diff --git a/src/Mod/PartDesign/Gui/TaskLinearPatternParameters.h b/src/Mod/PartDesign/Gui/TaskLinearPatternParameters.h index 91b24f2cea..4425a98933 100644 --- a/src/Mod/PartDesign/Gui/TaskLinearPatternParameters.h +++ b/src/Mod/PartDesign/Gui/TaskLinearPatternParameters.h @@ -55,6 +55,9 @@ public: void apply() override; +protected: + void onSelectionChanged(const Gui::SelectionChanges& msg) override; + private Q_SLOTS: void onUpdateViewTimer(); void onDirectionChanged(int num); @@ -65,8 +68,15 @@ private Q_SLOTS: void onOccurrences(const uint n); void onUpdateView(bool) override; -protected: - void onSelectionChanged(const Gui::SelectionChanges& msg) override; +private: + void setupParameterUI(QWidget* widget) override; + void retranslateParameterUI(QWidget* widget) override; + + void connectSignals(); + void updateUI(); + void adaptVisibilityToMode(); + void kickUpdateViewTimer() const; + void getDirection(App::DocumentObject*& obj, std::vector& sub) const; bool getReverse() const; int getMode() const; @@ -74,14 +84,6 @@ protected: double getOffset() const; unsigned getOccurrences() const; -private: - void setupParameterUI(QWidget* widget) override; - void retranslateParameterUI(QWidget* widget) override; - void connectSignals(); - void updateUI(); - void adaptVisibilityToMode(); - void kickUpdateViewTimer() const; - private: std::unique_ptr ui; QTimer* updateViewTimer = nullptr; diff --git a/src/Mod/PartDesign/Gui/TaskMirroredParameters.h b/src/Mod/PartDesign/Gui/TaskMirroredParameters.h index ac63ead9cc..ff354786fa 100644 --- a/src/Mod/PartDesign/Gui/TaskMirroredParameters.h +++ b/src/Mod/PartDesign/Gui/TaskMirroredParameters.h @@ -57,20 +57,20 @@ public: void apply() override; +protected: + void onSelectionChanged(const Gui::SelectionChanges& msg) override; + private Q_SLOTS: void onPlaneChanged(int num); void onUpdateView(bool) override; -protected: - void onSelectionChanged(const Gui::SelectionChanges& msg) override; - private: void setupParameterUI(QWidget* widget) override; void retranslateParameterUI(QWidget* widget) override; void updateUI(); - ComboLinks planeLinks; private: + ComboLinks planeLinks; std::unique_ptr ui; }; @@ -83,7 +83,6 @@ class TaskDlgMirroredParameters : public TaskDlgTransformedParameters public: explicit TaskDlgMirroredParameters(ViewProviderMirrored *MirroredView); -public: /// is called by the framework if the dialog is accepted (Ok) bool accept() override; }; diff --git a/src/Mod/PartDesign/Gui/TaskMultiTransformParameters.h b/src/Mod/PartDesign/Gui/TaskMultiTransformParameters.h index c8f8ec5c01..6270dcfcdf 100644 --- a/src/Mod/PartDesign/Gui/TaskMultiTransformParameters.h +++ b/src/Mod/PartDesign/Gui/TaskMultiTransformParameters.h @@ -63,11 +63,9 @@ public: void apply() override; -public Q_SLOTS: - /// User finished editing a subFeature - void onSubTaskButtonOK() override; - private Q_SLOTS: + /// User finished editing a subFeature + void onSubTaskButtonOK(); void onTransformDelete(); void onTransformEdit(); void onTransformActivated(const QModelIndex& index); @@ -80,12 +78,14 @@ private Q_SLOTS: // Note: There is no Cancel button because I couldn't work out how to save the state of // a subFeature so as to revert the changes of an edit operation void onUpdateView(bool) override; - /** Notifies when the object is about to be removed. */ - void slotDeletedObject(const Gui::ViewProviderDocumentObject& Obj) override; private: void setupParameterUI(QWidget* widget) override; void retranslateParameterUI(QWidget* widget) override; + + /** Notifies when the object is about to be removed. */ + void slotDeletedObject(const Gui::ViewProviderDocumentObject& Obj) override; + void updateUI(); void closeSubTask(); void moveTransformFeature(const int increment); @@ -108,7 +108,6 @@ class TaskDlgMultiTransformParameters : public TaskDlgTransformedParameters public: explicit TaskDlgMultiTransformParameters(ViewProviderMultiTransform *MultiTransformView); -public: /// is called by the framework if the dialog is accepted (Ok) bool accept() override; /// is called by the framework if the dialog is rejected (Cancel) diff --git a/src/Mod/PartDesign/Gui/TaskPolarPatternParameters.h b/src/Mod/PartDesign/Gui/TaskPolarPatternParameters.h index 7fec756d8f..1d5c8e2e9a 100644 --- a/src/Mod/PartDesign/Gui/TaskPolarPatternParameters.h +++ b/src/Mod/PartDesign/Gui/TaskPolarPatternParameters.h @@ -55,6 +55,9 @@ public: void apply() override; +protected: + void onSelectionChanged(const Gui::SelectionChanges& msg) override; + private Q_SLOTS: void onUpdateViewTimer(); void onAxisChanged(int num); @@ -65,8 +68,15 @@ private Q_SLOTS: void onOccurrences(const uint n); void onUpdateView(bool) override; -protected: - void onSelectionChanged(const Gui::SelectionChanges& msg) override; +private: + void setupParameterUI(QWidget* widget) override; + void retranslateParameterUI(QWidget* widget) override; + + void connectSignals(); + void updateUI(); + void kickUpdateViewTimer() const; + void adaptVisibilityToMode(); + void getAxis(App::DocumentObject*& obj, std::vector& sub) const; const std::string getStdAxis() const; const std::string getAxis() const; @@ -74,14 +84,6 @@ protected: double getAngle() const; unsigned getOccurrences() const; -private: - void setupParameterUI(QWidget* widget) override; - void retranslateParameterUI(QWidget* widget) override; - void connectSignals(); - void updateUI(); - void kickUpdateViewTimer() const; - void adaptVisibilityToMode(); - private: std::unique_ptr ui; QTimer* updateViewTimer = nullptr; diff --git a/src/Mod/PartDesign/Gui/TaskScaledParameters.h b/src/Mod/PartDesign/Gui/TaskScaledParameters.h index 8b4e342b6f..49373d895a 100644 --- a/src/Mod/PartDesign/Gui/TaskScaledParameters.h +++ b/src/Mod/PartDesign/Gui/TaskScaledParameters.h @@ -58,15 +58,14 @@ private Q_SLOTS: void onOccurrences(const uint n); void onUpdateView(bool) override; -protected: - double getFactor() const; - unsigned getOccurrences() const; - private: void setupParameterUI(QWidget* widget) override; void retranslateParameterUI(QWidget* widget) override; void updateUI(); + double getFactor() const; + unsigned getOccurrences() const; + private: std::unique_ptr ui; }; @@ -80,7 +79,6 @@ class TaskDlgScaledParameters : public TaskDlgTransformedParameters public: explicit TaskDlgScaledParameters(ViewProviderScaled *ScaledView); -public: /// is called by the framework if the dialog is accepted (Ok) bool accept() override; }; diff --git a/src/Mod/PartDesign/Gui/TaskTransformedParameters.h b/src/Mod/PartDesign/Gui/TaskTransformedParameters.h index 302dd85303..a46dce1216 100644 --- a/src/Mod/PartDesign/Gui/TaskTransformedParameters.h +++ b/src/Mod/PartDesign/Gui/TaskTransformedParameters.h @@ -131,20 +131,7 @@ public: explicit TaskTransformedParameters(TaskMultiTransformParameters *parentTask); ~TaskTransformedParameters() override; - /// Returns the originals property of associated top feeature object - const std::vector & getOriginals() const; - - /// Get the TransformedFeature object associated with this task - // Either through the ViewProvider or the currently active subFeature of the parentTask - App::DocumentObject *getBaseObject() const; - - /// Get the sketch object of the first original either of the object associated with this feature or with the parent feature (MultiTransform mode) - App::DocumentObject* getSketchObject() const; - - void exitSelectionMode(); - virtual void apply() = 0; - virtual void onUpdateView(bool) = 0; /*! * \brief setEnabledTransaction @@ -153,14 +140,87 @@ public: * By default, transactions are enabled. */ void setEnabledTransaction(bool); + + /// Exit the selection mode of the associated task panel + void exitSelectionMode(); + +protected: + /** Setup the standalone UI. + * Call this in the derived destructor with ViewProvider. + */ + void setupUI(); + + /** + * Returns the base transformation + * For stand alone features it will be object associated with the view provider + * For features inside MultiTransform it will be the parent MultiTransform's sub feature object + */ + PartDesign::Transformed *getObject() const; + + /// Get the sketch object of the first original either of the object associated with this feature or with the parent feature (MultiTransform mode) + App::DocumentObject* getSketchObject() const; + + /** Handle adding/removing of selected features + * Returns true if a selected feature was added/removed. + */ + bool originalSelected(const Gui::SelectionChanges& msg); + + /// Recompute either this feature or the parent MultiTransform feature + void recomputeFeature(); + + /// Hide the top transformed object (see getTopTransformedObject()) + void hideObject(); + /// Show the top transformed object (see getTopTransformedObject()) + void showObject(); + /// Hide the base transformation object (see getObject()) + void hideBase(); + /// Show the base transformation object (see getObject()) + void showBase(); + + void addReferenceSelectionGate(AllowSelectionFlags); + + int getUpdateViewTimeout() const; + + /** Notifies when the object is about to be removed. */ + void slotDeletedObject(const Gui::ViewProviderDocumentObject& Obj) override; + + void onSelectionChanged(const Gui::SelectionChanges& msg) override; + + /// Fill combobox with the axis from the sketch and the own bodys origin axis + void fillAxisCombo(ComboLinks &combolinks, Part::Part2DObject *sketch); + /// Fill combobox with the planes from the sketch and the own bodys origin planes + void fillPlanesCombo(ComboLinks &combolinks, Part::Part2DObject *sketch); + bool isEnabledTransaction() const; void setupTransaction(); - int getTransactionID() const { - return transactionID; - } +private Q_SLOTS: + virtual void onUpdateView(bool) = 0; + + void onButtonAddFeature(const bool checked); + void onButtonRemoveFeature(const bool checked); + void onFeatureDeleted(); + void indexesMoved(); + +private: + /** Setup the parameter UI. + * This is called to create the parameter UI in the specified widget. + * Call this in the derived constructor with MultiTransform parent. + */ + virtual void setupParameterUI(QWidget* widget) = 0; + + /// Change translation of the parameter UI + virtual void retranslateParameterUI(QWidget* widget) = 0; + + void addObject(App::DocumentObject*); + void removeObject(App::DocumentObject*); + void clearButtons(); + void checkVisibility(); + + /// Return the base object of the base transformed object (see getTopTransformedObject()) + // Either through the ViewProvider or the currently active subFeature of the parentTask + App::DocumentObject *getBaseObject() const; -protected: /** * Returns the base transformation view provider * For stand alone features it will be view provider associated with this object @@ -175,79 +235,33 @@ protected: */ PartDesign::Transformed *getTopTransformedObject () const; -protected Q_SLOTS: - /// Connect the subTask OK button to the MultiTransform task - virtual void onSubTaskButtonOK() {} - void onButtonAddFeature(const bool checked); - void onButtonRemoveFeature(const bool checked); - void onFeatureDeleted(); - void indexesMoved(); - -protected: - void setupUI(); - - /** - * Returns the base transformation - * For stand alone features it will be objects associated with the view provider - * For features inside multitransform it will be the parent's multitransform object - */ - PartDesign::Transformed *getObject () const; - - bool originalSelected(const Gui::SelectionChanges& msg); - - /// Recompute either this feature or the parent feature (MultiTransform mode) - void recomputeFeature(); - - void hideObject(); - void showObject(); - void hideBase(); - void showBase(); - - void addReferenceSelectionGate(AllowSelectionFlags); - - int getUpdateViewTimeout() const; - - void checkVisibility(); - -private: - virtual void setupParameterUI(QWidget* widget) = 0; - virtual void retranslateParameterUI(QWidget* widget) = 0; - -protected: - virtual void addObject(App::DocumentObject*); - virtual void removeObject(App::DocumentObject*); - /** Notifies when the object is about to be removed. */ - void slotDeletedObject(const Gui::ViewProviderDocumentObject& Obj) override; void changeEvent(QEvent *e) override; - void onSelectionChanged(const Gui::SelectionChanges& msg) override; - void clearButtons(); + static void removeItemFromListWidget(QListWidget* widget, const QString& itemstr); - void fillAxisCombo(ComboLinks &combolinks, Part::Part2DObject *sketch); - void fillPlanesCombo(ComboLinks &combolinks, Part::Part2DObject *sketch); - protected: - QWidget* proxy = nullptr; - ViewProviderTransformed *TransformedView = nullptr; - int transactionID = 0; - bool enableTransaction = true; - enum class SelectionMode { None, AddFeature, RemoveFeature, Reference }; + + ViewProviderTransformed *TransformedView = nullptr; SelectionMode selectionMode = SelectionMode::None; - /// The MultiTransform parent task of this task - TaskMultiTransformParameters* parentTask = nullptr; - /// Flag indicating whether this object is a container for MultiTransform - bool insideMultiTransform = false; /// Lock updateUI(), applying changes to the underlying feature and calling recomputeFeature() bool blockUpdate = false; private: + int transactionID = 0; + bool enableTransaction = true; + /// The MultiTransform parent task of this task + TaskMultiTransformParameters* parentTask = nullptr; + /// Flag indicating whether this object is a container for MultiTransform + bool insideMultiTransform = false; + /// Widget holding the transform task UI + QWidget* proxy = nullptr; std::unique_ptr ui; }; @@ -262,7 +276,6 @@ public: ViewProviderTransformed* getTransformedView() const { return static_cast(vp); } -public: /// is called by the framework if the dialog is accepted (Ok) bool accept() override; /// is called by the framework if the dialog is rejected (Cancel)