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 <inspector/VInspectorAPI_CallBack.hxx>
22 #include <inspector/VInspector_CallBackMode.hxx>
23 #include <inspector/VInspector_ViewModelHistory.hxx>
24 #include <inspector/VInspector_Tools.hxx>
26 class AIS_InteractiveObject;
27 class SelectMgr_EntityOwner;
29 //! \class VInspector_CallBack
30 //! Updates inspector state on actions in context
31 class VInspector_CallBack : public VInspectorAPI_CallBack
36 VInspector_CallBack() : VInspectorAPI_CallBack() {}
39 virtual ~VInspector_CallBack() {}
41 //! Appends displayed presentation into history model
42 //! \param thePrs the presentation
43 virtual void Display (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
44 { if (myHistoryModel != 0) myHistoryModel->AddElement (VInspector_CallBackMode_Display, VInspector_Tools::GetInfo (thePrs)); }
46 //! Appends redisplayed presentation into history model
47 //! \param thePrs the presentation
48 virtual void Redisplay (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
49 { if (myHistoryModel != 0) myHistoryModel->AddElement (VInspector_CallBackMode_Redisplay, VInspector_Tools::GetInfo (thePrs)); }
51 //! Appends removed presentation into history model
52 //! \param thePrs the presentation
53 virtual void Remove (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
54 { if (myHistoryModel != 0) myHistoryModel->AddElement (VInspector_CallBackMode_Remove, VInspector_Tools::GetInfo (thePrs)); }
56 //! Appends loaded presentation into history model
57 //! \param thePrs the presentation
58 virtual void Load (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
59 { if (myHistoryModel != 0) myHistoryModel->AddElement (VInspector_CallBackMode_Load, VInspector_Tools::GetInfo (thePrs)); }
61 //! Appends information about modes activation
62 //! \param thePrs the presentation
63 //! \param theModes the selection modes
64 virtual void ActivatedModes (Handle(AIS_InteractiveObject) thePrs, TColStd_ListOfInteger& theModes) Standard_OVERRIDE
65 { (void)thePrs; (void)theModes; }
67 //! Appends information about mode activation
68 //! \param thePrs the presentation
69 //! \param theModes the selection mode
70 Standard_EXPORT virtual void Activate (Handle(AIS_InteractiveObject) thePrs,
71 const Standard_Integer theMode) Standard_OVERRIDE;
73 //! Appends information about modes deactivation
74 //! \param thePrs the presentation
75 virtual void Deactivate (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
76 { if (myHistoryModel != 0) myHistoryModel->AddElement (VInspector_CallBackMode_Deactivate, VInspector_Tools::GetInfo (thePrs)); }
78 //! Appends information about modes deactivation
79 //! \param thePrs the presentation
80 //! \param theMode the selection mode
81 virtual void Deactivate (Handle(AIS_InteractiveObject) thePrs, const Standard_Integer theMode) Standard_OVERRIDE
83 if (myHistoryModel != 0) myHistoryModel->AddElement (VInspector_CallBackMode_Deactivate, VInspector_Tools::GetInfo (thePrs)); }
85 //! Appends information about selection change
86 //! \param theShape the selected shape
87 Standard_EXPORT virtual void AddOrRemoveSelected (const TopoDS_Shape& theShape) Standard_OVERRIDE;
89 //! Appends information about selection change
90 //! \param thePrs the selected presentation
91 Standard_EXPORT virtual void AddOrRemoveSelected (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE;
93 //! Appends information about selection change
94 //! \param theOwner the selected owner
95 Standard_EXPORT virtual void AddOrRemoveSelected (Handle(SelectMgr_EntityOwner) theOwner) Standard_OVERRIDE;
97 //! Appends information about selection clear
98 Standard_EXPORT virtual void ClearSelected() Standard_OVERRIDE;
100 //! Appends information about selection clear
101 //! \param thePrs the selected presentation
102 virtual void ClearSelected (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
103 { if (myHistoryModel != 0) myHistoryModel->AddElement (VInspector_CallBackMode_ClearSelected, VInspector_Tools::GetInfo (thePrs)); }
105 //! Appends information about moving to point
106 //! \param theXPix a pixels on horizontal
107 //! \param theYPix a pixels on vertical
108 Standard_EXPORT virtual void MoveTo (const Standard_Integer theXPix, const Standard_Integer theYPix) Standard_OVERRIDE;
110 //! Appends information about setting selection
111 //! \param thePrs the selected presentation
112 virtual void SetSelected (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE
113 { if (myHistoryModel != 0) myHistoryModel->AddElement (VInspector_CallBackMode_SetSelected, VInspector_Tools::GetInfo (thePrs)); }
115 //! Appends information about select
116 Standard_EXPORT virtual void Select() Standard_OVERRIDE;
118 //! Appends information about shift select
119 Standard_EXPORT virtual void ShiftSelect() Standard_OVERRIDE;
121 //! Sets history model, it will be filled by actions in context
122 //! \param theHistoryModel the view model
123 void SetHistoryModel (VInspector_ViewModelHistory* theHistoryModel) { myHistoryModel = theHistoryModel; }
125 //! Sets context, where actions happen
126 //! \param theContext a context instance
127 void SetContext (const Handle(AIS_InteractiveContext)& theContext) { myContext = theContext; }
128 DEFINE_STANDARD_RTTIEXT(VInspector_CallBack, VInspectorAPI_CallBack)
130 //! Returns string information of call back mode
131 //! \param theMode type of AIS action
132 //! \return information text
133 static QString GetInfo (const VInspector_CallBackMode& theMode);
136 VInspector_ViewModelHistory* myHistoryModel; //!< the current history model, fulfilled by context actions
137 Handle(AIS_InteractiveContext) myContext; //!< the listened context