]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'master' of newgeom:newgeom
authormpv <mikhail.ponikarov@opencascade.com>
Wed, 23 Apr 2014 04:17:13 +0000 (08:17 +0400)
committermpv <mikhail.ponikarov@opencascade.com>
Wed, 23 Apr 2014 04:17:13 +0000 (08:17 +0400)
Conflicts:
CMakeLists.txt
src/Config/CMakeLists.txt
src/Config/plugins.xml

31 files changed:
CMakeLists.txt
src/Config/plugins.xml
src/ModelAPI/ModelAPI_Document.h
src/ModuleBase/ModuleBase_Operation.cpp
src/ModuleBase/ModuleBase_Operation.h
src/PartSet/CMakeLists.txt
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_OperationSketch.cpp [new file with mode: 0644]
src/PartSet/PartSet_OperationSketch.h [new file with mode: 0644]
src/PartSet/PartSet_OperationSketchBase.cpp [new file with mode: 0644]
src/PartSet/PartSet_OperationSketchBase.h [new file with mode: 0644]
src/PartSet/PartSet_icons.qrc
src/PartSet/icons/line.png [new file with mode: 0644]
src/PartSet/icons/sketch.png [new file with mode: 0644]
src/SketchPlugin/CMakeLists.txt [new file with mode: 0644]
src/SketchPlugin/SketchPlugin.h [new file with mode: 0644]
src/SketchPlugin/SketchPlugin_Feature.cpp [new file with mode: 0644]
src/SketchPlugin/SketchPlugin_Feature.h [new file with mode: 0644]
src/SketchPlugin/SketchPlugin_Plugin.cpp [new file with mode: 0644]
src/SketchPlugin/SketchPlugin_Plugin.h [new file with mode: 0644]
src/SketchPlugin/SketchPlugin_Sketch.cpp [new file with mode: 0644]
src/SketchPlugin/SketchPlugin_Sketch.h [new file with mode: 0644]
src/SketchPlugin/plugin-Sketch.xml [new file with mode: 0644]
src/XGUI/CMakeLists.txt
src/XGUI/XGUI_Displayer.cpp [new file with mode: 0644]
src/XGUI/XGUI_Displayer.h [new file with mode: 0644]
src/XGUI/XGUI_Viewer.cpp
src/XGUI/XGUI_Viewer.h
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h

index b5dd0ebd4b68198848779931de5c83e9da974fac..dc4b8fd191e0706ff1d6fbfeffaf69c846558569 100644 (file)
@@ -26,6 +26,7 @@ ADD_SUBDIRECTORY (src/ModuleBase)
 ADD_SUBDIRECTORY (src/PartSet)
 ADD_SUBDIRECTORY (src/PartSetPlugin)
 ADD_SUBDIRECTORY (src/ConstructionPlugin)
+ADD_SUBDIRECTORY (src/SketchPlugin)
 ADD_SUBDIRECTORY (src/PyConsole)
 ADD_SUBDIRECTORY (src/PyEvent)
 ADD_SUBDIRECTORY (src/PyInterp)
index fa22efe2a011009d04e8466df05b766168c9b8f3..2f4f45fd9de3456a23bfa516aec5b059d6d41f10 100644 (file)
@@ -1,4 +1,5 @@
 <plugins module="PartSet">
   <plugin library="PartSetPlugin" configuration="plugin-PartSet.xml"/>
+  <plugin library="SketchPlugin" configuration="plugin-Sketch.xml"/>
   <plugin library="ConstructionPlugin" configuration="plugin-Construction.xml"/>
 </plugins>
index 9f5f838e92457f1f0daba8fd311aae840744922c..378915c639ee65d153e5b4ea76235348def95b70 100644 (file)
@@ -20,6 +20,8 @@ static const std::string PARAMETERS_GROUP = "Parameters";
 static const std::string CONSTRUCTIONS_GROUP = "Construction";
 /// Group of parts
 static const std::string PARTS_GROUP = "Parts";
