00001 /* 00002 * This file is part of openMask © INRIA, CNRS, Universite de Rennes 1 1993-2002, thereinafter the Software 00003 * 00004 * The Software has been developped within the Siames Project. 00005 * INRIA, the University of Rennes 1 and CNRS jointly hold intellectual property rights 00006 * 00007 * The Software has been registered with the Agence pour la Protection des 00008 * Programmes (APP) under registration number IDDN.FR.001.510008.00.S.P.2001.000.41200 00009 * 00010 * This file may be distributed under the terms of the Q Public License 00011 * version 1.0 as defined by Trolltech AS of Norway and appearing in the file 00012 * LICENSE.QPL included in the packaging of this file. 00013 * 00014 * Licensees holding valid specific licenses issued by INRIA, CNRS or Université de Rennes 1 00015 * for the software may use this file in accordance with that specific license 00016 * 00017 */ 00018 #ifdef _PSGUI1 00019 #include <PsGuiController.h> 00020 #include <PsArbreSimul.h> 00021 #include <PsCtrlLocGui.h> 00022 #include <PsCtrlLocPan.h> 00023 extern "C" IlvBoolean IlvSetLanguage(); 00024 //- Run ------------------------------------- 00025 // 00026 00027 PsnGuiController::PsnGuiController(const PsName & processName, PsObjectDescriptor* scenario,PsKernelObjectAbstractFactory * aFactory) 00028 : PsController(processName,scenario,aFactory) 00029 { 00030 // initialisation de l'état du controleur 00031 *_computeStatePointer= PsnReferenceObjectHandle::initial; 00032 } 00033 00034 void PsnGuiController::init() { 00035 PsNameToPointerMap<PsnReferenceObjectHandle>::iterator pTab; 00036 00037 //initialisation commune aux controleurs 00038 PsController::init(); 00039 00040 //Acquisition eventuelle d'un nom de display 00041 int nbp= NbParams(); 00042 if (nbp>=1){ 00043 char** p= Parametres(); 00044 NomDisplayX11(p[0]); 00045 } 00046 00047 // installation de l'interface utilisateur de controle de la simulation 00048 IlvSetLanguage(); 00049 00050 appliIlv = new PsCtrlLocGui(this, "controleGui", NomDisplayX11(), 0, (char**)NULL); 00051 if (!appliIlv->getDisplay()){ 00052 error("PsnGuiController - Impossible d'ouvrir le display"); 00053 } 00054 appliIlv->realize(); 00055 00056 // pour tous les referentiels init de l'interface utilisateur 00057 //la méthode initUserInterface est vide par défaut, mais existe pour tous les objets de simulation 00058 for (pTab= _referenceObjectsMap.begin(); 00059 pTab != _referenceObjectsMap.end(); 00060 pTab++) 00061 { 00062 leCalcul=(*pTab).second->getCalculus(); 00063 if(leCalcul!=NULL) { 00064 leCalcul->initUserInterface(); 00065 } 00066 } 00067 } 00068 bool PsnGuiController::lancerNouvelObjet(PsObjectDescriptor* idObj) { 00069 bool resul=PsController::lancerNouvelObjet(idObj); 00070 PsCalculus * leCalcul = idObj->RefObjet()->Calcul(); 00071 if(leCalcul!=NULL) { 00072 leCalcul->initUserInterface(); 00073 } 00074 return resul; 00075 } 00076 00077 void PsnGuiController::removeObjectFromDataStructures(const PsName & nom) { 00078 PsCalculus * calcul = getPointerToSimulatedObjectNamed(nom)->Calcul(); 00079 if (calcul!=NULL) { 00080 calcul->terminateUserInterface(); 00081 } 00082 PsController::removeObjectFromDataStructures(nom); 00083 } 00084 //---------------------------------------------------------- 00085 // desctructeur 00086 00087 PsnGuiController::~PsnGuiController() { 00088 // destruction de l'interface utilisateur 00089 delete appliIlv; 00090 //le destructeur du père est appellé en plus 00091 } 00092 00093 00094 void PsnGuiController::run() 00095 { 00096 // Phase de simulation 00097 //==================== 00098 while(*_computeStatePointer!=PsnReferenceObjectHandle::destroyed) { 00099 if(*_computeStatePointer==PsnReferenceObjectHandle::running) advanceSimulatedDate(); 00100 compute(); 00101 runUserInterface(); 00102 }//while 00103 } 00104 00105 void PsnGuiController::runUserInterface() { 00106 PsNameToPointerMap<PsnReferenceObjectHandle>::iterator pTab; 00107 // gestion des demandes de l'utilisateur au niveau controle 00108 appliIlv->gestEvtUI(); 00109 // pour tous les referentiels gestion de l'interface utilisateur pour chacun des modules 00110 for (pTab= _referenceObjectsMap.begin(); 00111 pTab != _referenceObjectsMap.end(); 00112 pTab++) 00113 { 00114 PsCalculus * leCalcul=(*pTab).second->getCalculus(); 00115 if(leCalcul!=NULL) { 00116 switch(*_computeStatePointer) { 00117 case PsnReferenceObjectHandle::running: 00118 leCalcul->runUserInterface(); 00119 break; 00120 case PsnReferenceObjectHandle::suspended: 00121 leCalcul->runUserInterface(); 00122 break; 00123 case PsnReferenceObjectHandle::stopped: 00124 leCalcul->runUserInterfaceDuringSuspend(); 00125 appliIlv->cont->showStop(); 00126 break; 00127 case PsnReferenceObjectHandle::initial: 00128 leCalcul->runUserInterfaceDuringInit(); 00129 break; 00130 default: 00131 break; 00132 } 00133 } 00134 } 00135 } 00136 void PsnGuiController::dernierPas() 00137 { 00138 if(*_computeStatePointer==PsnReferenceObjectHandle::stopped) { 00139 PsEvenement evt(Mask_DELETE, date-dt,Nom(),Nom()); 00140 nouvelEvt(evt); 00141 } 00142 else { 00143 PsDate dateEnvoi; 00144 if(*_computeStatePointer==PsnReferenceObjectHandle::suspended) { 00145 dateEnvoi=date-dt; 00146 } 00147 else { 00148 dateEnvoi=date; 00149 } 00150 PsEvenement evnt(Mask_STOP, dateEnvoi,Nom(),Nom()); 00151 nouvelEvt(evnt); 00152 } 00153 appliIlv->cont->showStop(); 00154 } 00155 00156 //- controle du deroulement de la session---------- 00157 //-------------------------------------------------- 00158 void PsnGuiController::departSim() 00159 { 00160 PsEvenement evt(Mask_START, date-dt,Nom(),Nom()); 00161 nouvelEvt(evt); 00162 } 00163 00164 void PsnGuiController::unPasSim() 00165 { 00166 advanceSimulatedDate(); 00167 traiterEvt(); 00168 computeNextSimulationStep(); 00169 supprEvt(); 00170 } 00171 00172 void PsnGuiController::pauseSim(bool etat) 00173 { 00174 if(etat) { 00175 nouvelEvt(Mask_SUSPEND); 00176 } 00177 else { 00178 PsEvenement evt(Mask_RESUME, date-dt,Nom(),Nom()); 00179 nouvelEvt(evt); 00180 } 00181 } 00182 00183 void PsnGuiController::destroyObject(const PsName & nom) { 00184 PsController::destroyObject(nom); 00185 appliIlv->cont->estDetruit(nom); 00186 } 00187 //--------------------------------------------------- 00188 00189 00190 00191 00192 00193 00194 #endif
| Documentation generated on Mon Nov 25 15:24:59 2002 |
Generated with doxygen 1.2.12 by Dimitri van Heesch , 1997-2001 |