Salome HOME
Issue #1343. Improvement of Extrusion and Revolution operations: filling extrusion...
[modules/shaper.git] / src / XGUI / XGUI_Workshop.h
index 5aa9e7802f64b58ae1de8f4a26e866e5f887b688..37685b16975e972402f10fd5ed111b13e3157fe2 100755 (executable)
@@ -47,6 +47,7 @@ class QMainWindow;
 
 class QAction;
 
+
 /**\class XGUI_Workshop
  * \ingroup GUI
  * \brief Class which defines a configuration of the application (Workshop) and launches it.
@@ -167,6 +168,11 @@ Q_OBJECT
   //! Delete features
   void deleteObjects();
 
+  //! Searches for selected features unused in other (not selected) features. If one or several
+  //! selected features are found, a warning message proposes to delete them. It contains 
+  //! the list of features to be deleted.
+  void cleanHistory();
+
   //! Returns true if the selected feature can be moved to the position after the current feature
   //! \return boolean value
   bool canMoveFeature();
@@ -226,18 +232,12 @@ Q_OBJECT
    */
   bool abortAllOperations();
 
-  //! Delete features. Delete the referenced features. There can be a question with a list of referenced
-  //! objects.
+  //! Delete features. Delete the referenced features. There can be a question with a list of
+  //! referenced objects.
   //! \param theList an objects to be deleted
   //! \param theIgnoredFeatures a list of features to be ignored during delete
-  //! \param theParent a parent widget for the question message box
-  //! \param theAskAboutDeleteReferences if true, the message box with a list of references to the
-  //! objects features appear. If the user chose do not continue, the deletion is not performed
-  //! \return the success of the delete 
-  bool deleteFeatures(const QObjectPtrList& theList,
-                      const std::set<FeaturePtr>& theIgnoredFeatures = std::set<FeaturePtr>(),
-                      QWidget* theParent = 0,
-                      const bool theAskAboutDeleteReferences = false);
+  bool deleteFeatures(const QObjectPtrList& theFeatures,
+                      const std::set<FeaturePtr>& theIgnoredFeatures = std::set<FeaturePtr>());
 
   /// Deactivates the object, if it is active and the module returns that the activation
   /// of selection for the object is not possible currently(the current operation uses it)
@@ -258,6 +258,19 @@ Q_OBJECT
   /// \param theUpdateViewer update viewer flag
   void synchronizeGroupInViewer(const DocumentPtr& theDoc, const std::string& theGroup, bool theUpdateViewer);
 
+  /// Update the property panel content by the XML description of the operation and set the panel
+  /// into the operation
+  /// \param theOperation an operation
+  void setPropertyPanel(ModuleBase_Operation* theOperation);
+
+  /// Connects or disconnects to the value changed signal of the property panel widgets
+  /// \param isToConnect a boolean value whether connect or disconnect
+  void connectToPropertyPanel(const bool isToConnect);
+
+  /// A constant string used for "Move to end" command definition
+  /// It is used for specific processing of Undo/Redo for this command.
+  static QString MOVE_TO_END_COMMAND;
+
 signals:
   /// Emitted when selection happens in Salome viewer
   void salomeViewerSelection();
@@ -296,13 +309,17 @@ signals:
   /// Redo previous command
   void onRedo(int times = 1);
 
-  /// Rebuild data tree
-  void onRebuild();
+  // Rebuild data tree
+  //void onRebuild();
 
   /// Validates the operation to change the "Apply" button state.
   /// \param thePreviousState the previous state of the widget
   void onWidgetStateChanged(int thePreviousState);
 
+  /// Calls activate of the current widget again. It is possible that selection filters are
+  /// differs in the new state of paged container
+  void onValuesChanged();
+
   /// Show property panel
   void showPropertyPanel();
 
@@ -332,20 +349,47 @@ signals:
   void onPreferences();
 #endif
 