+/// Group of sketches
+static const std::string SKETCHS_GROUP = "Sketchs";
 
 /**\class Model_Document
  * \ingroup DataModel
index a6afc4d5f2f0dd246ae7ade945f065ac6f621309..e2e6891c4084ab79244b1899eb4ef1da73a217e5 100644 (file)
@@ -54,6 +54,11 @@ QString ModuleBase_Operation::operationId() const
   return myOperationId;
 }
 
+std::shared_ptr<ModelAPI_Feature> ModuleBase_Operation::feature() const
+{
+  return myFeature;
+}
+
 /*!
  * \brief Gets state of operation
  * \return Value from OperationState enumeration
index 5daf8e6c66d974db3824dd9ccc599056bb26de7c..a3c0c40c18aa4925a9be7995f7fe6acfd5d38e5f 100644 (file)
@@ -46,7 +46,7 @@ public:
   enum OperationState
   {
     Waiting,  //!< Operation is not used (it is not run or suspended)
-    Running,  //!< Operation is started
+    Running  //!< Operation is started
   };
 
   /*!
@@ -76,6 +76,8 @@ public:
   // Operation processing.
   virtual QString operationId() const;
 
+  std::shared_ptr<ModelAPI_Feature> feature() const;
+
   OperationState state() const;
   bool isRunning() const;
   virtual bool isValid(ModuleBase_Operation* theOtherOp) const;
index 0300761e69687bea5b337f0eb2ef4dd57707b84e..81da4af8346a1669793761e2f592b59cd60d7ff3 100644 (file)
@@ -1,13 +1,19 @@
 INCLUDE(Common)
+INCLUDE(FindCAS)
+
 SET(CMAKE_AUTOMOC ON)
 
 SET(PROJECT_HEADERS
        PartSet.h
        PartSet_Module.h
+       PartSet_OperationSketchBase.h
+        PartSet_OperationSketch.h
 )
 
 SET(PROJECT_SOURCES
        PartSet_Module.cpp
+       PartSet_OperationSketchBase.cpp
+       PartSet_OperationSketch.cpp
 )
 
 SET(PROJECT_RESOURCES 
@@ -22,6 +28,7 @@ SET(PROJECT_LIBRARIES
     ModuleBase
     Config
     ${QT_LIBRARIES}
+    ${CAS_KERNEL}
 )
 
 SET(PROJECT_AUTOMOC 
@@ -38,9 +45,12 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/XGUI
                     ${CMAKE_SOURCE_DIR}/src/Config
                     ${CMAKE_SOURCE_DIR}/src/Event
                     ${CMAKE_SOURCE_DIR}/src/ModuleBase
+                    ${CMAKE_SOURCE_DIR}/src/ModelAPI
+                    ${CMAKE_SOURCE_DIR}/src/SketchPlugin
+                    ${CAS_INCLUDE_DIRS}
 )
 
-ADD_DEFINITIONS(-DPARTSET_EXPORTS)
+ADD_DEFINITIONS(-DPARTSET_EXPORTS ${CAS_DEFINITIONS})
 ADD_LIBRARY(PartSet SHARED 
        ${PROJECT_SOURCES} 
        ${PROJECT_HEADERS} 
@@ -50,7 +60,7 @@ ADD_LIBRARY(PartSet SHARED
 )
 
 # The Qt5Widgets_LIBRARIES variable also includes QtGui and QtCore
-TARGET_LINK_LIBRARIES(PartSet ${PROJECT_LIBRARIES})
+TARGET_LINK_LIBRARIES(PartSet ${PROJECT_LIBRARIES} XGUI ModelAPI SketchPlugin)
 
 ADD_DEPENDENCIES(PartSet ModuleBase)
 
index fb437c5ba52b712363473543f534ef9691f0c6e8..7a32a90bbf3d4c11ed9e73e72baa1ffb37b64e04 100644 (file)
@@ -1,5 +1,10 @@
 #include <PartSet_Module.h>
-#include <ModuleBase_PropPanelOperation.h>
+#include <PartSet_OperationSketch.h>
+
+#include <ModuleBase_Operation.h>
+
+#include <XGUI_MainWindow.h>
+#include <XGUI_Displayer.h>
 
 #include <Config_PointerMessage.h>
 #include <Config_ModuleReader.h>
@@ -59,9 +64,31 @@ void PartSet_Module::onFeatureTriggered()
   //TODO(sbh): Implement static method to extract event id [SEID]
   static Event_ID aModuleEvent = Event_Loop::eventByName("PartSetModuleEvent");
   Config_PointerMessage aMessage(aModuleEvent, this);
-  ModuleBase_PropPanelOperation* aPartSetOp = new ModuleBase_PropPanelOperation(aCmdId, this);
+  ModuleBase_PropPanelOperation* aPartSetOp;
+  if (aCmdId == "Sketch" )
+    aPartSetOp = new PartSet_OperationSketch(aCmdId, this);
+  else
+    aPartSetOp = new ModuleBase_PropPanelOperation(aCmdId, this);
+
+  PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(aPartSetOp);
+  if (aPreviewOp)
+    connect(aPreviewOp, SIGNAL(visualizePreview()), this, SLOT(onVisualizePreview()));
+
   aPartSetOp->setXmlRepresentation(QString::fromStdString(aXmlCfg));
   aPartSetOp->setDescription(QString::fromStdString(aDescription));
   aMessage.setPointer(aPartSetOp);
   Event_Loop::loop()->send(aMessage);
 }
+
+void PartSet_Module::onVisualizePreview()
+{
+  ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
+  if (!anOperation)
+    return;
+
+  PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
+  if (!aPreviewOp)
+    return;
+
+  myWorkshop->displayer()->Display(anOperation->feature(), aPreviewOp->preview());
+}
index f4894e239868544517f7f7d0695b5d28065d3f21..b33d2ad7dac976aef554ba00e91c16c73c33182c 100644 (file)
@@ -20,6 +20,7 @@ public:
 
 public slots:
   void onFeatureTriggered();
+  void onVisualizePreview();
 
 private:
   XGUI_Workshop* myWorkshop;
diff --git a/src/PartSet/PartSet_OperationSketch.cpp b/src/PartSet/PartSet_OperationSketch.cpp
new file mode 100644 (file)
index 0000000..b5aa187
--- /dev/null
@@ -0,0 +1,22 @@
+#include <PartSet_OperationSketch.h>
+
+#include <SketchPlugin_Feature.h>
+
+#ifdef _DEBUG
+#include <QDebug>
+#endif
+
+using namespace std;
+
+PartSet_OperationSketch::PartSet_OperationSketch(const QString& theId,
+                                                    QObject* theParent)
+: PartSet_OperationSketchBase(theId, theParent)
+{
+}
+
+/*!
+ * \brief Destructor
+ */
+PartSet_OperationSketch::~PartSet_OperationSketch()
+{
+}
diff --git a/src/PartSet/PartSet_OperationSketch.h b/src/PartSet/PartSet_OperationSketch.h
new file mode 100644 (file)
index 0000000..99cacfb
--- /dev/null
@@ -0,0 +1,23 @@
+#ifndef PartSet_OperationSketch_H
+#define PartSet_OperationSketch_H
+
+#include "PartSet.h"
+
+#include <PartSet_OperationSketchBase.h>
+#include <QObject>
+
+/*!
+ \class PartSet_OperationSketch
+ * \brief The operation for the sketch creation
+ *
+ *  Base class for all operations. If you perform an action it is reasonable to create
+*/
+class PARTSET_EXPORT PartSet_OperationSketch : public PartSet_OperationSketchBase
+{
+Q_OBJECT
+public:
+  PartSet_OperationSketch(const QString& theId, QObject* theParent);
+  virtual ~PartSet_OperationSketch();
+};
+
+#endif
diff --git a/src/PartSet/PartSet_OperationSketchBase.cpp b/src/PartSet/PartSet_OperationSketchBase.cpp
new file mode 100644 (file)
index 0000000..c5b70b0
--- /dev/null
@@ -0,0 +1,46 @@
+#include <PartSet_OperationSketchBase.h>
+
+#include <SketchPlugin_Feature.h>
+
+#ifdef _DEBUG
+#include <QDebug>
+#endif
+
+using namespace std;
+
+/*!
+ \brief Constructor
+  \param theId an feature index
+  \param theParent the object parent
+ */
+PartSet_OperationSketchBase::PartSet_OperationSketchBase(const QString& theId,
+                                                            QObject* theParent)
+: ModuleBase_PropPanelOperation(theId, theParent)
+{
+}
+
+/*!
+ * \brief Destructor
+ */
+PartSet_OperationSketchBase::~PartSet_OperationSketchBase()
+{
+}
+
+/**
+ * Returns the feature preview shape
+ */
+const TopoDS_Shape& PartSet_OperationSketchBase::preview() const
+{
+  shared_ptr<SketchPlugin_Feature> aFeature = dynamic_pointer_cast<SketchPlugin_Feature>(feature());
+  return aFeature->preview();
+}
+
+/*!
+ * Perform the operation start and emit signal about visualization of the operation preview
+ */
+void PartSet_OperationSketchBase::startOperation()
+{
+  ModuleBase_PropPanelOperation::startOperation();
+
+  emit visualizePreview();
+}
diff --git a/src/PartSet/PartSet_OperationSketchBase.h b/src/PartSet/PartSet_OperationSketchBase.h
new file mode 100644 (file)
index 0000000..ceb8802
--- /dev/null
@@ -0,0 +1,33 @@
+#ifndef PartSet_OperationSketchBase_H
+#define PartSet_OperationSketchBase_H
+
+#include "PartSet.h"
+
+#include <TopoDS_Shape.hxx>
+
+#include <ModuleBase_PropPanelOperation.h>
+#include <QObject>
+
+/*!
+ \class PartSet_OperationSketchBase
+ * \brief The base operation for the sketch features.
+ *
+ *  Base class for all sketch operations. It provides an access to the feature preview
+*/
+class PARTSET_EXPORT PartSet_OperationSketchBase : public ModuleBase_PropPanelOperation
+{
+Q_OBJECT
+public:
+  PartSet_OperationSketchBase(const QString& theId, QObject* theParent);
+  virtual ~PartSet_OperationSketchBase();
+
+  const TopoDS_Shape& preview() const;
+
+signals:
+  void visualizePreview();
+
+protected:
+  virtual void startOperation();
+};
+
+#endif
index 571e1cd6fb9279b16fbe1d05082d65c3e37a55c2..f3300ede58262776b78a58a529f2ca12b0387d47 100644 (file)
@@ -11,5 +11,7 @@
      <file>icons/revol.png</file>
      <file>icons/common.png</file>
      <file>icons/import.png</file>
