1 // Created on: 2017-06-16
2 // Created by: Natalia ERMOLAEVA
3 // Copyright (c) 2017 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef VInspector_CallBack_H
17 #define VInspector_CallBack_H
19 #include <AIS_InteractiveContext.hxx>
20 #include <Standard.hxx>
21 #include <VInspectorAPI_CallBack.hxx>
22 #include <VInspector_CallBackMode.hxx>
23 #include <VInspector_ViewModelHistory.hxx>
24 #include <VInspector_Tools.hxx>
26 class AIS_InteractiveObject;
27 class SelectMgr_EntityOwner;
29 DEFINE_STANDARD_HANDLE(VInspector_CallBack, VInspectorAPI_CallBack)
31 //! \class VInspector_CallBack
32 //! Updates inspector state on actions in context
33 class VInspector_CallBack : public VInspectorAPI_CallBack
38 VInspector_CallBack() : VInspectorAPI_CallBack() {}
41 virtual ~VInspector_CallBack() Standard_OVERRIDE {}
43 //! Appends displayed presentation into history model
44 //! \param thePrs the presentation
45 virtual void Display (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
46 { myHistoryModel->AddElement (VInspector_CallBackMode_Display, VInspector_Tools::GetInfo (thePrs)); }
48 //! Appends redisplayed presentation into history model
49 //! \param thePrs the presentation
50 virtual void Redisplay (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
51 { myHistoryModel->AddElement (VInspector_CallBackMode_Redisplay, VInspector_Tools::GetInfo (thePrs)); }
53 //! Appends removed presentation into history model
54 //! \param thePrs the presentation
55 virtual void Remove (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
56 { myHistoryModel->AddElement (VInspector_CallBackMode_Remove, VInspector_Tools::GetInfo (thePrs)); }
58 //! Appends loaded presentation into history model
59 //! \param thePrs the presentation
60 virtual void Load (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
61 { myHistoryModel->AddElement (VInspector_CallBackMode_Load, VInspector_Tools::GetInfo (thePrs)); }
63 //! Appends information about modes activation
64 //! \param thePrs the presentation
65 //! \param theModes the selection modes
66 virtual void ActivatedModes (Handle(AIS_InteractiveObject) thePrs, TColStd_ListOfInteger& theModes) Standard_OVERRIDE
67 { (void)thePrs; (void)theModes; }
69 //! Appends information about mode activation
70 //! \param thePrs the presentation
71 //! \param theModes the selection mode
72 Standard_EXPORT virtual void Activate (Handle(AIS_InteractiveObject) thePrs,
73 const Standard_Integer theMode) Standard_OVERRIDE;
75 //! Appends information about modes deactivation
76 //! \param thePrs the presentation
77 virtual void Deactivate (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
78 { myHistoryModel->AddElement (VInspector_CallBackMode_Deactivate, VInspector_Tools::GetInfo (thePrs)); }
80 //! Appends information about modes deactivation
81 //! \param thePrs the presentation
82 //! \param theMode the selection mode
83 virtual void Deactivate (Handle(AIS_InteractiveObject) thePrs, const Standard_Integer theMode) Standard_OVERRIDE
84 { (void)theMode; myHistoryModel->AddElement (VInspector_CallBackMode_Deactivate, VInspector_Tools::GetInfo (thePrs)); }
86 //! Appends information about selection change
87 //! \param theShape the selected shape
88 Standard_EXPORT virtual void AddOrRemoveSelected (const TopoDS_Shape& theShape) Standard_OVERRIDE;
90 //! Appends information about selection change
91 //! \param thePrs the selected presentation
92 Standard_EXPORT virtual void AddOrRemoveSelected (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE;
94 //! Appends information about selection change
95 //! \param theOwner the selected owner
96 Standard_EXPORT virtual void AddOrRemoveSelected (Handle(SelectMgr_EntityOwner) theOwner) Standard_OVERRIDE;
98 //! Appends information about selection clear
99 Standard_EXPORT virtual void ClearSelected() Standard_OVERRIDE;
101 //! Appends information about selection clear
102 //! \param thePrs the selected presentation
103 virtual void ClearSelected (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
104 { myHistoryModel->AddElement (VInspector_CallBackMode_ClearSelected, VInspector_Tools::GetInfo (thePrs)); }
106 //! Appends information about moving to point
107 //! \param theXPix a pixels on horizontal
108 //! \param theYPix a pixels on vertical
109 Standard_EXPORT virtual void MoveTo (const Standard_Integer theXPix, const Standard_Integer theYPix) Standard_OVERRIDE;
111 //! Appends information about setting selection
112 //! \param thePrs the selected presentation
113 virtual void SetSelected (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
114 { myHistoryModel->AddElement (VInspector_CallBackMode_SetSelected, VInspector_Tools::GetInfo (thePrs)); }
116 //! Appends information about select
117 Standard_EXPORT virtual void Select() Standard_OVERRIDE;
119 //! Appends information about shift select
120 Standard_EXPORT virtual void ShiftSelect() Standard_OVERRIDE;
122 //! Sets history model, it will be filled by actions in context
123 //! \param theHistoryModel the view model
124 void SetHistoryModel (VInspector_ViewModelHistory* theHistoryModel) { myHistoryModel = theHistoryModel; }
126 //! Sets context, where actions happen
127 //! \param theContext a context instance
128 void SetContext (const Handle(AIS_InteractiveContext)& theContext) { myContext = theContext; }
129 #if OCC_VERSION_HEX <= 0x060901
130 DEFINE_STANDARD_RTTI(VInspector_CallBack)
132 DEFINE_STANDARD_RTTIEXT(VInspector_CallBack, VInspectorAPI_CallBack)
135 //! Returns string information of call back mode
136 //! \param theMode type of AIS action
137 //! \return information text
138 static QString GetInfo (const VInspector_CallBackMode& theMode);
141 VInspector_ViewModelHistory* myHistoryModel; //!< the current history model, fulfilled by context actions
142 Handle(AIS_InteractiveContext) myContext; //!< the listened context