1 // Copyright (C) 2006-2008 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.
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
19 #include "VisitorSaveGuiSchema.hxx"
21 #include "QtGuiContext.hxx"
22 #include "guiObservers.hxx"
23 #include "SceneItem.hxx"
28 #include "YacsTrace.hxx"
31 using namespace YACS::HMI;
32 using namespace YACS::ENGINE;
34 VisitorSaveGuiSchema::VisitorSaveGuiSchema(YACS::ENGINE::Proc* proc)
35 : VisitorSaveSalomeSchema(proc), _proc(proc)
37 DEBTRACE("VisitorSaveGuiSchema::VisitorSaveGuiSchema");
40 VisitorSaveGuiSchema::~VisitorSaveGuiSchema()
42 DEBTRACE("VisitorSaveGuiSchema::~VisitorSaveGuiSchema");
45 void VisitorSaveGuiSchema::visitProc()
47 DEBTRACE("VisitorSaveGuiSchema::visitProc");
48 VisitorSaveSalomeSchema::visitProc(_proc);
52 void VisitorSaveGuiSchema::writePresentation()
54 DEBTRACE("VisitorSaveGuiSchema::writePresentation");
55 set<Node*> nodeSet = getAllNodes(_proc);
57 for (set<Node*>::iterator iter = nodeSet.begin(); iter != nodeSet.end(); ++iter)
60 SubjectNode * snode = QtGuiContext::getQtCurrent()->_mapOfSubjectNode[node];
61 SceneItem* item = QtGuiContext::getQtCurrent()->_mapOfSceneItem[snode];
63 writeItem(_proc->getChildName(node), item);
66 SubjectNode * sproc = QtGuiContext::getQtCurrent()->getSubjectProc();
67 SceneItem* item = QtGuiContext::getQtCurrent()->_mapOfSceneItem[sproc];
69 writeItem("__ROOT__", item);
72 void VisitorSaveGuiSchema::writeItem(std::string name, SceneItem* item)
75 _out << indent(depth) << "<presentation";
76 _out << " name=\"" << name << "\"";
77 _out << " x=\"" << item->x() << "\"";
78 _out << " y=\"" << item->y() << "\"";
79 _out << " width=\"" << item->getWidth() << "\"";
80 _out << " height=\""<< item->getHeight() << "\"";