+     <file>icons/line.png</file>
+     <file>icons/sketch.png</file>
  </qresource>
  </RCC>
diff --git a/src/PartSet/icons/line.png b/src/PartSet/icons/line.png
new file mode 100644 (file)
index 0000000..6176fb6
Binary files /dev/null and b/src/PartSet/icons/line.png differ
diff --git a/src/PartSet/icons/sketch.png b/src/PartSet/icons/sketch.png
new file mode 100644 (file)
index 0000000..f2964c7
Binary files /dev/null and b/src/PartSet/icons/sketch.png differ
diff --git a/src/SketchPlugin/CMakeLists.txt b/src/SketchPlugin/CMakeLists.txt
new file mode 100644 (file)
index 0000000..f9e47c7
--- /dev/null
@@ -0,0 +1,36 @@
+INCLUDE(Common)
+INCLUDE(FindCAS)
+
+SET(PROJECT_HEADERS
+    SketchPlugin.h
+    SketchPlugin_Feature.h
+    SketchPlugin_Plugin.h
+    SketchPlugin_Sketch.h
+)
+
+SET(PROJECT_SOURCES
+    SketchPlugin_Feature.cpp
+    SketchPlugin_Plugin.cpp
+    SketchPlugin_Sketch.cpp
+)
+
+SET(PROJECT_LIBRARIES
+    ${CAS_KERNEL}
+    ${CAS_MODELER}
+)
+
+ADD_DEFINITIONS(-DSKETCHPLUGIN_EXPORTS ${BOOST_DEFINITIONS} ${CAS_DEFINITIONS})
+ADD_LIBRARY(SketchPlugin SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
+TARGET_LINK_LIBRARIES(SketchPlugin ${PROJECT_LIBRARIES} ModelAPI)
+
+INCLUDE_DIRECTORIES(
+  ${CAS_INCLUDE_DIRS}
+  ../ModelAPI
+)
+
+SET(XML_RESOURCES
+  plugin-Sketch.xml
+)
+
+INSTALL(TARGETS SketchPlugin DESTINATION plugins)
+INSTALL(FILES ${XML_RESOURCES} DESTINATION plugins)
diff --git a/src/SketchPlugin/SketchPlugin.h b/src/SketchPlugin/SketchPlugin.h
new file mode 100644 (file)
index 0000000..b7a5fcf
--- /dev/null
@@ -0,0 +1,18 @@
+#ifndef SKETCHPLUGIN_H
+#define SKETCHPLUGIN_H
+
+#if defined SKETCHPLUGIN_EXPORTS
+#if defined WIN32
+#define SKETCHPLUGIN_EXPORT              __declspec( dllexport )
+#else
+#define SKETCHPLUGIN_EXPORT
+#endif
+#else
+#if defined WIN32
+#define SKETCHPLUGIN_EXPORT              __declspec( dllimport )
+#else
+#define SKETCHPLUGIN_EXPORT
+#endif
+#endif
+
+#endif
diff --git a/src/SketchPlugin/SketchPlugin_Feature.cpp b/src/SketchPlugin/SketchPlugin_Feature.cpp
new file mode 100644 (file)
index 0000000..57bc358
--- /dev/null
@@ -0,0 +1,18 @@
+#include "SketchPlugin_Feature.h"
+
+/**
+ * Returns the sketch preview
+ */
+const TopoDS_Shape& SketchPlugin_Feature::preview()
+{
+  return myPreview;
+}
+
+/**
+ * Set the shape to the internal preview field
+ * \param theShape a preview shape
+ */
+void SketchPlugin_Feature::setPreview(const TopoDS_Shape& theShape)
+{
+  myPreview = theShape;
+}
diff --git a/src/SketchPlugin/SketchPlugin_Feature.h b/src/SketchPlugin/SketchPlugin_Feature.h
new file mode 100644 (file)
index 0000000..4b91631
--- /dev/null
@@ -0,0 +1,29 @@
+// File:        SketchPlugin_Feature.h
+// Created:     27 Mar 2014
+// Author:      Mikhail PONIKAROV
+
+#ifndef SketchPlugin_Feature_HeaderFile
+#define SketchPlugin_Feature_HeaderFile
+
+#include "SketchPlugin.h"
+#include <ModelAPI_Feature.h>
+
+#include "TopoDS_Shape.hxx"
+
+/**\class SketchPlugin_Feature
+ * \ingroup DataModel
+ * \brief Feature for creation of the new part in PartSet.
+ */
+class SketchPlugin_Feature: public ModelAPI_Feature
+{
+public:
+ SKETCHPLUGIN_EXPORT virtual const TopoDS_Shape& preview() = 0;
+
+protected:
+  void setPreview(const TopoDS_Shape& theShape); ///< the preview shape
+
+private:
+  TopoDS_Shape myPreview; ///< the preview shape
+};
+
+#endif
diff --git a/src/SketchPlugin/SketchPlugin_Plugin.cpp b/src/SketchPlugin/SketchPlugin_Plugin.cpp
new file mode 100644 (file)
index 0000000..56f3b20
--- /dev/null
@@ -0,0 +1,27 @@
+#include "SketchPlugin_Plugin.h"
+#include "SketchPlugin_Sketch.h"
+#include <ModelAPI_PluginManager.h>
+#include <ModelAPI_Document.h>
+
+using namespace std;
+
+// the only created instance of this plugin
+static SketchPlugin_Plugin* MY_INSTANCE = new SketchPlugin_Plugin();
+
+SketchPlugin_Plugin::SketchPlugin_Plugin() 
+{
+  // register this plugin
+  ModelAPI_PluginManager::get()->registerPlugin(this);
+}
+
+shared_ptr<ModelAPI_Feature> SketchPlugin_Plugin::createFeature(string theFeatureID)
+{
+  if (theFeatureID == "Sketch") {
+    return shared_ptr<ModelAPI_Feature>(new SketchPlugin_Sketch);
+  }
+  /*else if (theFeatureID == "Point") {
+    return shared_ptr<ModelAPI_Feature>(new SketchPlugin_Point);
+  }*/
+  // feature of such kind is not found
+  return shared_ptr<ModelAPI_Feature>();
+}
diff --git a/src/SketchPlugin/SketchPlugin_Plugin.h b/src/SketchPlugin/SketchPlugin_Plugin.h
new file mode 100644 (file)
index 0000000..2b26663
--- /dev/null
@@ -0,0 +1,23 @@
+// File:        SketchPlugin_Plugin.hxx
+// Created:     31 Mar 2014
+// Author:      Mikhail PONIKAROV
+
+#ifndef SketchPlugin_Plugin_HeaderFile
+#define SketchPlugin_Plugin_HeaderFile
+
+
+#include "SketchPlugin.h"
+#include "ModelAPI_Plugin.h"
+
+class SKETCHPLUGIN_EXPORT SketchPlugin_Plugin: public ModelAPI_Plugin
+{
+public:
+  /// Creates the feature object of this plugin by the feature string ID
+  virtual std::shared_ptr<ModelAPI_Feature> createFeature(std::string theFeatureID);
+
+public:
+  /// Is needed for python wrapping by swig
+  SketchPlugin_Plugin();
+};
+
+#endif
diff --git a/src/SketchPlugin/SketchPlugin_Sketch.cpp b/src/SketchPlugin/SketchPlugin_Sketch.cpp
new file mode 100644 (file)
index 0000000..a665a70
--- /dev/null
@@ -0,0 +1,60 @@
+// File:        SketchPlugin_Sketch.cxx
+// Created:     27 Mar 2014
+// Author:      Mikhail PONIKAROV
+
+#include "SketchPlugin_Sketch.h"
+#include "ModelAPI_Data.h"
+#include "ModelAPI_AttributeDocRef.h"
+
+using namespace std;
+#include <gp_Pln.hxx>
+#include <gp_Dir.hxx>
+#include <gp_Vec.hxx>
+
+#include <TopoDS.hxx>
+#include <TopoDS_Shape.hxx>
+
+#include <BRep_Tool.hxx>
+#include <BRep_Builder.hxx>
+#include <BRepBuilderAPI_MakeFace.hxx>
+
+const double PLANE_U_MIN = -100;
+const double PLANE_U_MAX = 100;
+const double PLANE_V_MIN = -100;
+const double PLANE_V_MAX = 100;
+
+SketchPlugin_Sketch::SketchPlugin_Sketch()
+{
+}
+
+void SketchPlugin_Sketch::initAttributes()
+{
+  data()->addAttribute(PART_ATTR_DOC_REF, ModelAPI_AttributeDocRef::type());
+}
+
+void SketchPlugin_Sketch::execute() 
+{
+  shared_ptr<ModelAPI_AttributeDocRef> aDocRef = data()->docRef(PART_ATTR_DOC_REF);
+  if (!aDocRef->value()) { // create a document if not yet created
+    shared_ptr<ModelAPI_Document> aPartSetDoc = ModelAPI_PluginManager::get()->rootDocument();
+    aDocRef->setValue(aPartSetDoc->subDocument(data()->getName()));
+  }
+}
+
+shared_ptr<ModelAPI_Document> SketchPlugin_Sketch::documentToAdd() {
+  return ModelAPI_PluginManager::get()->rootDocument();
+}
+
+const TopoDS_Shape& SketchPlugin_Sketch::preview()
+{
+  if (SketchPlugin_Feature::preview().IsNull())
+  {
+    gp_Pnt anOrigin(0, 0, 0);
+    gp_Dir aDir(gp_Vec(gp_Pnt(0,0,0), gp_Pnt(1,0,0)));
+    gp_Pln aPlane(anOrigin, aDir);
+    BRepBuilderAPI_MakeFace aFaceBuilder(aPlane, PLANE_U_MIN, PLANE_U_MAX, PLANE_V_MIN,
+                                         PLANE_V_MAX);
+    setPreview(aFaceBuilder.Face());
+  }
+  return SketchPlugin_Feature::preview();
+}
diff --git a/src/SketchPlugin/SketchPlugin_Sketch.h b/src/SketchPlugin/SketchPlugin_Sketch.h
new file mode 100644 (file)
index 0000000..0ac6ce1
--- /dev/null
@@ -0,0 +1,46 @@
+// File:        SketchPlugin_Sketch.h
+// Created:     27 Mar 2014
+// Author:      Mikhail PONIKAROV
+
+#ifndef SketchPlugin_Sketch_HeaderFile
+#define SketchPlugin_Sketch_HeaderFile
+
+#include "SketchPlugin.h"
+#include <SketchPlugin_Feature.h>
+
+#include <TopoDS_Shape.hxx>
+
+/// part reference attribute
+const std::string PART_ATTR_DOC_REF = "SketchDocument";
+
+/**\class SketchPlugin_Sketch
+ * \ingroup DataModel
+ * \brief Feature for creation of the new part in PartSet.
+ */
+class SketchPlugin_Sketch: public SketchPlugin_Feature
+{
+public:
+  /// Returns the kind of a feature
+ SKETCHPLUGIN_EXPORT virtual const std::string& getKind() 
+  {static std::string MY_KIND = "Sketch"; return MY_KIND;}
+
+  /// Returns to which group in the document must be added feature
+ SKETCHPLUGIN_EXPORT virtual const std::string& getGroup() 
+  {static std::string MY_GROUP = "Sketchs"; return MY_GROUP;}
+
+  /// Creates a new part document if needed
+ SKETCHPLUGIN_EXPORT virtual void execute();
+
+  /// Request for initialization of data model of the feature: adding all attributes
+ SKETCHPLUGIN_EXPORT virtual void initAttributes();
+
+ SKETCHPLUGIN_EXPORT virtual std::shared_ptr<ModelAPI_Document> documentToAdd();
+
+  /// Returns the sketch preview
+  SKETCHPLUGIN_EXPORT virtual const TopoDS_Shape& preview();
+
+  /// Use plugin manager for features creation
+  SketchPlugin_Sketch();
+};
+
+#endif
diff --git a/src/SketchPlugin/plugin-Sketch.xml b/src/SketchPlugin/plugin-Sketch.xml
new file mode 100644 (file)
index 0000000..755458b
--- /dev/null
@@ -0,0 +1,18 @@
+<plugin>
+  <workbench id="Sketch">
+    <group id="Basic">
+      <feature id="Sketch" text="New sketch" tooltip="Create a new sketch or edit an existing sketch" icon=":icons/sketch.png"/>
+    </group>
+    <group id="Operations">
+      <feature id="Point" text="New point" tooltip="Create a new point" icon=":icons/point.png">
+        <doublevalue id="x" label="X:" min="0" max="" step="0.1" default="0"
+               icon=":pictures/x_point.png" tooltip="Set X"/>
+        <doublevalue id="y" label="Y:" min="0" max="" step="0.1" default="1"
+               icon=":pictures/y_point.png" tooltip="Set Y"/>
+        <doublevalue id="z" label="Z:" min="0" max="10" step="0.1" default="2"
+               icon=":pictures/z_point.png" tooltip="Set Z"/>
+      </feature>
+      <feature id="Line" text="New line" tooltip="Create a new line" icon=":icons/line.png"/>
+    </group>
+  </workbench>
+</plugin>
index a10e48e68a257f42fa17832ca4e0aaed9c3ebf64..30949838013fffa5d394850023ac14e976158a47 100644 (file)
@@ -5,6 +5,7 @@ SET(CMAKE_AUTOMOC ON)
 SET(PROJECT_HEADERS
        XGUI.h
        XGUI_Command.h
+       XGUI_Displayer.h
        XGUI_MainMenu.h
        XGUI_MainWindow.h
        XGUI_MenuGroupPanel.h
@@ -32,6 +33,7 @@ SET(PROJECT_AUTOMOC
 
 SET(PROJECT_SOURCES
        XGUI_Command.cpp
+       XGUI_Displayer.cpp
        XGUI_MainMenu.cpp
        XGUI_MainWindow.cpp
        XGUI_MenuGroupPanel.cpp
diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp
new file mode 100644 (file)
index 0000000..1df3291
--- /dev/null
@@ -0,0 +1,47 @@
+#include "XGUI_Displayer.h"
+#include "XGUI_Tools.h"
+#include "XGUI_Viewer.h"
+
+#include <ModelAPI_Document.h>
+
+#include <AIS_InteractiveContext.hxx>
+#include <AIS_Shape.hxx>
+
+/*!
+ \brief Constructor
+ */
+XGUI_Displayer::XGUI_Displayer(XGUI_Viewer* theViewer)
+: myViewer(theViewer)
+{
+}
+
+/*!
+ \brief Destructor
+ */
+XGUI_Displayer::~XGUI_Displayer()
+{
+}
+
+/*!
+ * Display the feature
+ * \param theFeature a feature instance
+ */
+void XGUI_Displayer::Display(std::shared_ptr<ModelAPI_Feature> theFeature)
+{
+}
+
+/*!
+ * Display the feature and a shape. This shape would be associated to the given feature
+ * \param theFeature a feature instance
+ * \param theFeature a shape
+ */
+void XGUI_Displayer::Display(std::shared_ptr<ModelAPI_Feature> theFeature,
+                             const TopoDS_Shape& theShape)
+{
+  Handle(AIS_InteractiveContext) aContext = myViewer->AISContext();
+
+  Handle(AIS_Shape) anAIS = new AIS_Shape(theShape);
+  aContext->Display(anAIS, Standard_False);
+
+  aContext->UpdateCurrentViewer();
+}
diff --git a/src/XGUI/XGUI_Displayer.h b/src/XGUI/XGUI_Displayer.h
new file mode 100644 (file)
index 0000000..cf5dbbb
--- /dev/null
@@ -0,0 +1,31 @@
+#ifndef XGUI_Displayer_H
+#define XGUI_Displayer_H
+
+#include "XGUI.h"
+
+#include <QString>
+
+#include <TopoDS_Shape.hxx>
+
+class XGUI_Viewer;
+class ModelAPI_Feature;
+
+/**\class XGUI_Displayer
+ * \ingroup GUI
+ * \brief Displayer. Provides mechanizm of displa/erase of objects in viewer
+ */
+class XGUI_EXPORT XGUI_Displayer
+{
+public:
+  XGUI_Displayer(XGUI_Viewer* theViewer);
+  virtual ~XGUI_Displayer();
+
+  void Display(std::shared_ptr<ModelAPI_Feature> theFeature);
+
+  void Display(std::shared_ptr<ModelAPI_Feature> theFeature, const TopoDS_Shape& theShape);
+
+protected:
+  XGUI_Viewer* myViewer; ///< the viewer
+};
+
+#endif
index b02a735eb3a1142623736cc3d7ec43a1f4f34bef..6d4c100681cd3677f60761ca556c521ef5172601 100644 (file)
@@ -18,6 +18,9 @@
 #include <Prs3d_LineAspect.hxx>
 #include <V3d_View.hxx>
 #include <Visual3d_View.hxx>
+#include <AIS_ListOfInteractive.hxx>
+
+#include <QMouseEvent>
 
 #ifdef WIN32
 #include <WNT_Window.hxx>
@@ -389,7 +392,7 @@ void XGUI_Viewer::addView(QMdiSubWindow* theView)
             this,    SIGNAL(tryCloseView(XGUI_ViewWindow*)));
 
     connect(aWindow, SIGNAL(mousePressed(XGUI_ViewWindow*, QMouseEvent*)),
-            this,    SIGNAL(mousePress(XGUI_ViewWindow*, QMouseEvent*)));
+            this,    SLOT(onMousePressed(XGUI_ViewWindow*, QMouseEvent*)));
 
     connect(aWindow, SIGNAL(mouseReleased(XGUI_ViewWindow*, QMouseEvent*)),
             this,    SIGNAL(mouseRelease(XGUI_ViewWindow*, QMouseEvent*)));
@@ -409,6 +412,12 @@ void XGUI_Viewer::addView(QMdiSubWindow* theView)
 //    connect(aWindow, SIGNAL(contextMenuRequested( QContextMenuEvent* )),
 //            this,    SLOT  (onContextMenuRequested( QContextMenuEvent* )));
 
+    connect(aWindow, SIGNAL(mouseMoving(XGUI_ViewWindow*, QMouseEvent*)),
+            this, SLOT(onMouseMove(XGUI_ViewWindow*, QMouseEvent*)));
+
+    connect(aWindow, SIGNAL(mouseReleased(XGUI_ViewWindow*, QMouseEvent*)),
+            this, SLOT(onMouseReleased(XGUI_ViewWindow*, QMouseEvent*)));
+
     myViews.append(theView);
 }
 
@@ -444,3 +453,25 @@ void XGUI_Viewer::onWindowMinimized(QMdiSubWindow* theWnd)
     }
   }
 }