+  /// Activates/deactivates the trihedron in the viewer AIS context
+  void onTrihedronVisibilityChanged(bool theState);
+
  protected:
   /// Sets the granted operations for the parameter operation. Firstly, it finds the nested features
   /// and set them into the operation. Secondly, it asks the module about ids of granted operations.
   /// \param theOperation an operation
    void setGrantedFeatures(ModuleBase_Operation* theOperation);
 
-  /// Update the property panel content by the XML description of the operation and set the panel
-  /// into the operation
-  /// \param theOperation an operation
-  void setPropertyPanel(ModuleBase_Operation* theOperation);
+  //! Find all referenced features. Return direct and indirect lists of referenced object
+  //! \param theList an objects to be checked
+  //! \param aDirectRefFeatures a list of direct reference features
+  //! \param aIndirectRefFeatures a list of features which depend on the feature through others
+  void findReferences(const QObjectPtrList& theList,
+                      std::set<FeaturePtr>& aDirectRefFeatures,
+                      std::set<FeaturePtr>& aIndirectRefFeatures);
+
+  //! Shows a dialog box about references. Ask whether they should be also removed.
+  //! \param theList an objects to be checked
+  //! \param aDirectRefFeatures a list of direct reference features
+  //! \param aIndirectRefFeatures a list of features which depend on the feature through others
+  //! \param theParent a parent widget for the question message box
+  //! \param doDeleteReferences if there are parameters between features, ask if they should be
+  //! replaced to their meaning without corresponded features remove
+  //! \return true if in message box answer is Yes
+  bool isDeleteFeatureWithReferences(const QObjectPtrList& theList,
+                                     const std::set<FeaturePtr>& aDirectRefFeatures,
+                                     const std::set<FeaturePtr>& aIndirectRefFeatures,
+                                     QWidget* theParent,
+                                     bool& doDeleteReferences);
 
-  /// Connects or disconnects to the value changed signal of the property panel widgets
-  /// \param isToConnect a boolean value whether connect or disconnect
-  void connectToPropertyPanel(const bool isToConnect);
+  //! \param theIgnoredFeatures a list of features to be ignored during delete
+  //! \param theList an objects to be checked
+  //! \param aDirectRefFeatures a list of direct reference features
+  //! \param aIndirectRefFeatures a list of features which depend on the feature through others
+  //! \param doDeleteReferences flag if referenced features should be removed also
+  bool deleteFeaturesInternal(const QObjectPtrList& theList,
+                              const std::set<FeaturePtr>& aDirectRefFeatures,
+                              const std::set<FeaturePtr>& aIndirectRefFeatures,
+                              const std::set<FeaturePtr>& theIgnoredFeatures,
+                              const bool doDeleteReferences = true);
 
 private:
   /// Display all results
@@ -394,15 +438,6 @@ private:
   /// the operation can be committed and do it if it returns true.
   void onAcceptActionClicked();
 
-  /// Listens the corresponded signal from operation manager and send it with the Ok
-  /// action to operation manager.
-  /// \param theEnabled an enabled state for the action
-  //void onValidationStateChanged(bool theEnabled);
-
-  //connect(myOperationMgr,  SIGNAL(validationStateChanged(bool)),
-  //        aOkAct,          SLOT(setEnabled(bool)));
-
-
  private:
    /// Init menu
   void initMenu();
@@ -435,6 +470,15 @@ private:
   //! \param theSlot - onUndo(int) or onRedo(int) SLOT
   void addHistoryMenu(QObject* theObject, const char* theSignal, const char* theSlot);
 
+
+  /// Calls removeFeature of the document for each object in the list
+  //! \param theList an objects to be deleted
+  //! \param theIgnoredFeatures a list of features to be ignored during delete
+  //! \param theActionId an action command key to find context menu object types enabled for remove
+  bool removeFeatures(const QObjectPtrList& theList,
+                      const std::set<FeaturePtr>& theIgnoredFeatures,
+                      const QString& theActionId);
+
   //! Creates list of actions (commands) by given history list from session
   QList<ActionInfo> processHistoryList(const std::list<std::string>&) const;