]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'master' of newgeom:newgeom
authorvsv <vitaly.smetannikov@opencascade.com>
Mon, 2 Jun 2014 07:54:09 +0000 (11:54 +0400)
committervsv <vitaly.smetannikov@opencascade.com>
Mon, 2 Jun 2014 07:54:09 +0000 (11:54 +0400)
12 files changed:
src/ModuleBase/ModuleBase_ModelWidget.h
src/ModuleBase/ModuleBase_WidgetPoint2D.cpp
src/ModuleBase/ModuleBase_WidgetPoint2D.h
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_OperationSketch.cpp
src/PartSet/PartSet_OperationSketch.h
src/PartSet/PartSet_OperationSketchLine.cpp
src/XGUI/XGUI_PropertyPanel.cpp
src/XGUI/XGUI_SalomeViewer.h
src/XGUI/XGUI_ViewerProxy.cpp
src/XGUI/XGUI_ViewerProxy.h

index 57b75346aec15b629d8ff5d2401e43652285fdc3..afdc1f2cafccbf317b6faa7d3e3fe28696d3da64 100644 (file)
@@ -38,9 +38,12 @@ public:
 
   virtual bool restoreValue(boost::shared_ptr<ModelAPI_Feature> theFeature) = 0;
 
-  /// Set focus to the current widget if it corresponds to the given attribute
+  /// Returns whether the widget can accept focus, or if it corresponds to the given attribute
   /// \param theAttribute name
-  virtual bool focusTo(const std::string& theAttributeName) = 0;
+  virtual bool canFocusTo(const std::string& theAttributeName) = 0;
+
+  /// Set focus to the current widget if it corresponds to the given attribute
+  virtual void focusTo() = 0;
 
   /// Returns list of widget controls
   /// \return a control list
index 0f397b1017bf3f2eb55cb24a2383c947962d8c78..cbc61430a743a286c9278a46b33573c28364ed7c 100644 (file)
@@ -95,16 +95,15 @@ bool ModuleBase_WidgetPoint2D::restoreValue(boost::shared_ptr<ModelAPI_Feature>
   return true;
 }
 
-bool ModuleBase_WidgetPoint2D::focusTo(const std::string& theAttributeName)
+bool ModuleBase_WidgetPoint2D::canFocusTo(const std::string& theAttributeName)
 {
-  if (theAttributeName != myFeatureAttributeID)
-    return false;
+  return theAttributeName == myFeatureAttributeID;
+}
 
-  if (!myXSpin->hasFocus() && !myYSpin->hasFocus()) {
+void ModuleBase_WidgetPoint2D::focusTo()
+{
+  if (!myXSpin->hasFocus() && !myYSpin->hasFocus())
     myXSpin->setFocus();
-  }
-
-  return true;
 }
 
 QWidget* ModuleBase_WidgetPoint2D::getControl() const
index 016b17217c0e0901640cc1293cc6c5c6440858c9..1a09516b00c30e50635cca03db926459f5233120 100644 (file)
@@ -38,9 +38,12 @@ public:
 
   virtual bool restoreValue(boost::shared_ptr<ModelAPI_Feature> theFeature);
 
-  /// Set focus to the current widget if it corresponds to the given attribute
+  /// Returns whether the widget can accept focus, or if it corresponds to the given attribute
   /// \param theAttribute name
-  virtual bool focusTo(const std::string& theAttributeName);
+  virtual bool canFocusTo(const std::string& theAttributeName);
+
+  /// Set focus to the current widget if it corresponds to the given attribute
+  virtual void focusTo();
 
   /// Returns the internal parent wiget control, that can be shown anywhere
   /// \returns the widget
index 3d93034020fd5ae115d03761f5ee5d1f0174a6c2..99cab29e5c2a2be1f1c3660db3f475f92ec16c61 100644 (file)
@@ -213,6 +213,11 @@ void PartSet_Module::onPlaneSelected(double theX, double theY, double theZ)
   //PartSet_TestOCC::testSelection(myWorkshop);
 }
 
+void PartSet_Module::onFitAllView()
+{
+  myWorkshop->viewer()->fitAll();
+}
+
 void PartSet_Module::onLaunchOperation(std::string theName, boost::shared_ptr<ModelAPI_Feature> theFeature)
 {
   ModuleBase_Operation* anOperation = createOperation(theName.c_str());
@@ -355,6 +360,8 @@ ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdI
     if (aSketchOp) {
       connect(aSketchOp, SIGNAL(planeSelected(double, double, double)),
               this, SLOT(onPlaneSelected(double, double, double)));
+      connect(aSketchOp, SIGNAL(fitAllView()),
+              this, SLOT(onFitAllView()));
     }
   }
 
index bf571a32332a294f68bd532a7a6d627bfb16fd7a..d92604bbb89410135ec12244364edb5464ac4779 100644 (file)
@@ -89,6 +89,9 @@ public slots:
   /// \param theZ the Z projection value
   void onPlaneSelected(double theX, double theY, double theZ);
 
