Salome HOME
Merge branch 'BR_coding_rules'
authorazv <azv@opencascade.com>
Thu, 1 Dec 2016 07:12:00 +0000 (10:12 +0300)
committerazv <azv@opencascade.com>
Thu, 1 Dec 2016 07:12:00 +0000 (10:12 +0300)
src/ModelAPI/ModelAPI_ResultBody.h
src/ModelAPI/ModelAPI_ResultConstruction.h
src/ModuleBase/ModuleBase_WidgetConcealedObjects.cpp
src/ModuleBase/ModuleBase_WidgetConcealedObjects.h
src/PartSet/PartSet_CustomPrs.h
src/PartSet/PartSet_Tools.cpp
src/PartSet/PartSet_Tools.h
src/SHAPERGUI/SHAPERGUI.cpp
src/SHAPERGUI/SHAPERGUI.h
src/XGUI/XGUI_Workshop.cpp

index 959259934aa286c0424db13db1969b1f976d8c2a..8b90e4427440c2796840b274da23063ec6c07f97 100644 (file)
@@ -47,7 +47,7 @@ public:
   /// default deflection for a result body
   inline static const std::string DEFAULT_DEFLECTION()
   {
-    return "0.001";
+    return "0.0001";
   }
 
   /// Iternal enumeration for storage the information of connected topology flag
index 4704bc43bd9af48f2dd9a100870645831aa2a7fa..b132572b8d063e77a81bbaad2f037b06c8dbc697 100644 (file)
@@ -43,7 +43,7 @@ class ModelAPI_ResultConstruction : public ModelAPI_Result
   /// default deflection for a result construction
   inline static const std::string DEFAULT_DEFLECTION()
   {
-    return "0.0001";
+    return "0.00001";
   }
 
   /// Sets the result
index 9da48c21c141f4859b9706191fbe44754bd1adf3..1b14529e43d96882fb47f4e02dba508e4b43d8bd 100644 (file)
@@ -21,7 +21,8 @@
 #include <QWidget>
 #include <QTableWidget>
 #include <QHeaderView>
-#include <QToolButton>
+#include <QCheckBox>
+#include <QVBoxLayout>
 
 const int DEFAULT_NAME_COLUMN_WIDTH = 200;
 
@@ -54,7 +55,7 @@ bool ModuleBase_WidgetConcealedObjects::storeValueCustom()
   anAttributeList->clear();
   int aSize1 = anAttributeList->size(false);
   for (int i = 0, aSize = myView->rowCount(); i < aSize; i++) {
-    QToolButton* aButton = dynamic_cast<QToolButton*>(myView->cellWidget(i, 0));;
+    QCheckBox* aButton = dynamic_cast<QCheckBox*>(myView->cellWidget(i, 0)->findChild<QCheckBox*>());
     if (aButton->isChecked())
       anAttributeList->append(myConcealedResults[i]);
   }
@@ -95,12 +96,11 @@ bool ModuleBase_WidgetConcealedObjects::restoreValueCustom()
   int aSize = anAttributeList->size();
   for (int i = 0, aSize = myView->rowCount(); i < aSize; i++) {
     ResultPtr aResult = myConcealedResults[i];
-    QToolButton* aButton = dynamic_cast<QToolButton*>(myView->cellWidget(i, 0));
+    QCheckBox* aButton = dynamic_cast<QCheckBox*>(myView->cellWidget(i, 0)->findChild<QCheckBox*>());
     bool isChecked = anAttributeList->isInList(aResult);
 
     bool aBlocked = aButton->blockSignals(true);
     aButton->setChecked(isChecked);
-    this->updateItemIcon(aButton);
     aButton->blockSignals(aBlocked);
   }
   return true;