+
+/*!
+  SLOT: called on mouse move, processes hilighting
+*/
+void XGUI_Viewer::onMouseMove(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent)
+{
+  XGUI_ViewPort* aViewPort = theWindow->viewPort();
+  Handle(V3d_View) aView3d = aViewPort->getView();
+
+  if ( !aView3d.IsNull() )
+    myAISContext->MoveTo(theEvent->x(), theEvent->y(), aView3d);
+}
+
+/*!
+  SLOT: called on mouse button release, finishes selection
+*/
+void XGUI_Viewer::onMouseReleased(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent)
+{
+  myAISContext->Select();
+
+  emit selectionChanged();
+}
index b68f9accbbf1619f4c793dd57d4cd3f3865df304..5b68ebdf0b9a47e516d0ea7d28973311a6f9742d 100644 (file)
@@ -110,6 +110,7 @@ signals:
   void keyPress(XGUI_ViewWindow* theWindow, QKeyEvent* theEvent);
   void keyRelease(XGUI_ViewWindow* theWindow, QKeyEvent* theEvent);
   void activated(XGUI_ViewWindow* theWindow);
+  void selectionChanged();
 
 public slots:
   void onWindowMinimized(QMdiSubWindow*);
@@ -117,6 +118,8 @@ public slots:
 
 private slots:
   void onViewClosed(QMdiSubWindow*);