+  /// SLOT, to fit all current viewer
+  void onFitAllView();
+
   void onLaunchOperation(std::string theName, boost::shared_ptr<ModelAPI_Feature> theFeature);
 
   /// SLOT, to switch on/off the multi selection in the viewer
index 3270705d61af4f68d75d8ad4c06526a29c76bc0a..7deb0ef54c44d670e467ac214ba58afb10d74a8a 100644 (file)
@@ -144,8 +144,10 @@ bool PartSet_OperationSketch::isNestedOperationsEnabled() const
 
 void PartSet_OperationSketch::startOperation()
 {
-  if (!feature())
+  if (!feature()) {
     setFeature(createFeature());
+    emit fitAllView();
+  }
 }
 
 bool PartSet_OperationSketch::hasSketchPlane() const
index d40a55331a198a5fdccbb4fdb9cbc8a22872ffda..9c76414e9f7b5ce2b9cce0c008afe8d3b12cbeac 100644 (file)
@@ -79,6 +79,8 @@ signals:
   /// \param theX the value in the Y direction value of the plane
   /// \param theX the value in the Z direction of the plane
   void planeSelected(double theX, double theY, double theZ);
+  // signal about the viewer fit all perform
+  void fitAllView();
 
 protected:
   /// Virtual method called when operation started (see start() method for more description)
index 4ca7d3200991b2acfa7782b722b84f3e8e15cce5..1a1cdbc0ea420b3442860cd9a40f1b9c8c520415 100644 (file)
@@ -209,7 +209,8 @@ void PartSet_OperationSketchLine::mouseMoved(QMouseEvent* theEvent, Handle(V3d_V
 void PartSet_OperationSketchLine::keyReleased(std::string theName, QKeyEvent* theEvent)
 {
   int aKeyType = theEvent->key();
-  if (!theName.empty() && aKeyType == Qt::Key_Return) {
+  // the second point should be activated by any modification in the property panel
+  if (!theName.empty() /*&& aKeyType == Qt::Key_Return*/) {
     if (theName == LINE_ATTR_START) {
       setPointSelectionMode(SM_SecondPoint, false);
     }
index f9328b5e16a276f6dadf83b2fb377251d3cc07b2..f511a5750a38d3b40f86638087076ae0b16b645d 100644 (file)
@@ -73,7 +73,6 @@ void XGUI_PropertyPanel::setModelWidgets(const QList<ModuleBase_ModelWidget*>& t
   myWidgets = theWidgets;
 
   if (!theWidgets.empty()) {
-
     QList<ModuleBase_ModelWidget*>::const_iterator anIt = theWidgets.begin(), aLast = theWidgets.end();
     for (; anIt != aLast; anIt++) {
       connect(*anIt, SIGNAL(keyReleased(const std::string&, QKeyEvent*)),
@@ -92,6 +91,9 @@ void XGUI_PropertyPanel::setModelWidgets(const QList<ModuleBase_ModelWidget*>& t
         setTabOrder(anOkBtn, aCancelBtn);
       }
     }
+    ModuleBase_ModelWidget* aWidget = theWidgets.first();
+    if (aWidget)
+      aWidget->focusTo();
   }
 }
 
@@ -138,8 +140,10 @@ void XGUI_PropertyPanel::onFocusActivated(const std::string& theAttributeName)
   }
   else {
     foreach(ModuleBase_ModelWidget* eachWidget, myWidgets) {
-      if (eachWidget->focusTo(theAttributeName))
+      if (eachWidget->canFocusTo(theAttributeName)) {
+        eachWidget->focusTo();
         break;
+      }
     }
   }
 }
index a1e5054bd81c88a1345e8d37be87cbe2282d2695..b00d5aea391c940138b1320dbfb5f5d8d7411d48 100644 (file)
@@ -41,6 +41,9 @@ public:
   //! Returns true if multiselection is enabled
   virtual bool isMultiSelectionEnabled() const = 0;
 
+  //! Perfroms the fit all for the active view
+  virtual void fitAll() = 0;
+
 signals:
   void lastViewClosed();
   void tryCloseView();
index e07c3693e75ca6e91446ddefc12c7d9d2b16b020..c3ae206ca44440ac40effb8a549a385d323f08cd 100644 (file)
@@ -51,6 +51,16 @@ void XGUI_ViewerProxy::setViewProjection(double theX, double theY, double theZ)
   }
 }
 
+void XGUI_ViewerProxy::fitAll()
+{
+  if (myWorkshop->isSalomeMode()) {
+    myWorkshop->salomeConnector()->viewer()->fitAll();
+  }
+  else {
+    XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
+    aViewer->activeViewWindow()->viewPort()->fitAll();
+  }
+}
 
 void XGUI_ViewerProxy::connectToViewer()
 {
index 2d2864dd4f9a7cafd85d8687f25eca655852a23c..1f7f63344662da2dfef8de75ebc948c303a4e4fc 100644 (file)
@@ -46,6 +46,9 @@ public:
   /// \param theZ the Z projection value
   void setViewProjection(double theX, double theY, double theZ);
 
+  //! Sets the view fitted all
+  void fitAll();
+
   /// Connects to a viewer according to current environment
   void connectToViewer();