SHAPER 9.16.0
PartSet_CustomPrs.h
1// Copyright (C) 2014-2026 CEA, EDF
2//
3// This library is free software; you can redistribute it and/or
4// modify it under the terms of the GNU Lesser General Public
5// License as published by the Free Software Foundation; either
6// version 2.1 of the License, or (at your option) any later version.
7//
8// This library is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11// Lesser General Public License for more details.
12//
13// You should have received a copy of the GNU Lesser General Public
14// License along with this library; if not, write to the Free Software
15// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16//
17// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18//
19
20#ifndef PartSet_CustomPrs_H
21#define PartSet_CustomPrs_H
22
23#include "PartSet.h"
24
25#include "PartSet_OperationPrs.h"
26
27#include <ModuleBase_IModule.h>
28#include <ModelAPI_Object.h>
29#include <ModelAPI_Result.h>
30#include <ModelAPI_Feature.h>
31
32#include <Events_Listener.h>
33
34#include <GeomAPI_ICustomPrs.h>
35#include <GeomAPI_AISObject.h>
36#include <GeomAPI_Shape.h>
37
39class XGUI_Workshop;
40
46{
47public:
49 static const std::string OPERATION_PARAMETER_COLOR() { return "255, 255, 0"; }
51 static const std::string OPERATION_RESULT_COLOR() { return "0,225, 0"; }
53 static const std::string OPERATION_HIGHLIGHT_COLOR() { return "128, 0, 0"; }
54
56 static const std::string OPERATION_REMOVE_FEATURE_COLOR() { return "255, 174, 201"; }
57
59 static const std::string OPERATION_SKETCH_PLANE() { return "170,255,0"; }
60public:
63 PARTSET_EXPORT PartSet_CustomPrs(ModuleBase_IWorkshop* theWorkshop);
64 PARTSET_EXPORT virtual ~PartSet_CustomPrs() {};
65
69
75 bool activate(const FeaturePtr& theObject,
77 const bool theUpdateViewer);
78
84 const bool theUpdateViewer);
85
92 bool redisplay(const ObjectPtr& theObject,
94 const bool theUpdateViewer);
95
99 void clearPrs();
100
104 myDisabledMode = theMode;
105 erasePresentation(theMode, false);
106 }
107
109 void enableCustomModes() { myDisabledMode = -1; }
110
112 virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
113
114private:
117 void initPresentation(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag);
118
123 AISObjectPtr getPresentation(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag,
124 const bool theToCreate);
125
127 XGUI_Workshop* workshop() const;
128
133 bool displayPresentation(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag,
134 const bool theUpdateViewer);
135
140 bool erasePresentation(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag,
141 const bool theUpdateViewer);
142
147 void clearPresentation(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag);
148
152 Quantity_Color getShapeColor(const ModuleBase_IModule::ModuleBase_CustomizeFlag& theFlag);
153
155 void clearErrorShape();
156
157private:
158 ModuleBase_IWorkshop* myWorkshop;
159 FeaturePtr myFeature;
160 bool myPresentationIsEmpty;
162 QMap<ModuleBase_IModule::ModuleBase_CustomizeFlag, AISObjectPtr> myPresentations;
164 QMap<ModuleBase_IModule::ModuleBase_CustomizeFlag, bool> myIsActive;
165
166 int myDisabledMode;
167
168 Handle(AIS_Shape) myErrorShapes;
169};
170
171#endif
Base interface for any event listener.
Definition: Events_Listener.h:37
ModuleBase_CustomizeFlag
enumeration to know which objects should be customized
Definition: ModuleBase_IModule.h:74
Class which provides access to Workshop object services.
Definition: ModuleBase_IWorkshop.h:48
This is the module custom presentation, which manage an AIS presentation, that can be filled by a fea...
Definition: PartSet_CustomPrs.h:46
static const std::string OPERATION_PARAMETER_COLOR()
Returns yellow color.
Definition: PartSet_CustomPrs.h:49
bool isActive(const ModuleBase_IModule::ModuleBase_CustomizeFlag &theFlag)
Returns true if the presentation is active.
Definition: PartSet_CustomPrs.cpp:65
void disableCustomMode(ModuleBase_IModule::ModuleBase_CustomizeFlag theMode)
Disable displaying of custom mode.
Definition: PartSet_CustomPrs.h:103
PartSet_CustomPrs(ModuleBase_IWorkshop *theWorkshop)
Constructor.
Definition: PartSet_CustomPrs.cpp:48
static const std::string OPERATION_RESULT_COLOR()
Returns green color.
Definition: PartSet_CustomPrs.h:51
static const std::string OPERATION_REMOVE_FEATURE_COLOR()
Returns color lighter than sketch feature entity : pink.
Definition: PartSet_CustomPrs.h:56
bool redisplay(const ObjectPtr &theObject, const ModuleBase_IModule::ModuleBase_CustomizeFlag &theFlag, const bool theUpdateViewer)
If the presentation is active[displayed], the shapes of the presentation is recomputed and the presen...
Definition: PartSet_CustomPrs.cpp:235
static const std::string OPERATION_SKETCH_PLANE()
Returns color equal to default color of construction plugin : green.
Definition: PartSet_CustomPrs.h:59
virtual void processEvent(const std::shared_ptr< Events_Message > &theMessage)
Redefinition of Events_Listener method to listen a moment that the presentation becomes empty.
Definition: PartSet_CustomPrs.cpp:268
static const std::string OPERATION_HIGHLIGHT_COLOR()
Returns color between white and color of highlight.
Definition: PartSet_CustomPrs.h:53
bool activate(const FeaturePtr &theObject, const ModuleBase_IModule::ModuleBase_CustomizeFlag &theFlag, const bool theUpdateViewer)
Initializes the operation presentation by the parameter object and display the presentation.
Definition: PartSet_CustomPrs.cpp:70
void clearPrs()
Nullify all internal presentations.
Definition: PartSet_CustomPrs.cpp:249
void enableCustomModes()
Enables disabled custom mode.
Definition: PartSet_CustomPrs.h:109
bool deactivate(const ModuleBase_IModule::ModuleBase_CustomizeFlag &theFlag, const bool theUpdateViewer)
Initializes the operation presentation by empty object and erase the presentation.
Definition: PartSet_CustomPrs.cpp:99
Class which defines a configuration of the application (Workshop) and launches it.
Definition: XGUI_Workshop.h:83