]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
refs #30 - Sketch base GUI: create, draw lines
authornds <natalia.donis@opencascade.com>
Thu, 24 Apr 2014 14:37:12 +0000 (18:37 +0400)
committernds <natalia.donis@opencascade.com>
Thu, 24 Apr 2014 14:37:12 +0000 (18:37 +0400)
Set plane for sketch and erase the sketch preview. Set view projection.

src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_OperationSketch.cpp
src/PartSet/PartSet_OperationSketchBase.h
src/XGUI/XGUI_Viewer.cpp
src/XGUI/XGUI_Viewer.h

index f1787442a8740740b86d669d48e7133e183fcbfc..71d0987a4bbebcec134cea5127758d8e868af099 100644 (file)
@@ -98,8 +98,11 @@ void PartSet_Module::onOperationStarted()
   ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
 
   PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
-  if (aPreviewOp)
+  if (aPreviewOp) {
     visualizePreview(true);
+    connect(aPreviewOp, SIGNAL(viewerProjectionChange(double, double, double)),
+            this, SLOT(onViewerProjectionChange(double, double, double)));
+  }
 }
 
 void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation)
@@ -126,6 +129,14 @@ void PartSet_Module::onViewSelectionChanged()
   }
 }
 
+void PartSet_Module::onViewerProjectionChange(double theX, double theY, double theZ)
+{
+  XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
+  if (aViewer) {
+    aViewer->setViewProjection(theX, theY, theZ);
+  }
+}
+
 void PartSet_Module::visualizePreview(bool isDisplay)
 {
   ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
index fcf98a0c32920465955216376030dec8541d88cd..c7d8e8d3b8a476bdb383257b68c3674ac41cf4d8 100644 (file)
@@ -34,6 +34,11 @@ public slots:
   /// SLOT, that is called by the selection in the viewer is changed.
   /// The selection is sent to the current operation if it listen the selection.
   void onViewSelectionChanged();
+  /// SLOT, to apply to the current viewer the operation
+  /// \param theX the X projection value
+  /// \param theY the Y projection value
+  /// \param theZ the Z projection value
+  void onViewerProjectionChange(double theX, double theY, double theZ);
 
 private:
   /// Displays or erase the current operation preview, if it has it.
index 1f1f1e91c868e922ad5955e49cc21f5878c3c6f7..8ce3b79589b82be90cfce5d7b7d2a8e33423ea04 100644 (file)
@@ -63,7 +63,8 @@ void PartSet_OperationSketch::setSelectedShapes(const NCollection_List<TopoDS_Sh
   aData->real(SKETCH_ATTR_PLANE_C)->setValue(aC);
   aData->real(SKETCH_ATTR_PLANE_D)->setValue(aD);
 
-  //emit viewPlaneChanged();
+  boost::shared_ptr<GeomAPI_Dir> aDir = aPlane->direction();
+  emit viewerProjectionChange(aDir->x(), aDir->y(), aDir->z());
 
   commit();
 }
index 72a635bb1c986ac5e701a0cba26decfedd0dd0d8..7ca7fd2d3ac30aa4a1cfaf37ad690c4fe6cdcb99 100644 (file)
@@ -39,6 +39,9 @@ public:
   /// Gives the current selected objects to be processed by the operation
   /// \param a list of interactive selected objects
   virtual void setSelectedShapes(const NCollection_List<TopoDS_Shape>& theList) = 0;
+
+signals:
+  void viewerProjectionChange(double theX, double theY, double theZ);
 };
 
 #endif
index a09722bcdf66885aa8cb4f9a84f3d7a071457e32..dd50e3e116e31c208803ecbcec655d9eb186c144 100644 (file)
@@ -283,6 +283,17 @@ void XGUI_Viewer::getHotButton(XGUI::InteractionStyle theInteractionStyle,
   theButton = myButtonMap[theInteractionStyle][theOper];
 }
 
+void XGUI_Viewer::setViewProjection(double theX, double theY, double theZ)
+{
+  XGUI_ViewWindow* aWindow = dynamic_cast<XGUI_ViewWindow*>(myActiveView->widget());
+  if (aWindow) {
+    Handle(V3d_View) aView3d = aWindow->viewPort()->getView();
+    if ( !aView3d.IsNull() ) 
+      aView3d->SetProj(theX, theY, theZ);
+    aWindow->viewPort()->fitAll();
+  }
+}
+
 /*!
  Changes visibility of trihedron to opposite
  */
index c7a2492f1fda250990112f6ca7ab1f198113c146..27df6840da36199369f2c72a6413650742bf5483 100644 (file)
@@ -119,6 +119,12 @@ public:
   static void getHotButton(XGUI::InteractionStyle theInteractionStyle, XGUI::HotOperation theOper,
                            Qt::KeyboardModifiers& theState, Qt::MouseButtons& theButton);
 
+  //! Sets the view projection
+  /// \param theX the X projection value
+  /// \param theY the Y projection value
+  /// \param theZ the Z projection value
+  void setViewProjection(double theX, double theY, double theZ);
+
   typedef QMap<XGUI::HotOperation, Qt::KeyboardModifiers> StatesMap;
   typedef QMap<XGUI::HotOperation, Qt::MouseButtons> ButtonsMap;