0029807: [Regression to 7.0.0] Impossible to cut cone from prism
[occt.git] / tools / VInspector / VInspector_CallBack.hxx
CommitLineData
14bbbdcb 1// Created on: 2017-06-16
2// Created by: Natalia ERMOLAEVA
3// Copyright (c) 2017 OPEN CASCADE SAS
4//
5// This file is part of Open CASCADE Technology software library.
6//
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.
12//
13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
15
16#ifndef VInspector_CallBack_H
17#define VInspector_CallBack_H
18
19#include <AIS_InteractiveContext.hxx>
20#include <Standard.hxx>
0cb512c0 21#include <inspector/VInspectorAPI_CallBack.hxx>
22#include <inspector/VInspector_CallBackMode.hxx>
23#include <inspector/VInspector_ViewModelHistory.hxx>
24#include <inspector/VInspector_Tools.hxx>
14bbbdcb 25
26class AIS_InteractiveObject;
27class SelectMgr_EntityOwner;
28
29DEFINE_STANDARD_HANDLE(VInspector_CallBack, VInspectorAPI_CallBack)
30
31//! \class VInspector_CallBack
32//! Updates inspector state on actions in context
33class VInspector_CallBack : public VInspectorAPI_CallBack
34{
35public:
36
37 //! Constructor
38 VInspector_CallBack() : VInspectorAPI_CallBack() {}
39
40 //! Destructor
41 virtual ~VInspector_CallBack() Standard_OVERRIDE {}
42
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)); }
47
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)); }
52
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)); }
57
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)); }
62
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; }
68
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;
74
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)); }
79
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)); }
85
86 //! Appends information about selection change
87 //! \param theShape the selected shape
88 Standard_EXPORT virtual void AddOrRemoveSelected (const TopoDS_Shape& theShape) Standard_OVERRIDE;
89
90 //! Appends information about selection change
91 //! \param thePrs the selected presentation
92 Standard_EXPORT virtual void AddOrRemoveSelected (Handle(AIS_InteractiveObject) thePrs) Standard_OVERRIDE;
93
94 //! Appends information about selection change
95 //! \param theOwner the selected owner
96 Standard_EXPORT virtual void AddOrRemoveSelected (Handle(SelectMgr_EntityOwner) theOwner) Standard_OVERRIDE;
97
98 //! Appends information about selection clear
99 Standard_EXPORT virtual void ClearSelected() Standard_OVERRIDE;
100
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)); }
105
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;
110
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)); }
115
116 //! Appends information about select
117 Standard_EXPORT virtual void Select() Standard_OVERRIDE;
118
119 //! Appends information about shift select
120 Standard_EXPORT virtual void ShiftSelect() Standard_OVERRIDE;
121
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; }
125
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)
131#else
132 DEFINE_STANDARD_RTTIEXT(VInspector_CallBack, VInspectorAPI_CallBack)
133#endif
134
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);
139
140private:
141 VInspector_ViewModelHistory* myHistoryModel; //!< the current history model, fulfilled by context actions
142 Handle(AIS_InteractiveContext) myContext; //!< the listened context
143};
144
145#endif