26 #include <SUIT_MessageBox.h>
27 #include <SUIT_ResourceMgr.h>
28 #include <SUIT_Desktop.h>
29 #include <SUIT_ViewManager.h>
30 #include <SUIT_ViewWindow.h>
31 #include <SalomeApp_Application.h>
32 #include <SalomeApp_Engine_i.h>
33 #include <QxScene_ViewManager.h>
34 #include <QxScene_ViewModel.h>
35 #include <QxScene_ViewWindow.h>
37 #include <SalomeApp_DataObject.h>
38 #include <SalomeApp_Study.h>
39 #include <SalomeApp_Module.h>
40 #include <SUIT_DataBrowser.h>
41 #include <QtxTreeView.h>
42 #include <SUIT_DataObject.h>
44 #include <SALOME_LifeCycleCORBA.hxx>
46 #include <QInputDialog>
59 using namespace YACS::HMI;
76 disconnect( getApp(), SIGNAL(studyClosed()),
this, SLOT (
onCleanOnExit()));
85 SalomeApp_Module::initialize( app );
87 QWidget* aParent = application()->desktop();
88 DEBTRACE(app <<
" " << application() <<
" " << application()->desktop() <<
" " << aParent);
90 SUIT_ResourceMgr* aResourceMgr = app->resourceMgr();
96 if ( app && app->desktop() )
98 connect( app->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
102 SIGNAL(objectDoubleClicked( SUIT_DataObject* )),
107 SIGNAL(studyClosed()),
119 SalomeApp_Study* aStudy =
dynamic_cast<SalomeApp_Study*
>( app->activeStudy() );
121 bool aLocked = (_PTR(AttributeStudyProperties)(aStudy->studyDS()->GetProperties()))->IsLocked();
123 SUIT_MessageBox::warning ( app->desktop(), QObject::tr(
"WRN_WARNING"), QObject::tr(
"WRN_STUDY_LOCKED") );
131 QStringList appModules;
132 app->modules(appModules,
false);
133 for ( QStringList::const_iterator it = appModules.begin(); it != appModules.end(); ++it )
136 QString modName = app->moduleName( aModule );
137 if ( modName.isEmpty() ) modName = aModule;
138 QString rootDir = QString(
"%1_ROOT_DIR" ).arg( modName );
139 QString modDir = getenv( rootDir.toLatin1().constData() );
140 if ( !modDir.isEmpty() )
142 QStringList cataLst = QStringList() << modDir <<
"share" <<
"salome" <<
"resources" << modName.toLower() << modName+
"SchemaCatalog.xml";
143 QString cataFile = cataLst.join( QDir::separator() );
144 if ( QFile::exists( cataFile ) )
153 list.append( QxScene_Viewer::Type() );
158 DEBTRACE(
"Yacsgui::activateModule");
159 bool bOk = SalomeApp_Module::activateModule( theStudy );
162 if(Resource::dockWidgetPriority)
164 parent->setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
165 parent->setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
166 parent->setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea);
167 parent->setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
169 setMenuShown(
true );
170 setToolShown(
true );
174 PyGILState_STATE gstate = PyGILState_Ensure();
175 PyObject* pluginsmanager=PyImport_ImportModule((
char*)
"salome_pluginsmanager");
176 if(pluginsmanager==NULL)
180 PyObject* result=PyObject_CallMethod( pluginsmanager, (
char*)
"initialize", (
char*)
"isss",1,
"yacs",
"YACS",tr(
"YACS_PLUGINS").toStdString().c_str());
185 Py_XDECREF(pluginsmanager);
187 PyGILState_Release(gstate);
198 DEBTRACE(
"Yacsgui::deactivateModule");
201 parent->setCorner(Qt::TopLeftCorner, Qt::TopDockWidgetArea);
202 parent->setCorner(Qt::BottomLeftCorner, Qt::BottomDockWidgetArea);
203 parent->setCorner(Qt::TopRightCorner, Qt::TopDockWidgetArea);
204 parent->setCorner(Qt::BottomRightCorner, Qt::BottomDockWidgetArea);
206 setMenuShown(
false );
207 setToolShown(
false );
211 DEBTRACE(
"_studyContextMap[theStudy] " << theStudy <<
" " << context);
212 return SalomeApp_Module::deactivateModule( theStudy );
221 theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
222 theMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
228 QString anEngineIOR = SalomeApp_Engine_i::EngineIORForComponent(
"YACS",
true ).c_str();
235 DataObjectList dol =getApp()->objectBrowser()->getSelected();
236 if (dol.isEmpty())
return;
238 SalomeApp_DataObject* item =
dynamic_cast<SalomeApp_DataObject*
>(dol[0]);
241 DEBTRACE(item->name().toStdString());
244 DEBTRACE(item->entry().toStdString());
245 QWidget * viewWindow = model->getViewWindow(item->entry().toStdString());
247 if (!viewWindow)
return;
248 DEBTRACE(
"--- " << viewWindow <<
" " << item->entry().toStdString());
249 if (getApp()->activeModule()->moduleName().compare(
"YACS") != 0)
250 getApp()->activateModule(
"YACS");
253 viewWindow->setFocus();
259 DEBTRACE(
"Yacsgui::onWindowActivated");
260 QxScene_ViewWindow* viewWindow =
dynamic_cast<QxScene_ViewWindow*
>(svw);
267 DEBTRACE(
"viewWindow " << viewWindow);
268 DEBTRACE(
"activeModule()->moduleName() " << (getApp()->activeModule() ? getApp()->activeModule()->moduleName().toStdString() :
"") );
269 if (!getApp()->activeModule() || getApp()->activeModule()->moduleName() !=
"YACS")
272 disconnect(viewWindow, SIGNAL( tryClose(
bool&, QxScene_ViewWindow* ) ),
273 this, SLOT(
onTryClose(
bool&, QxScene_ViewWindow* )) );
274 disconnect(viewWindow->getViewManager(), SIGNAL( deleteView( SUIT_ViewWindow* ) ),
276 connect(viewWindow, SIGNAL( tryClose(
bool&, QxScene_ViewWindow* ) ),
277 this, SLOT(
onTryClose(
bool&, QxScene_ViewWindow* )) );
278 connect(viewWindow->getViewManager(), SIGNAL( deleteView( SUIT_ViewWindow* ) ),
283 _studyContextMap[getApp()->activeStudy()->id()] = QtGuiContext::getQtCurrent();
293 DEBTRACE(
"Yacsgui::onWindowClosed");
312 DEBTRACE(
"Yacsgui::createSComponent");
313 _PTR(Study) aStudy = (( SalomeApp_Study* )(getApp()->activeStudy()))->studyDS();
314 _PTR(StudyBuilder) aBuilder (aStudy->NewBuilder());
315 _PTR(GenericAttribute) anAttr;
316 _PTR(AttributeName) aName;
320 _PTR(SComponent) aComponent = aStudy->FindComponent(
"YACS");
323 aComponent = aBuilder->NewComponent(
"YACS");
324 anAttr = aBuilder->FindOrCreateAttribute(aComponent,
"AttributeName");
325 aName = _PTR(AttributeName) (anAttr);
326 aName->SetValue(getApp()->moduleTitle(
"YACS").toStdString());
328 anAttr = aBuilder->FindOrCreateAttribute(aComponent,
"AttributePixMap");
329 _PTR(AttributePixMap) aPixmap(anAttr);
330 aPixmap->SetPixMap(
"ModuleYacs.png");
332 aBuilder->DefineComponentInstance(aComponent,
engineIOR().toLatin1().constData());
348 DEBTRACE(
"Yacsgui::createPreferences");
354 DEBTRACE(
"Yacsgui::preferencesChanged");
356 if(name==
"userCatalog")
364 int newStudyId = getApp()->activeStudy()->id();
377 DEBTRACE(
"no switch to null context");