Version: 9.15.0
VisitorSaveGuiSchema.cxx
Go to the documentation of this file.
1
// Copyright (C) 2006-2025 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
#include "
VisitorSaveGuiSchema.hxx
"
21
#include "
Proc.hxx
"
22
#include "
QtGuiContext.hxx
"
23
#include "
guiObservers.hxx
"
24
#include "
SceneItem.hxx
"
25
#include "
SceneNodeItem.hxx
"
26
27
#include <cassert>
28
29
//#define _DEVDEBUG_
30
#include "
YacsTrace.hxx
"
31
32
using namespace
std;
33
using namespace
YACS::HMI
;
34
using namespace
YACS::ENGINE
;
35
36
VisitorSaveGuiSchema::VisitorSaveGuiSchema(
YACS::ENGINE::Proc
* proc)
37
:
VisitorSaveSalomeSchema
(proc),
_proc
(proc)
38
{
39
DEBTRACE
(
"VisitorSaveGuiSchema::VisitorSaveGuiSchema"
);
40
}
41
42
VisitorSaveGuiSchema::~VisitorSaveGuiSchema
()
43
{
44
DEBTRACE
(
"VisitorSaveGuiSchema::~VisitorSaveGuiSchema"
);
45
}
46
47
void
VisitorSaveGuiSchema::visitProc
()
48
{
49
DEBTRACE
(
"VisitorSaveGuiSchema::visitProc"
);
50
VisitorSaveSalomeSchema::visitProc(
_proc
);
51
writePresentation
();
52
}
53
54
void
VisitorSaveGuiSchema::writePresentation
()
55
{
56
DEBTRACE
(
"VisitorSaveGuiSchema::writePresentation"
);
57
set<Node*> nodeSet =
getAllNodes
(
_proc
);
58
59
for
(set<Node*>::iterator iter = nodeSet.begin(); iter != nodeSet.end(); ++iter)
60
{
61
Node
* node = *iter;
62
SubjectNode
* snode =
QtGuiContext::getQtCurrent
()->
_mapOfSubjectNode
[node];
63
SceneItem
* item =
QtGuiContext::getQtCurrent
()->
_mapOfSceneItem
[snode];
64
YASSERT
(item);
65
SceneNodeItem
* inode =
dynamic_cast<
SceneNodeItem
*
>
(item);
66
YASSERT
(inode);
67
writeItem
(
_proc
->
getChildName
(node), inode);
68
}
69
70
SubjectNode
* sproc =
QtGuiContext::getQtCurrent
()->
getSubjectProc
();
71
SceneItem
* item =
QtGuiContext::getQtCurrent
()->
_mapOfSceneItem
[sproc];
72
YASSERT
(item);
73
SceneNodeItem
* inode =
dynamic_cast<
SceneNodeItem
*
>
(item);
74
YASSERT
(inode);
75
writeItem
(
"__ROOT__"
, inode);
76
}
77
78
void
VisitorSaveGuiSchema::writeItem
(std::string name,
SceneNodeItem
* item)
79
{
80
int
depth = 1;
81
_out
<<
indent
(depth) <<
"<presentation"
;
82
_out
<<
" name=\""
<< name <<
"\""
;
83
_out
<<
" x=\""
<< item->x() <<
"\""
;
84
_out
<<
" y=\""
<< item->y() <<
"\""
;
85
_out
<<
" width=\""
<< item->
getWidth
() <<
"\""
;
86
_out
<<
" height=\""
<< item->
getHeight
() <<
"\""
;
87
_out
<<
" expanded=\""
<< item->
isExpanded
() <<
"\""
;
88
_out
<<
" expx=\""
<< item->
getExpandedX
() <<
"\""
;
89
_out
<<
" expy=\""
<< item->
getExpandedY
() <<
"\""
;
90
_out
<<
" expWidth=\""
<< item->
getExpandedWidth
() <<
"\""
;
91
_out
<<
" expHeight=\""
<< item->
getExpandedHeight
() <<
"\""
;
92
_out
<<
" shownState=\""
<< item->
getShownState
() <<
"\""
;
93
_out
<<
"/>"
<< endl;
94
}
Proc.hxx
QtGuiContext.hxx
SceneItem.hxx
SceneNodeItem.hxx
VisitorSaveGuiSchema.hxx
YacsTrace.hxx
YASSERT
#define YASSERT(val)
YASSERT macro is always defined, used like assert, but throw a YACS::Exception instead of abort.
Definition:
YacsTrace.hxx:59
DEBTRACE
#define DEBTRACE(msg)
Definition:
YacsTrace.hxx:31
YACS::ENGINE::ComposedNode::getChildName
std::string getChildName(const Node *node) const
Definition:
ComposedNode.cxx:968
YACS::ENGINE::Node
Base class for all nodes.
Definition:
Node.hxx:70
YACS::ENGINE::Proc
Base class for all schema objects.
Definition:
Proc.hxx:44
YACS::ENGINE::VisitorSaveSalomeSchema
Definition:
VisitorSaveSalomeSchema.hxx:31
YACS::ENGINE::VisitorSaveSchema::indent
std::string indent(int val)
Definition:
VisitorSaveSchema.hxx:106
YACS::ENGINE::VisitorSaveSchema::_out
std::ofstream _out
Definition:
VisitorSaveSchema.hxx:107
YACS::ENGINE::VisitorSaveSchema::getAllNodes
std::set< Node * > getAllNodes(ComposedNode *node)
Definition:
VisitorSaveSchema.cxx:1077
YACS::HMI::AbstractSceneItem::getWidth
qreal getWidth()
Definition:
SceneItem.cxx:153
YACS::HMI::AbstractSceneItem::getHeight
qreal getHeight()
Definition:
SceneItem.cxx:158
YACS::HMI::GuiContext::getSubjectProc
YACS::HMI::SubjectProc * getSubjectProc()
Definition:
guiContext.hxx:52
YACS::HMI::GuiContext::_mapOfSubjectNode
std::map< YACS::ENGINE::Node *, YACS::HMI::SubjectNode * > _mapOfSubjectNode
Definition:
guiContext.hxx:68
YACS::HMI::QtGuiContext::getQtCurrent
static QtGuiContext * getQtCurrent()
Definition:
QtGuiContext.hxx:92
YACS::HMI::QtGuiContext::_mapOfSceneItem
std::map< YACS::HMI::Subject *, YACS::HMI::SceneItem * > _mapOfSceneItem
Definition:
QtGuiContext.hxx:96
YACS::HMI::SceneItem
Definition:
SceneItem.hxx:121
YACS::HMI::SceneNodeItem
Definition:
SceneNodeItem.hxx:45
YACS::HMI::SceneNodeItem::getExpandedWidth
qreal getExpandedWidth()
Definition:
SceneNodeItem.hxx:88
YACS::HMI::SceneNodeItem::isExpanded
bool isExpanded()
Definition:
SceneNodeItem.hxx:81
YACS::HMI::SceneNodeItem::getExpandedHeight
qreal getExpandedHeight()
Definition:
SceneNodeItem.hxx:89
YACS::HMI::SceneNodeItem::getShownState
shownState getShownState()
Definition:
SceneNodeItem.hxx:90
YACS::HMI::SceneNodeItem::getExpandedX
qreal getExpandedX()
Definition:
SceneNodeItem.hxx:84
YACS::HMI::SceneNodeItem::getExpandedY
qreal getExpandedY()
Definition:
SceneNodeItem.hxx:85
YACS::HMI::SubjectNode
Definition:
guiObservers.hxx:286
YACS::HMI::VisitorSaveGuiSchema::_proc
YACS::ENGINE::Proc * _proc
Definition:
VisitorSaveGuiSchema.hxx:50
YACS::HMI::VisitorSaveGuiSchema::~VisitorSaveGuiSchema
virtual ~VisitorSaveGuiSchema()
Definition:
VisitorSaveGuiSchema.cxx:42
YACS::HMI::VisitorSaveGuiSchema::writeItem
virtual void writeItem(std::string name, SceneNodeItem *item)
Definition:
VisitorSaveGuiSchema.cxx:78
YACS::HMI::VisitorSaveGuiSchema::writePresentation
virtual void writePresentation()
Definition:
VisitorSaveGuiSchema.cxx:54
YACS::HMI::VisitorSaveGuiSchema::visitProc
virtual void visitProc()
Definition:
VisitorSaveGuiSchema.cxx:47
guiObservers.hxx
YACS::ENGINE
Definition:
AbstractPoint.hxx:37
YACS::HMI
Definition:
commands.hxx:37
driver_internal._proc
_proc
Definition:
driver_internal.py:263
src
genericgui
VisitorSaveGuiSchema.cxx
Copyright © 2006-2024 CEA, EDF