Salome HOME
mergefrom branch BR_V511_PR tag mergeto_trunk_03feb09
[modules/yacs.git] / src / hmi / guiContext.cxx
index 9b539b266c2a088e6c4c0a561daeac5e404d97ec..c99b620673cf4061b67da1a452cd2615bc14b001 100644 (file)
@@ -1,4 +1,21 @@
-
+//  Copyright (C) 2006-2008  CEA/DEN, EDF R&D
+//
+//  This library is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU Lesser General Public
+//  License as published by the Free Software Foundation; either
+//  version 2.1 of the License.
+//
+//  This library is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+//  Lesser General Public License for more details.
+//
+//  You should have received a copy of the GNU Lesser General Public
+//  License along with this library; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
 #include "RuntimeSALOME.hxx"
 #include "guiContext.hxx"
 #include "Proc.hxx"
@@ -30,10 +47,7 @@ GuiContext::GuiContext()
   _proc = 0;
   _subjectProc = 0;
   _numItem = 0;
-  _selectedCanvasItem = 0;
 
-  _canvas = new QCanvas(800,2000);
-  _widgetStack = 0;
   _mapOfSubjectNode.clear();
   _mapOfSubjectDataPort.clear();
   _mapOfSubjectLink.clear();
@@ -41,6 +55,7 @@ GuiContext::GuiContext()
   _mapOfSubjectComponent.clear();
   _mapOfSubjectContainer.clear();
   _mapOfSubjectDataType.clear();
+  _mapOfExecSubjectNode.clear();
   _lastErrorMessage ="";
   _xmlSchema ="";
   _YACSEngineContainer = pair<string, string>("YACSServer","localhost");
@@ -56,6 +71,7 @@ GuiContext::~GuiContext()
       delete _subjectProc;
       _subjectProc = 0;
     }
+  _current = 0;
 }
 
 void GuiContext::setProc(YACS::ENGINE::Proc* proc)
@@ -79,93 +95,10 @@ void GuiContext::setProc(YACS::ENGINE::Proc* proc)
   _mapOfSubjectNode[static_cast<Node*>(proc)] = _subjectProc;
   update(YACS::HMI::NEWROOT, 0, _subjectProc);
   _subjectProc->loadProc();
+  update(YACS::HMI::ENDLOAD, 0, _subjectProc);
 }
 
 long GuiContext::getNewId(YACS::HMI::TypeOfElem type)
 {
-  long anId = 0;
-
-  if ( Proc* aProc = getProc() )
-  { 
-    set<long> anIds;
-       
-    if ( type == CONTAINER )
-    {
-      QString aTemplate("container");
-
-      map<string, Container*>::const_iterator itCont = aProc->containerMap.begin();
-      for ( ; itCont != aProc->containerMap.end(); ++itCont)
-      {
-       QString aName( (*itCont).second->getName() );
-       if ( aName.length() > aTemplate.length() && !aName.left(aTemplate.length()).compare(aTemplate) )
-       {
-         aName = aName.right(aName.length()-aTemplate.length());
-         bool ok;
-         long aNum = aName.toLong(&ok);
-         if (ok) anIds.insert(aNum);
-       }
-      }
-    }
-    else if ( type == COMPONENT )
-    {
-      QString aTemplate("component");
-
-      map<std::pair<std::string,int>, ComponentInstance*>::const_iterator itComp = 
-       aProc->componentInstanceMap.begin();
-      for ( ; itComp != aProc->componentInstanceMap.end(); ++itComp)
-      {
-       QString aName( (*itComp).second->getCompoName() );
-       printf(">> component name : %s\n",aName.latin1());
-       if ( aName.length() > aTemplate.length() && !aName.left(aTemplate.length()).compare(aTemplate) )
-       {
-         aName = aName.right(aName.length()-aTemplate.length());
-         bool ok;
-         long aNum = aName.toLong(&ok);
-         if (ok) anIds.insert(aNum);
-       }
-      }
-    }
-    else
-    {
-      list<Node*> aNodes = aProc->getAllRecursiveConstituents();
-      list<Node*>::iterator it = aNodes.begin();
-      for ( ; it != aNodes.end(); it++ )
-      {
-       QString aName( (*it)->getName() );
-
-       if ( ProcInvoc::getTypeOfNode(*it) != type ) continue;
-       
-       QString aTemplate;
-       switch(type)
-       {
-       case BLOC:             aTemplate= QString("Bloc");              break;
-       case FOREACHLOOP:      aTemplate= QString("ForEachLoopDouble"); break;
-       case FORLOOP:          aTemplate= QString("ForLoop");           break;
-       case WHILELOOP:        aTemplate= QString("WhileLoop");         break;
-       case SWITCH:           aTemplate= QString("Switch");            break;
-       case PYTHONNODE:       aTemplate= QString("PyScript");          break;
-       case PYFUNCNODE:       aTemplate= QString("PyFunction");        break;
-       case CORBANODE:        aTemplate= QString("CORBANode");         break;
-       case SALOMENODE:       aTemplate= QString("SalomeNode");        break;
-       case CPPNODE:          aTemplate= QString("CppNode");           break;
-       case SALOMEPYTHONNODE: aTemplate= QString("SalomePythonNode");  break;
-       case XMLNODE:          aTemplate= QString("XmlNode");           break;
-       default:                                                        break;
-       }
-
-       if ( aName.length() > aTemplate.length() && !aName.left(aTemplate.length()).compare(aTemplate) )
-       {
-         aName = aName.right(aName.length()-aTemplate.length());
-         bool ok;
-         long aNum = aName.toLong(&ok);
-         if (ok) anIds.insert(aNum);
-       }
-      }
-    }
-
-    if ( !anIds.empty() )
-      anId = (*anIds.rbegin()) + 1;
-  }
-
-  return anId;
+  return _numItem++;
 }