Salome HOME
98a939e4fa0552ee996050263c6da60b6908d58e
[modules/yacs.git] / src / genericgui / QtGuiContext.cxx
1 //  Copyright (C) 2006-2008  CEA/DEN, EDF R&D
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.
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 #include "QtGuiContext.hxx"
20
21 //#define _DEVDEBUG_
22 #include "YacsTrace.hxx"
23
24 using namespace std;
25 using namespace YACS::ENGINE;
26 using namespace YACS::HMI;
27
28 QtGuiContext * QtGuiContext::_QtCurrent = 0;
29 std::set<QtGuiContext*> QtGuiContext::_setOfContext;
30
31 QtGuiContext::QtGuiContext(GenericGui *gmain) : GuiContext()
32 {
33   _gmain = gmain;
34   _schemaModel = 0;
35   _editTree = 0;
36   _selectionModel = 0;
37   _scene = 0;
38   _view = 0;
39   _rootEdit = 0;
40   _window = 0;
41   _stackedWidget = 0;
42   _guiExecutor = 0;
43   _selectedSubject = 0;
44   _subjectToCut = 0;
45   _subjectToCopy = 0;
46   _isEdition = true;
47   _studyId = 0;
48   _isLoading = false;
49   _fileName = QString();
50   _mapOfSchemaItem.clear();
51   _mapOfSceneItem.clear();
52   _mapOfEditionItem.clear();
53   _setOfModifiedSubjects.clear();
54   _setOfContext.insert(this);
55 }
56
57 QtGuiContext::~QtGuiContext()
58 {
59   DEBTRACE("QtGuiContext::~QtGuiContext");
60   if (_invoc) delete _invoc;
61   _invoc = 0;
62   if (_subjectProc)
63     {
64       _subjectProc->clean();
65       delete _subjectProc;
66       _subjectProc = 0;
67     }
68   _current = 0;
69   _QtCurrent = 0;
70   _setOfContext.erase(this);
71 }
72
73 void QtGuiContext::setProc(YACS::ENGINE::Proc* proc)
74 {
75   _mapOfSchemaItem.clear();
76   _mapOfSceneItem.clear();
77   GuiContext::setProc(proc);
78 }
79
80 YACS::HMI::Subject* QtGuiContext::getSubjectToPaste(bool &isCut)
81 {
82   isCut = (_subjectToCut != 0);
83   if (isCut)
84     return _subjectToCut;
85   else
86     return _subjectToCopy;
87 }
88
89 void QtGuiContext::setSubjectToCut(YACS::HMI::Subject* sub)
90 {
91   _subjectToCut = sub;
92   _subjectToCopy = 0;
93 }
94
95 void QtGuiContext::setSubjectToCopy(YACS::HMI::Subject* sub)
96 {
97   _subjectToCopy = sub;
98   _subjectToCut = 0;
99 }