]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Prepare extrusion feature
authorvsv <vitaly.smetannikov@opencascade.com>
Mon, 2 Jun 2014 07:53:52 +0000 (11:53 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Mon, 2 Jun 2014 07:53:52 +0000 (11:53 +0400)
18 files changed:
src/Config/Config_Keywords.h
src/ConstructionPlugin/CMakeLists.txt
src/ConstructionPlugin/ConstructionPlugin_Extrusion.cpp [new file with mode: 0644]
src/ConstructionPlugin/ConstructionPlugin_Extrusion.h [new file with mode: 0644]
src/ConstructionPlugin/ConstructionPlugin_Plugin.cpp
src/ConstructionPlugin/extrusion_widget.xml [new file with mode: 0644]
src/ConstructionPlugin/plugin-Construction.xml
src/Model/CMakeLists.txt
src/Model/Model_AttributeBoolean.cpp [new file with mode: 0644]
src/Model/Model_AttributeBoolean.h [new file with mode: 0644]
src/ModelAPI/CMakeLists.txt
src/ModelAPI/ModelAPI_AttributeBoolean.h [new file with mode: 0644]
src/ModelAPI/ModelAPI_PluginManager.cpp
src/ModuleBase/ModuleBase_WidgetFactory.cpp
src/ModuleBase/ModuleBase_WidgetFactory.h
src/PartSet/PartSet_icons.qrc
src/PartSet/icons/dimension_v.png [new file with mode: 0644]
src/PartSet/icons/hand_point.png [new file with mode: 0644]

index 2056a658bff44d66ffcb4630482371009760d120..125faa57a0879e241a273c5f94d7c27a79adee24 100644 (file)
@@ -18,6 +18,7 @@ const static char* NODE_SOURCE = "source";
 
 //Widgets
 const static char* WDG_DOUBLEVALUE = "doublevalue";
+const static char* WDG_BOOLVALUE = "boolvalue";
 //Widget containers
 const static char* WDG_INFO = "label";
 const static char* WDG_GROUP = "groupbox";
@@ -26,6 +27,7 @@ const static char* WDG_TOOLBOX = "toolbox";
 const static char* WDG_TOOLBOX_BOX = "box";
 const static char* WDG_SWITCH = "switch";
 const static char* WDG_SWITCH_CASE = "case";
+const static char* WDG_SELECTOR = "selector";
 
 //Specific widget containers
 const static char* WDG_POINT_SELECTOR = "point_selector";
index 7fe6d649c3b671b6cb6dacc3581a394fb47920c1..ab34919147ff1251a53a238fd62bec0a005e75ec 100644 (file)
@@ -4,11 +4,13 @@ SET(PROJECT_HEADERS
     ConstructionPlugin.h
     ConstructionPlugin_Plugin.h
     ConstructionPlugin_Point.h
+    ConstructionPlugin_Extrusion.h
 )
 
 SET(PROJECT_SOURCES
     ConstructionPlugin_Plugin.cpp
     ConstructionPlugin_Point.cpp
+    ConstructionPlugin_Extrusion.cpp
 )
 
 ADD_DEFINITIONS(-DCONSTRUCTIONPLUGIN_EXPORTS ${BOOST_DEFINITIONS})
@@ -22,6 +24,7 @@ INCLUDE_DIRECTORIES(
 SET(XML_RESOURCES
   plugin-Construction.xml
   point_widget.xml
+  extrusion_widget.xml
 )
 
 INSTALL(TARGETS ConstructionPlugin DESTINATION plugins)
diff --git a/src/ConstructionPlugin/ConstructionPlugin_Extrusion.cpp b/src/ConstructionPlugin/ConstructionPlugin_Extrusion.cpp
new file mode 100644 (file)
index 0000000..8b5dc2d
--- /dev/null
@@ -0,0 +1,33 @@
+// File:        ConstructionPlugin_Extrusion.cpp
+// Created:     30 May 2014
+// Author:      Vitaly SMETANNIKOV
+
+#include "ConstructionPlugin_Extrusion.h"
+#include <ModelAPI_PluginManager.h>
+#include <ModelAPI_Document.h>
+#include <ModelAPI_Data.h>
+#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_AttributeReference.h>
+#include <ModelAPI_AttributeBoolean.h>
+
+using namespace std;
+
+ConstructionPlugin_Extrusion::ConstructionPlugin_Extrusion()
+{
+}
+
+void ConstructionPlugin_Extrusion::initAttributes()
+{
+  data()->addAttribute(EXTRUSION_FACE, ModelAPI_AttributeReference::type());
+  data()->addAttribute(EXTRUSION_SIZE, ModelAPI_AttributeDouble::type());
+  data()->addAttribute(EXTRUSION_REVERCE, ModelAPI_AttributeBoolean::type());
+}
+
+// this is for debug only
+#include <iostream>
+void ConstructionPlugin_Extrusion::execute() 
+{
+  // TODO: create a real shape for the point using OCC layer
+  //cout<<"X="<<data()->real(POINT_ATTR_X)->value()<<" Y="<<data()->real(POINT_ATTR_Y)->value()
+  //    <<" Z="<<data()->real(POINT_ATTR_Z)->value()<<endl;
+}
diff --git a/src/ConstructionPlugin/ConstructionPlugin_Extrusion.h b/src/ConstructionPlugin/ConstructionPlugin_Extrusion.h
new file mode 100644 (file)
index 0000000..6d557a3
--- /dev/null
@@ -0,0 +1,42 @@
+// File:        ConstructionPlugin_Extrusion.h
+// Created:     30 May 2014
+// Author:      Vitaly SMETANNIKOV
+
+#ifndef ConstructionPlugin_Extrusion_HeaderFile
+#define ConstructionPlugin_Extrusion_HeaderFile
+
+#include "ConstructionPlugin.h"
+#include <ModelAPI_Feature.h>
+
+/// attribute name of referenced face
+const std::string EXTRUSION_FACE = "extrusion_select_face";
+
+/// attribute name of extrusion size
+const std::string EXTRUSION_SIZE = "extrusion_size";
+
+/// attribute name of reverce direction
+const std::string EXTRUSION_REVERCE = "extrusion_reverse";
+
+
+class ConstructionPlugin_Extrusion: public ModelAPI_Feature
+{
+public:
+  /// Returns the kind of a feature
+  CONSTRUCTIONPLUGIN_EXPORT virtual const std::string& getKind() 
+  { static std::string MY_KIND = "Extrusion"; return MY_KIND; }
+
+  /// Returns to which group in the document must be added feature
+  CONSTRUCTIONPLUGIN_EXPORT virtual const std::string& getGroup() 
+  { static std::string MY_GROUP = "Construction";  return MY_GROUP; }
+
+  /// Creates a new part document if needed
+  CONSTRUCTIONPLUGIN_EXPORT virtual void execute();
+
+  /// Request for initialization of data model of the feature: adding all attributes
+  CONSTRUCTIONPLUGIN_EXPORT virtual void initAttributes();
+
+  /// Use plugin manager for features creation
+  ConstructionPlugin_Extrusion();
+};
+
+#endif
index 5c1f39f2f8de2dfc5bc87f1df52371d2fbb9dff3..a825c5608e0a96cc95a2a453623bc65088706c6e 100644 (file)
@@ -1,5 +1,7 @@
 #include "ConstructionPlugin_Plugin.h"
 #include "ConstructionPlugin_Point.h"
+#include "ConstructionPlugin_Extrusion.h"
+
 #include <ModelAPI_PluginManager.h>
 #include <ModelAPI_Document.h>
 
@@ -18,6 +20,8 @@ boost::shared_ptr<ModelAPI_Feature> ConstructionPlugin_Plugin::createFeature(str
 {
   if (theFeatureID == "Point") {
     return boost::shared_ptr<ModelAPI_Feature>(new ConstructionPlugin_Point);
+  } else if (theFeatureID == "Extrusion") {
+    return boost::shared_ptr<ModelAPI_Feature>(new ConstructionPlugin_Extrusion);
   }
   // feature of such kind is not found
   return boost::shared_ptr<ModelAPI_Feature>();
diff --git a/src/ConstructionPlugin/extrusion_widget.xml b/src/ConstructionPlugin/extrusion_widget.xml
new file mode 100644 (file)
index 0000000..52cf862
--- /dev/null
@@ -0,0 +1,9 @@
+<source>
+  <selector id="extrusion_select_face" 
+    label="Select a face" 
+    icon=":icons/sketch.png" 
+    tooltip="Select a face for extrusion"
+  />
+  <doublevalue id="extrusion_size" label="Size" min="0" step="1.0" default="10" icon=":icons/dimension_v.png" tooltip="Set size of extrusion"/>
+  <boolvalue id="extrusion_reverse" label="Reverse" default="false" tooltip="Reverse default direction"/>
+</source>
index 8e86996877b49bbee33942038b5b299bee4152fb..4736d36cfa54344fbd11db2b318b8c8306917f41 100644 (file)
@@ -6,6 +6,9 @@
       </feature>
       <feature id="Axis" title="Axis" tooltip="Create a new axis" icon=":icons/axis.png" keysequence="" internal="true"/>
       <feature id="Plane" title="Plane" tooltip="Create a new plane" icon=":icons/plane.png" keysequence="" internal="true"/>
+      <feature id="Extrusion" title="Extrusion" tooltip="Create a shape by extrusion of a contour" icon=":icons/extrusion.png">
+          <source path="extrusion_widget.xml"/>
+      </feature>
     </group>
-  </workbench>  
+</workbench>  
 </plugin>
index 5db73c34774b755d8dbb34729b1ae8a32b41fe31..9da38b914c666e7dcd6563552f3372e5647f91d3 100644 (file)
@@ -13,6 +13,7 @@ SET(PROJECT_HEADERS
     Model_AttributeReference.h
     Model_AttributeRefAttr.h
     Model_AttributeRefList.h
+    Model_AttributeBoolean.h
     Model_Events.h
 )
 
@@ -27,6 +28,7 @@ SET(PROJECT_SOURCES
     Model_AttributeReference.cpp
     Model_AttributeRefAttr.cpp
     Model_AttributeRefList.cpp
+    Model_AttributeBoolean.cpp
     Model_Events.cpp
 )
 SET(PROJECT_LIBRARIES
diff --git a/src/Model/Model_AttributeBoolean.cpp b/src/Model/Model_AttributeBoolean.cpp
new file mode 100644 (file)
index 0000000..d3c0d6b
--- /dev/null
@@ -0,0 +1,33 @@
+// File:        Model_AttributeBoolean.cpp
+// Created:     2 june 2014
+// Author:      Vitaly Smetannikov
+
+#include "Model_AttributeBoolean.h"
+#include "Model_Events.h"
+#include <Events_Loop.h>
+
+using namespace std;
+
+void Model_AttributeBoolean::setValue(bool theValue)
+{
+  if (myBool->Get() != theValue) {
+    myBool->Set(theValue? 1 : 0);
+    static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_UPDATED);
+    Model_FeatureUpdatedMessage aMsg(owner(), anEvent);
+    Events_Loop::loop()->send(aMsg);
+  }
+}
+
+bool Model_AttributeBoolean::value()
+{
+  return (myBool->Get() == 1)? true : false;
+}
+
+Model_AttributeBoolean::Model_AttributeBoolean(TDF_Label& theLabel)
+{
+  // check the attribute could be already presented in this doc (after load document)
+  if (!theLabel.FindAttribute(TDataStd_Integer::GetID(), myBool)) {
+    // create attribute: not initialized by value yet, just zero
+    myBool = TDataStd_Integer::Set(theLabel, 0);
+  }
+}
diff --git a/src/Model/Model_AttributeBoolean.h b/src/Model/Model_AttributeBoolean.h
new file mode 100644 (file)
index 0000000..331fa13
--- /dev/null
@@ -0,0 +1,35 @@
+// File:        Model_AttributeBoolean.h
+// Created:     2 june 2014
+// Author:      Vitaly Smetannikov
+
+#ifndef Model_AttributeBoolean_HeaderFile
+#define Model_AttributeBoolean_HeaderFile
+
+#include "Model.h"
+#include "ModelAPI_AttributeBoolean.h"
+#include <TDataStd_Integer.hxx>
+#include <TDF_Label.hxx>
+
+/**\class Model_AttributeDouble
+ * \ingroup DataModel
+ * \brief Attribute that contains real value with double precision.
+ */
+
+class Model_AttributeBoolean : public ModelAPI_AttributeBoolean
+{
+  Handle_TDataStd_Integer myBool; ///< double is Real attribute
+public:
+  /// Defines the double value
+  MODEL_EXPORT virtual void setValue(bool theValue);
+
+  /// Returns the double value
+  MODEL_EXPORT virtual bool value();
+
+protected:
+  /// Initializes attibutes
+  Model_AttributeBoolean(TDF_Label& theLabel);
+
+  friend class Model_Data;
+};
+
+#endif
index 49757f69fe70022388c2ecab6a6b10fc6b4919ec..981d5567d82e4bda6a5dd79f327fd2762fa21217 100644 (file)
@@ -16,6 +16,7 @@ SET(PROJECT_HEADERS
     ModelAPI_AttributeReference.h
     ModelAPI_AttributeRefAttr.h
     ModelAPI_AttributeRefList.h
+    ModelAPI_AttributeBoolean.h
 )
 
 SET(PROJECT_SOURCES
diff --git a/src/ModelAPI/ModelAPI_AttributeBoolean.h b/src/ModelAPI/ModelAPI_AttributeBoolean.h
new file mode 100644 (file)
index 0000000..038b93f
--- /dev/null
@@ -0,0 +1,38 @@
+// File:        ModelAPI_AttributeBoolean.h
+// Created:     2 june 2014
+// Author:      Vitaly Smetannikov
+
+#ifndef ModelAPI_AttributeBoolean_HeaderFile
+#define ModelAPI_AttributeBoolean_HeaderFile
+
+#include "ModelAPI_Attribute.h"
+
+/**\class ModelAPI_AttributeBoolean
+ * \ingroup DataModel
+ * \brief Attribute that contains boolean value.
+ */
+
+class ModelAPI_AttributeBoolean : public ModelAPI_Attribute
+{
+public:
+  /// Defines the double value
+  MODELAPI_EXPORT virtual void setValue(bool theValue) = 0;
+
+  /// Returns the double value
+  MODELAPI_EXPORT virtual bool value() = 0;
+
+  /// Returns the type of this class of attributes
+  MODELAPI_EXPORT static std::string type() {return "Boolean";}
+
+  /// Returns the type of this class of attributes, not static method
+  MODELAPI_EXPORT virtual std::string attributeType() {return type();}
+
+  /// To virtually destroy the fields of successors
+  MODELAPI_EXPORT virtual ~ModelAPI_AttributeBoolean() {}
+
+protected:
+  /// Objects are created for features automatically
+  MODELAPI_EXPORT ModelAPI_AttributeBoolean() {}
+};
+
+#endif
index eb79b9d03d3a7e0c32e119be73a8b43204bc353c..4cf100d5c12719b0fd6f02d6267e08065190f2b8 100644 (file)
@@ -15,6 +15,7 @@
 #include <ModelAPI_Attribute.h>
 #include <ModelAPI_AttributeDocRef.h>
 #include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_AttributeBoolean.h>
 #include <ModelAPI_AttributeReference.h>
 #include <ModelAPI_AttributeRefAttr.h>
 #include <ModelAPI_AttributeRefList.h>
index e5212c7e85f70d8d4f61cf562f204976ca77dfd3..1ef8c83d8bedc66cea3b12e801dd69b0ee4d303c 100644 (file)
@@ -25,6 +25,9 @@
 #include <QPixmap>
 #include <QGroupBox>
 #include <QToolBox>
+#include <QLineEdit>
+#include <QToolButton>
+#include <QCheckBox>
 
 #ifdef _DEBUG
 #include <QDebug>
@@ -104,13 +107,20 @@ QWidget* ModuleBase_WidgetFactory::createWidgetByType(const std::string& theType
   QWidget* result = NULL;
   if (theType == WDG_DOUBLEVALUE) {
     result = doubleSpinBoxControl();
+
   } else if (theType == WDG_INFO) {
     result = labelControl(theParent);
-  }
-  else if (theType == WDG_POINT_SELECTOR) {
+
+  } else if (theType == WDG_SELECTOR) {
+    result = selectorControl(theParent);
+
+  } else if (theType == WDG_BOOLVALUE) {
+    result = booleanControl(theParent);
+
+  } else if (theType == WDG_POINT_SELECTOR) {
     result = pointSelectorControl(theParent);
-  }
-  else if (myWidgetApi->isContainerWidget() || myWidgetApi->isPagedWidget()) {
+
+  else if (myWidgetApi->isContainerWidget() || myWidgetApi->isPagedWidget()) {
     result = createContainer(theType, theParent);
   }
 #ifdef _DEBUG
@@ -215,3 +225,44 @@ QString ModuleBase_WidgetFactory::qs(const std::string& theStdString) const
 {
   return QString::fromStdString(theStdString);
 }
+
+
+QWidget* ModuleBase_WidgetFactory::selectorControl(QWidget* theParent)
+{
+  QWidget* aRes = new QWidget();
+  QHBoxLayout* aLayout = new QHBoxLayout(aRes);
+
+  aLayout->setContentsMargins(0, 0, 0, 0);
+  QString aLabelText = qs(myWidgetApi->widgetLabel());
+  QString aLabelIcon = qs(myWidgetApi->widgetIcon());
+  QLabel* aLabel = new QLabel(aLabelText, aRes);
+  aLabel->setPixmap(QPixmap(aLabelIcon));
+
+  aLayout->addWidget(aLabel);
+
+  QLineEdit* aTextLine = new QLineEdit(aRes);
+  aTextLine->setReadOnly(true);
+
+  aLayout->addWidget(aTextLine);
+
+  QToolButton* aActivateBtn = new QToolButton(aRes);
+  aActivateBtn->setIcon(QIcon(":icons/hand_point.png"));
+  aActivateBtn->setCheckable(true);
+
+  aLayout->addWidget(aActivateBtn);
+
+  return aRes;
+}
+
+
+QWidget* ModuleBase_WidgetFactory::booleanControl(QWidget* theParent)
+{
+  QString aText = qs(myWidgetApi->widgetLabel());
+  QString aToolTip = qs(myWidgetApi->widgetTooltip());
+  QString aDefault = qs(myWidgetApi->getProperty("default"));
+
+  QCheckBox* aRes = new QCheckBox(aText, theParent);
+  aRes->setToolTip(aToolTip);
+  aRes->setChecked(aDefault == "true");
+  return aRes;
+}
\ No newline at end of file
index bf765824f95dcdbc4a106bd1e4e0ad761f4738f6..f0303cdae36e66a47d336cb935514118650a8054 100644 (file)
@@ -39,6 +39,8 @@ protected:
   QWidget* doubleSpinBoxControl();
   QWidget* pointSelectorControl(QWidget* theParent);
   QWidget* createContainer(const std::string& theType, QWidget* theParent = NULL);
+  QWidget* selectorControl(QWidget* theParent);
+  QWidget* booleanControl(QWidget* theParent);
 
   bool connectWidget(QObject*, const QString&);
   QString qs(const std::string& theStdString) const;
index f3300ede58262776b78a58a529f2ca12b0387d47..89a8e5735c3afc339c6ed105555f5f616c70262d 100644 (file)
@@ -13,5 +13,7 @@
      <file>icons/import.png</file>
      <file>icons/line.png</file>
      <file>icons/sketch.png</file>
+     <file>icons/hand_point.png</file>
+     <file>icons/dimension_v.png</file>
  </qresource>
  </RCC>
diff --git a/src/PartSet/icons/dimension_v.png b/src/PartSet/icons/dimension_v.png
new file mode 100644 (file)
index 0000000..6213de3
Binary files /dev/null and b/src/PartSet/icons/dimension_v.png differ
diff --git a/src/PartSet/icons/hand_point.png b/src/PartSet/icons/hand_point.png
new file mode 100644 (file)
index 0000000..31c4813
Binary files /dev/null and b/src/PartSet/icons/hand_point.png differ