1 // Copyright (C) 2006-2014 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "VisitorSaveGuiSchema.hxx"
22 #include "QtGuiContext.hxx"
23 #include "guiObservers.hxx"
24 #include "SceneItem.hxx"
25 #include "SceneNodeItem.hxx"
30 #include "YacsTrace.hxx"
33 using namespace YACS::HMI;
34 using namespace YACS::ENGINE;
36 VisitorSaveGuiSchema::VisitorSaveGuiSchema(YACS::ENGINE::Proc* proc)
37 : VisitorSaveSalomeSchema(proc), _proc(proc)
39 DEBTRACE("VisitorSaveGuiSchema::VisitorSaveGuiSchema");
42 VisitorSaveGuiSchema::~VisitorSaveGuiSchema()
44 DEBTRACE("VisitorSaveGuiSchema::~VisitorSaveGuiSchema");
47 void VisitorSaveGuiSchema::visitProc()
49 DEBTRACE("VisitorSaveGuiSchema::visitProc");
50 VisitorSaveSalomeSchema::visitProc(_proc);
54 void VisitorSaveGuiSchema::writePresentation()
56 DEBTRACE("VisitorSaveGuiSchema::writePresentation");
57 set<Node*> nodeSet = getAllNodes(_proc);
59 for (set<Node*>::iterator iter = nodeSet.begin(); iter != nodeSet.end(); ++iter)
62 SubjectNode * snode = QtGuiContext::getQtCurrent()->_mapOfSubjectNode[node];
63 SceneItem* item = QtGuiContext::getQtCurrent()->_mapOfSceneItem[snode];
65 SceneNodeItem* inode = dynamic_cast<SceneNodeItem*>(item);
67 writeItem(_proc->getChildName(node), inode);
70 SubjectNode * sproc = QtGuiContext::getQtCurrent()->getSubjectProc();
71 SceneItem* item = QtGuiContext::getQtCurrent()->_mapOfSceneItem[sproc];
73 SceneNodeItem* inode = dynamic_cast<SceneNodeItem*>(item);
75 writeItem("__ROOT__", inode);
78 void VisitorSaveGuiSchema::writeItem(std::string name, SceneNodeItem* item)
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() << "\"";