@@ -119,13 +119,15 @@ void ModuleBase_WidgetConcealedObjects::addViewRow(
   int anId = myView->rowCount();
   myView->setRowCount(anId+1);
 
-  QToolButton* aVisibilityBtn = new QToolButton(this);
+  QWidget* aVisibilityWdg = new QWidget(this);
+  QVBoxLayout* aVisibilityLay = new QVBoxLayout(aVisibilityWdg);
+  aVisibilityLay->setContentsMargins(2, 2, 2, 2);
+  QCheckBox* aVisibilityBtn = new QCheckBox(aVisibilityWdg);
+  aVisibilityLay->addWidget(aVisibilityBtn, 0, Qt::AlignHCenter);
   connect(aVisibilityBtn, SIGNAL(toggled(bool)), this, SLOT(onItemToggled(bool)));
-  aVisibilityBtn->setCheckable(true);
   aVisibilityBtn->setChecked(false);
-  updateItemIcon(aVisibilityBtn);
 
-  myView->setCellWidget(anId, 0, aVisibilityBtn);
+  myView->setCellWidget(anId, 0, aVisibilityWdg);
   myView->setItem(anId, 1, new QTableWidgetItem(theResult->data()->name().c_str()));
 
   if (anId == 1) {
@@ -140,10 +142,3 @@ void ModuleBase_WidgetConcealedObjects::onItemToggled(bool theState)
   updateObject(myFeature);
 }
 
-void ModuleBase_WidgetConcealedObjects::updateItemIcon(QToolButton* theButton)
-{
-  bool isChecked = theButton->isChecked();
-  theButton->setIcon(isChecked ? QIcon(":icons/concealed_on.png")
-                               : QIcon(":icons/concealed_off.png"));
-  theButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
-}
index 9cd8f092afa17768c1c596f1fcb8065e3ef4f805..b289d7a87d5dcfbffba0e5ffbefee39db9d17a66 100644 (file)
@@ -18,7 +18,6 @@ class ModelAPI_Object;
 
 class QWidget;
 class QTableWidget;
-class QToolButton;
 
 /**
 * \ingroup GUI
@@ -59,11 +58,6 @@ private slots:
   /// \param theState a new state
   void onItemToggled(bool theState);
 
-private:
-  /// Updates icon of button
-  /// \param theButton a button of the table
-  void updateItemIcon(QToolButton* theButton);
-
 private:
   std::string myBaseShapeAttribute; ///< attribute of the base object
   QTableWidget* myView; ///< table view of visibility states
index ac99ab16709ae8c905fc1ccd38505fd3ea048115..f64ed35cd6c953458fe4f92c7a2491acf5bb9218 100755 (executable)
@@ -37,8 +37,7 @@ public:
   /// Returns green color
   static const std::string OPERATION_RESULT_COLOR() { return "0,225, 0"; }
   /// Returns color between white and color of highlight
-  /// highlight color is equal Quantity_Color(0.5,1,1) or QColor(122, 255,255) // 188
-  static const std::string OPERATION_HIGHLIGHT_COLOR() { return "188, 255, 255"; }
+  static const std::string OPERATION_HIGHLIGHT_COLOR() { return "128, 0, 0"; }
 
 public:
   /// Constructor
index ba73f12ae2df9f831e27b4942a1e68c0c04d45ec..53c1dc13fb77177cb87957788ac0ccc43d9e9bf1 100755 (executable)
@@ -563,6 +563,16 @@ ResultPtr PartSet_Tools::createFixedObjectByExternal(const TopoDS_Shape& theShap
         (aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID()));
 
       ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+      /// check external line created on Trihedron Axis
+      /// selection of a point on external edge referenced to AIS_Trihedron axis
+      /// should be prohibited or point should be replaced to "Origin". The second
+      /// case is implemented because of not correct AIS_Trihedron origin point highlight
+      /// When AIS is corrected(exactly priority of origin and stayed vertex by highlight)
+      /// the next check should be moved to Partset 2d point widget in isValidSelectionCustom
+      bool isAxis = isAxisSelected(theObject);
+      if (isAxis)
+        aRes = ResultPtr(); // to rely on code below that found the Origin result
+
       // if there is no object,
       // it means that this is the origin point: search it in the module document
       if (!aRes.get()) {
@@ -618,6 +628,29 @@ ResultPtr PartSet_Tools::createFixedObjectByExternal(const TopoDS_Shape& theShap
   return ResultPtr();
 }
 
+bool PartSet_Tools::isAxisSelected(const ObjectPtr& theObject)
+{
+  bool isAxis = false;
+  ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+  if (aRes.get()) {
+    // check if result belongs to external feature
+    // in this case we should use as a result reference of external feature
+    FeaturePtr aResFeature = ModelAPI_Feature::feature(aRes);
+    std::shared_ptr<SketchPlugin_Feature> aSPFeature =
+                  std::dynamic_pointer_cast<SketchPlugin_Feature>(aResFeature);
+    if (aSPFeature.get() && aSPFeature->isExternal()) {
+      AttributeSelectionPtr aAttr = aResFeature->selection(
+                                    SketchPlugin_SketchEntity::EXTERNAL_ID());
+      if (aAttr) { /// check if the result is Axis
+        ResultPtr anExternalRes = std::dynamic_pointer_cast<ModelAPI_Result>(aAttr->context());
+        FeaturePtr aResFeature = ModelAPI_Feature::feature(anExternalRes);
+        isAxis = aResFeature->getKind() == "Axis"; //ConstructionPlugin_Axis::ID()
+      }
+    }
+  }
+  return isAxis;
+}
+
 bool PartSet_Tools::isContainPresentation(const QList<ModuleBase_ViewerPrsPtr>& theSelected,
                                           const ModuleBase_ViewerPrsPtr& thePrs)
 {
index 7826014e1f44a48caba6558711459f22b76a5a08..10699dd2743e399489a9efc994ba722acf1d0406 100755 (executable)
@@ -180,7 +180,14 @@ public:
                                                CompositeFeaturePtr theSketch,
                                                const bool theTemporary = false);
 
-  /// Checks whether the list of selected presentations contains the given one
+
+  /// Checks if the shape is Origin, the conditions are the shape is a vertex and
+  /// selected feature is an external feature created on Axis
+  /// \param theObject a selected object in the viewer
+  /// \return boolean value
+  static bool isAxisSelected(const ObjectPtr& theObject);
+
+    /// Checks whether the list of selected presentations contains the given one
   /// \param theSelected a list of presentations
   /// \param thePrs a presentation to be found
   /// \return - result of check, true if the list contains the prs
index c670b01840f1e52f5612b8a0fb710d04ac2c7d13..ed44c1d91bd19973a65bc191d25ba14c1ca0df4e 100644 (file)
@@ -29,6 +29,7 @@
 #include <SUIT_Desktop.h>
 #include <SUIT_ViewManager.h>
 #include <SUIT_ResourceMgr.h>
+#include <SUIT_DataBrowser.h>
 
 #include <QtxPopupMgr.h>
 #include <QtxActionMenuMgr.h>
@@ -247,6 +248,10 @@ bool SHAPERGUI::activateModule(SUIT_Study* theStudy)
     Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
   }
   myProxyViewer->activateViewer(true);
+
+  // Postrrocessing for LoadScriptId to remove created(if it was created) SALOME Object Browser\r
+  connect(getApp()->action(LightApp_Application::UserID+1), SIGNAL(triggered(bool)),\r
+          this, SLOT(onScriptLoaded()));\r
   return isDone;
 }
 
@@ -291,6 +296,10 @@ bool SHAPERGUI::deactivateModule(SUIT_Study* theStudy)
   aResMgr->setValue("Study", "store_positions", myIsStorePositions);
   getApp()->setEditEnabled(myIsEditEnabled);
 
+  // Postrrocessing for LoadScriptId to remove created(if it was created) SALOME Object Browser\r
+  disconnect(getApp()->action(LightApp_Application::UserID+1), SIGNAL(triggered(bool)),\r
+             this, SLOT(onScriptLoaded()));\r
+
   return LightApp_Module::deactivateModule(theStudy);
 }
 
@@ -345,6 +354,19 @@ void SHAPERGUI::onDefaultPreferences()
   myWorkshop->displayer()->redisplayObjects();
 }
 
+//******************************************************
+void SHAPERGUI::onScriptLoaded()
+{
+  // this slot is called after processing of the LoadScriptId action of SalomeApp Application
+  // Each dumped script contains updateObjBrowser() that creates a new instance of Object
+  // Browser. When SHAPER module is active, this browser should not be used. It might be removed
+  // as hidden by means of updateWindows() of SalomeApp_Application or to remove
+  // it manually (because this method of application is protected)
+  SUIT_DataBrowser* aBrowser = getApp()->objectBrowser();
+  if (aBrowser)
+    delete aBrowser;
+}
+
 //******************************************************
 void SHAPERGUI::onUpdateCommandStatus()
 {
index c9c9f91fafc82a4731853b10fc20f676412eab5d..b940d8a1921d643001afbe27fb5efd68181c2fc5 100644 (file)
@@ -165,6 +165,9 @@ Q_OBJECT
   /// Set preferences to default
   void onDefaultPreferences();
 
+  /// Hide object browser if it was created during loading script
+  void onScriptLoaded();
+
   /// Obtains the current application and updates its actions
   void onUpdateCommandStatus();
 
index f569608b99fc1fb527bdc102603055bdb6707681..6996a2d02e4d2ad9864e0b120190fc88dbe695bd 100755 (executable)
@@ -213,12 +213,12 @@ XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
   Config_PropManager::registerProp("Visualization", "body_deflection",
                                    "Body deflection coefficient",
                                    Config_Prop::Double,
-                                   ModelAPI_ResultBody::DEFAULT_DEFLECTION());//"0.001");
+                                   ModelAPI_ResultBody::DEFAULT_DEFLECTION());
 
   Config_PropManager::registerProp("Visualization", "construction_deflection",
                                    "Construction deflection coefficient",
                                    Config_Prop::Double,
-                                   ModelAPI_ResultConstruction::DEFAULT_DEFLECTION());//"0.0001");
+                                   ModelAPI_ResultConstruction::DEFAULT_DEFLECTION());
 
   if (ModuleBase_Preferences::resourceMgr()->booleanValue("Viewer", "face-selection", true))
     myViewerSelMode.append(TopAbs_FACE);