+  void onMouseMove(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
+  void onMouseReleased(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
 
 private:
   void addView(QMdiSubWindow* theView);
index 48e3770cebdaee086a8120b7bc0115ab57301509..8911720284c17af1ebf0042e9dfaff2c9616d893 100644 (file)
@@ -11,6 +11,7 @@
 #include "XGUI_WidgetFactory.h"
 #include "XGUI_SelectionMgr.h"
 #include "XGUI_ObjectsBrowser.h"
+#include "XGUI_Displayer.h"
 
 #include <ModelAPI_PluginManager.h>
 #include <ModelAPI_Feature.h>
@@ -19,6 +20,7 @@
 
 #include <Event_Loop.h>
 #include <ModuleBase_PropPanelOperation.h>
+#include <ModuleBase_Operation.h>
 #include <Config_FeatureMessage.h>
 #include <Config_PointerMessage.h>
 
@@ -46,6 +48,7 @@ XGUI_Workshop::XGUI_Workshop()
 {
   myMainWindow = new XGUI_MainWindow();
   mySelector = new XGUI_SelectionMgr(this);
+  myDisplayer = new XGUI_Displayer(myMainWindow->viewer());
 }
 
 //******************************************************
index aff5c239bc90755867f18e9446a52f92d02e83b6..50e0a44cc0759dc0702f330cc29d552712a5c36c 100644 (file)
@@ -14,6 +14,7 @@ class XGUI_Command;
 class XGUI_Module;
 class XGUI_Workbench;
 class XGUI_SelectionMgr;
+class XGUI_Displayer;
 class ModuleBase_Operation;
 class ModuleBase_PropPanelOperation;
 
@@ -44,9 +45,15 @@ public:
   //! Returns selection manager object
   XGUI_SelectionMgr* selector() const { return mySelector; }
 
+  //! Returns displayer
+  XGUI_Displayer* displayer() const { return myDisplayer; }
+
   //! Creates and adds a new workbench (menu group) with the given name and returns it
   XGUI_Workbench* addWorkbench(const QString& theName);
 
+  //! Returns the current operation or NULL
+  ModuleBase_Operation* currentOperation() { return myCurrentOperation; }
+
   //! Redefinition of Event_Listener method
   virtual void processEvent(const Event_Message* theMessage);
 
@@ -78,6 +85,7 @@ private:
   XGUI_Module* myPartSetModule;
 
   XGUI_SelectionMgr* mySelector;
+  XGUI_Displayer* myDisplayer;
 
   ModuleBase_Operation* myCurrentOperation;
 };