]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
refs #80 - Sketch base GUI: create/draw point, circle and arc
authornds <natalia.donis@opencascade.com>
Wed, 25 Jun 2014 10:03:57 +0000 (14:03 +0400)
committernds <natalia.donis@opencascade.com>
Wed, 25 Jun 2014 10:03:57 +0000 (14:03 +0400)
1. It shows a line edit control to visualize a feature name in the WidgetFeature.

src/ModuleBase/ModuleBase_WidgetFactory.cpp
src/ModuleBase/ModuleBase_WidgetFeature.cpp
src/ModuleBase/ModuleBase_WidgetFeature.h
src/SketchPlugin/plugin-Sketch.xml

index a88a3086063388ad47af60ad03e314a8f52d1f54..8f97d85de8bd810437bd06894d4c62d03cdc97d1 100644 (file)
@@ -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
index 6007743f5248434f95cb489e300ac6031a98987d..fc095adedfd09f19890490542e91170832f27c47 100644 (file)
@@ -16,6 +16,9 @@
 #include <ModelAPI_AttributeRefAttr.h>
 
 #include <QWidget>
+#include <QLineEdit>
+#include <QHBoxLayout>
+#include <QLabel>
 
 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<ModelAPI_AttributeRefAttr>(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<ModelAPI_AttributeRefAttr> aRef =
           boost::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(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<QWidget*> ModuleBase_WidgetFeature::getControls() const
 {
-  QList<QWidget*> aControls;
-  return aControls;
+  QList<QWidget*> aList;
+  aList.append(myLabel);
+  aList.append(myEditor);
+  return aList;
 }
index a429421f0b3c01ef0666edc3c91ea4f6ce0343b0..45891e9226cca19cf9af394d83879c06d66c525e 100644 (file)
@@ -12,6 +12,9 @@
 #include <QStringList>
 
 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
index fc4b9d6b556e1f2a189042725f518a03d3fc8ddd..cd32b5528c18e33a311113fb28e06504751d4697 100644 (file)
       <feature id="SketchConstraintCoincidence" title="Points coincidence" tooltip="Create constraint for the coincidence of two points" internal="1"/>
       <feature id="SketchConstraintDistance" title="Distance between objects" tooltip="Create constraint for the distance from a point to an object">
         <label title="Select point and another feature (point or point on line) between which to calculate distance" tooltip="Select point and another feature (point or point on line) between which to calculate distance"/>
-        <feature_selector id="ConstraintEntityA" keysequence="SketchPoint" internal="1"/>
-        <feature_selector id="ConstraintEntityB" keysequence="SketchPoint" internal="1"/>
+        <feature_selector id="ConstraintEntityA" label="First point" tooltip="Select an entity in the viewer" keysequence="SketchPoint"/>
+        <feature_selector id="ConstraintEntityB" label="Last point" tooltip="Select an entity in the viewer" keysequence="SketchPoint"/>
         <point_selector id="ConstraintFlyoutValuePnt" internal="1"/>
         <doublevalue_editor id="ConstraintValue"/>
       </feature>
       <feature id="SketchConstraintLength" title="Length of a line" tooltip="Create constraint for the given length of a line segment">
         <label title="Select a line entity on which to calculate lenght" tooltip="Select a line entity on which to calculate lenght"/>
-        <feature_selector id="ConstraintEntityA" keysequence="SketchLine" internal="1"/>
+        <feature_selector id="ConstraintEntityA" label="Line" tooltip="Select an entity in the viewer" keysequence="SketchLine"/>
         <point_selector id="ConstraintFlyoutValuePnt" internal="1"/>
         <doublevalue_editor id="ConstraintValue"/>
       </feature>
       <feature id="SketchConstraintRadius" title="Radius of a circle or an arc" tooltip="Create constraint for the given radius of a circle or an arc">
         <label title="Select two points on a circle or an arc of circle on which to calculate radius" tooltip="Select two points on a circle or an arc of circle on which to calculate radius"/>
-        <feature_selector id="ConstraintEntityA" keysequence="SketchCircle SketchArc" internal="1"/>
+        <feature_selector id="ConstraintEntityA" label="Circle or Arc" tooltip="Select an entity in the viewer" keysequence="SketchCircle SketchArc"/>
         <point_selector id="ConstraintFlyoutValuePnt" internal="1"/>
         <doublevalue_editor id="ConstraintValue"/>
       </feature>
       <feature id="SketchConstraintParallel" title="Parallelism of a lines" tooltip="Create constraint defining two parallel lines">
-        <feature_selector id="ConstraintEntityA" keysequence="SketchLine" internal="1"/>
-        <feature_selector id="ConstraintEntityB" keysequence="SketchLine" internal="1"/>
+        <feature_selector id="ConstraintEntityA" label="First line" tooltip="Select an entity in the viewer" keysequence="SketchLine"/>
+        <feature_selector id="ConstraintEntityB" label="Last line" tooltip="Select an entity in the viewer" keysequence="SketchLine"/>
       </feature>
       <feature id="SketchConstraintPerpendicular" title="Orthgonality of a lines" tooltip="Create constraint defining two perpendicular lines">
-        <feature_selector id="ConstraintEntityA" keysequence="SketchLine" internal="1"/>
-        <feature_selector id="ConstraintEntityB" keysequence="SketchLine" internal="1"/>
+        <feature_selector id="ConstraintEntityA" label="First line" tooltip="Select an entity in the viewer" keysequence="SketchLine"/>
+        <feature_selector id="ConstraintEntityB" label="Last line" tooltip="Select an entity in the viewer" keysequence="SketchLine"/>
       </feature>
     </group>
   </workbench>