#include "PartSet_OperationPrs.h"
+#include <ModuleBase_IModule.h>
#include <ModelAPI_Object.h>
#include <ModelAPI_Result.h>
#include <ModelAPI_Feature.h>
#include <GeomAPI_Shape.h>
class ModuleBase_IWorkshop;
+class XGUI_Workshop;
/**
-* Interface of a class which can provide specific customization of
-* object presentation
+ * This is the module custom presentation, which manage an AIS presentation, that can be filled
+ * by a feature and visualized in the viewer additionally to usual workshop objects.
*/
-class PartSet_CustomPrs : public GeomAPI_ICustomPrs
+class PartSet_CustomPrs
{
public:
+ /// Returns yellow color
+ static const std::string OPERATION_PARAMETER_COLOR() { return "255, 255, 0"; }
+ /// 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"; }
+
+public:
+ /// Constructor
+ /// \param theWorkshop a reference to workshop
PARTSET_EXPORT PartSet_CustomPrs(ModuleBase_IWorkshop* theWorkshop);
PARTSET_EXPORT virtual ~PartSet_CustomPrs() {};
/// Returns true if the presentation is active
- bool isActive() const;
-
- /// Initializes the presentation by the parameter object
- void activate(const FeaturePtr& theObject);
+ /// \param theFlag an object AIS presentation type
+ bool isActive(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag);
+
+ /// Initializes the operation presentation by the parameter object and display the presentation
+ /// \param theObject an operation feature source to fill the presentation
+ /// \param theFlag an object AIS presentation type
+ /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
+ /// \returns true if the presentation is displayed
+ bool activate(const FeaturePtr& theObject,
+ const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag,
+ const bool theUpdateViewer);
+
+ /// Initializes the operation presentation by empty object and erase the presentation
+ /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
+ /// \param theFlag an object AIS presentation type
+ /// \returns true if the presentation has been displayed and now it is erased
+ bool deactivate(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag,
+ const bool theUpdateViewer);
+
+ /// If the presentation is active[displayed], the shapes of the presentation is recomputed
+ /// and the presentation is redisplayed.
+ /// \param theObject an object to redisplay
+ /// \param theFlag an object AIS presentation type
+ /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
+ /// \returns true if the presentation is redisplayed
+ bool redisplay(const ObjectPtr& theObject,
+ const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag,
+ const bool theUpdateViewer);
+
+ /// Nullify all internal presentations. For example, it can be useful when the viewer/context
+ /// is closed. If this is not performed and the presentation is assigned in another context,
+ /// it caused erroneus case because the presentation has linkage to the previous context.
+ void clearPrs();
- void deactivate();
+private:
+ /// Creates the AIS operation presentation
+ /// \param theFlag an object AIS presentation type
+ void initPresentation(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag);
- /// Modifies the given presentation in the custom way.
- bool customize(const ObjectPtr& theObject);
+ /// Gets an AIS presentation by the flag
+ /// \param theFlag an object AIS presentation type
+ /// \return the AIS prsentation
+ Handle(PartSet_OperationPrs) getPresentation(
+ const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag);
- /// Modifies the given presentation in the custom way.
- virtual bool customisePresentation(ResultPtr theResult, AISObjectPtr thePrs,
- std::shared_ptr<GeomAPI_ICustomPrs> theCustomPrs);
-private:
- /// Returns the AIS presentation
- Handle(PartSet_OperationPrs) getPresentation() const;
+ //! Returns workshop
+ XGUI_Workshop* workshop() const;
/// Displays the internal presentation in the viewer of workshop
- void displayPresentation();
+ /// \param theFlag an object AIS presentation type
+ /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
+ /// \param returns whether the presentation is displayed/redisplayed
+ bool displayPresentation(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag,
+ const bool theUpdateViewer);
+
/// Erases the internal presentation from the viewer of workshop
- void erasePresentation();
- /// Sets color, point size and width of the presentation
- void customizePresentation();
+ /// \param theFlag an object AIS presentation type
+ /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
+ void erasePresentation(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag,
+ const bool theUpdateViewer);
+
+ /// Nullify the operation presentation. For example, it can be useful when the viewer/context
+ /// is closed. If this is not performed and the presentation is assigned in another context,
+ /// it caused erroneus case because the presentation has linkage to the previous context.
+ /// \param theFlag an object AIS presentation type
+ void clearPresentation(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag);
+
+ /// Returns presentation color according to the flag
+ /// \param theFlag an object AIS presentation type
+ /// \return theShapeColor a color
+ Quantity_Color getShapeColor(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag);
private:
+ FeaturePtr myFeature; /// Reference to a feature object
ModuleBase_IWorkshop* myWorkshop; /// current workshop
- AISObjectPtr myOperationPrs; /// the AIS presentation, which is displayed/erased in the viewer
+ /// map of presentation type to AIS object
+ QMap<ModuleBase_IModule::ModuleBase_CustomizeFlag, AISObjectPtr> myPresentations;
+ /// State whether the presentation is activated/deactivated
+ QMap<ModuleBase_IModule::ModuleBase_CustomizeFlag, bool> myIsActive;
};
#endif