From 8f0712c06f339f4da39e951ca83e35b59e447018 Mon Sep 17 00:00:00 2001 From: nds Date: Wed, 25 Jun 2014 14:03:57 +0400 Subject: [PATCH] refs #80 - Sketch base GUI: create/draw point, circle and arc 1. It shows a line edit control to visualize a feature name in the WidgetFeature. --- src/ModuleBase/ModuleBase_WidgetFactory.cpp | 3 +- src/ModuleBase/ModuleBase_WidgetFeature.cpp | 39 ++++++++++++++++----- src/ModuleBase/ModuleBase_WidgetFeature.h | 7 ++++ src/SketchPlugin/plugin-Sketch.xml | 16 ++++----- 4 files changed, 47 insertions(+), 18 deletions(-) diff --git a/src/ModuleBase/ModuleBase_WidgetFactory.cpp b/src/ModuleBase/ModuleBase_WidgetFactory.cpp index a88a30860..8f97d85de 100644 --- a/src/ModuleBase/ModuleBase_WidgetFactory.cpp +++ b/src/ModuleBase/ModuleBase_WidgetFactory.cpp @@ -64,8 +64,9 @@ void ModuleBase_WidgetFactory::createWidget(QWidget* theParent) if (!isInternalWidget(aWdgType)) { aWidgetLay->addWidget(aWidget); } - else + else { aWidget->setVisible(false); + } } if (myWidgetApi->isContainerWidget()) { //if current widget is groupbox (container) process it's children recursively diff --git a/src/ModuleBase/ModuleBase_WidgetFeature.cpp b/src/ModuleBase/ModuleBase_WidgetFeature.cpp index 6007743f5..fc095aded 100644 --- a/src/ModuleBase/ModuleBase_WidgetFeature.cpp +++ b/src/ModuleBase/ModuleBase_WidgetFeature.cpp @@ -16,6 +16,9 @@ #include #include +#include +#include +#include ModuleBase_WidgetFeature::ModuleBase_WidgetFeature(QWidget* theParent, const Config_WidgetAPI* theData) @@ -23,6 +26,26 @@ ModuleBase_WidgetFeature::ModuleBase_WidgetFeature(QWidget* theParent, { QString aKinds = QString::fromStdString(theData->getProperty(FEATURE_KEYSEQUENCE)); myFeatureKinds = aKinds.split(" "); + + myContainer = new QWidget(theParent); + QHBoxLayout* aControlLay = new QHBoxLayout(myContainer); + aControlLay->setContentsMargins(0, 0, 0, 0); + + QString aLabelText = QString::fromStdString(theData->widgetLabel()); + myLabel = new QLabel(aLabelText, myContainer); + aControlLay->addWidget(myLabel); + + myEditor = new QLineEdit(myContainer); + QString anObjName = QString::fromStdString(attributeID()); + myEditor->setObjectName(anObjName); + myEditor->setReadOnly(true); + aControlLay->addWidget(myEditor); + + QString aTTip = QString::fromStdString(theData->widgetTooltip()); + myEditor->setToolTip(aTTip); + + aControlLay->addWidget(myEditor); + aControlLay->setStretch(1, 1); } ModuleBase_WidgetFeature::~ModuleBase_WidgetFeature() @@ -34,9 +57,8 @@ bool ModuleBase_WidgetFeature::setFeature(const FeaturePtr& theFeature) if (!theFeature || !myFeatureKinds.contains(theFeature->getKind().c_str())) return false; - //bool isBlocked = this->blockSignals(true); myFeature = theFeature; - //this->blockSignals(isBlocked); + myEditor->setText(theFeature ? theFeature->data()->getName().c_str() : ""); emit valuesChanged(); return true; } @@ -48,11 +70,9 @@ bool ModuleBase_WidgetFeature::storeValue(FeaturePtr theFeature) const boost::dynamic_pointer_cast(aData->attribute(attributeID())); ModuleBase_WidgetFeature* that = (ModuleBase_WidgetFeature*) this; - //bool isBlocked = that->blockSignals(true); aRef->setFeature(myFeature); theFeature->execute(); Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_FEATURE_UPDATED)); - //that->blockSignals(isBlocked); return true; } @@ -63,19 +83,20 @@ bool ModuleBase_WidgetFeature::restoreValue(FeaturePtr theFeature) boost::shared_ptr aRef = boost::dynamic_pointer_cast(aData->attribute(attributeID())); - //bool isBlocked = this->blockSignals(true); myFeature = aRef->feature(); - //this->blockSignals(isBlocked); + myEditor->setText(myFeature ? myFeature->data()->getName().c_str() : ""); return true; } QWidget* ModuleBase_WidgetFeature::getControl() const { - return 0; + return myContainer; } QList ModuleBase_WidgetFeature::getControls() const { - QList aControls; - return aControls; + QList aList; + aList.append(myLabel); + aList.append(myEditor); + return aList; } diff --git a/src/ModuleBase/ModuleBase_WidgetFeature.h b/src/ModuleBase/ModuleBase_WidgetFeature.h index a429421f0..45891e922 100644 --- a/src/ModuleBase/ModuleBase_WidgetFeature.h +++ b/src/ModuleBase/ModuleBase_WidgetFeature.h @@ -12,6 +12,9 @@ #include class ModelAPI_Feature; +class QWidget; +class QLabel; +class QLineEdit; /**\class ModuleBase_WidgetFeature * \ingroup GUI @@ -50,6 +53,10 @@ public: private: FeaturePtr myFeature; ///< the current widget feature QStringList myFeatureKinds; ///< the kinds of possible features + + QWidget* myContainer; /// the parent top control + QLabel* myLabel; /// the editor information label + QLineEdit* myEditor; ///< the feature editor to visualize the feature name }; #endif diff --git a/src/SketchPlugin/plugin-Sketch.xml b/src/SketchPlugin/plugin-Sketch.xml index fc4b9d6b5..cd32b5528 100644 --- a/src/SketchPlugin/plugin-Sketch.xml +++ b/src/SketchPlugin/plugin-Sketch.xml @@ -24,30 +24,30 @@ - - + + - - + + -- 2.39.2