Version: 9.16.0
Yacsgui Class Reference

#include <Yacsgui.hxx>

Inheritance diagram for Yacsgui:
Collaboration diagram for Yacsgui:

Public Slots

bool deactivateModule (SUIT_Study *theStudy)
 
bool activateModule (SUIT_Study *theStudy)
 
void onDblClick (SUIT_DataObject *object)
 
void onCleanOnExit ()
 

Public Member Functions

 Yacsgui ()
 
virtual ~Yacsgui ()
 
void initialize (CAM_Application *app)
 
void windows (QMap< int, int > &theMap) const
 
virtual QString engineIOR () const
 
virtual void viewManagers (QStringList &list) const
 
virtual void setResource (SUIT_ResourceMgr *r)
 
virtual void createPreferences ()
 
virtual void preferencesChanged (const QString &sect, const QString &name)
 
virtual void loadSchema (const std::string &filename, bool edit=true, bool arrangeLocalNodes=false)
 
- Public Member Functions inherited from SalomeWrap_Module
 SalomeWrap_Module (const char *name)
 
QxScene_ViewWindow * getNewWindow (QGraphicsScene *scene)
 
void AssociateViewToWindow (QGraphicsView *gView, QxScene_ViewWindow *viewWindow)
 
QDockWidget * objectBrowser ()
 
QAction * wCreateAction (const int id, const QString &toolTip, const QIcon &icon, const QString &menu, const QString &status, const int shortCut, QObject *parent=0, bool checkable=false, QObject *receiver=0, const char *member=0)
 
int wCreateMenu (const QString &subMenu, const int parentMenuId, const int menuId=-1, const int groupId=-1, const int index=-1)
 
int wCreateMenu (const QString &subMenu, const QString &parentMenu, const int menuId=-1, const int groupId=-1, const int index=-1)
 
int wCreateMenu (const int actionId, const int menuId, const int groupId=-1, const int index=-1)
 
int wCreateMenu (const int actionId, const QString &menu, const int groupId=-1, const int index=-1)
 
int wCreateMenu (QAction *action, const int menuId, const int actionId=-1, const int groupId=-1, const int index=-1)
 
int wCreateMenu (QAction *action, const QString &menu, const int actionId=-1, const int groupId=-1, const int index=-1)
 
int wCreateTool (const QString &title, const QString &name=QString())
 
int wCreateTool (const int actionId, const int toolbarId, const int index=-1)
 
int wCreateTool (const int actionId, const QString &toolbar, const int index=-1)
 
int wCreateTool (QAction *action, const int toolbarId, const int actionId=-1, const int index=-1)
 
int wCreateTool (QAction *action, const QString &toolbar, const int actionId=-1, const int index=-1)
 
SalomeWrap_DataModelgetDataModel ()
 

Protected Slots

void onWindowActivated (SUIT_ViewWindow *svw)
 
void onWindowClosed (SUIT_ViewWindow *svw)
 
void onTryClose (bool &isClosed, QxScene_ViewWindow *window)
 

Protected Member Functions

virtual CAM_DataModel * createDataModel ()
 
bool createSComponent ()
 
virtual CAM_DataModel * createDataModel ()
 

Protected Attributes

YACS::HMI::SuitWrapper_wrapper
 
YACS::HMI::GenericGui_genericGui
 
bool _selectFromTree
 
Yacsgui_Resource_myresource
 
SUIT_ViewWindow * _currentSVW
 
YACS::HMI::QtGuiContext_studyContext
 
- Protected Attributes inherited from SalomeWrap_Module
std::map< QGraphicsScene *, QxScene_ViewWindow * > _mapOfViewWindow
 

Friends

class Yacsgui_Resource
 

Additional Inherited Members

- Static Public Member Functions inherited from SalomeWrap_Module
static QAction * wSeparator ()
 

Detailed Description

Definition at line 46 of file Yacsgui.hxx.

Constructor & Destructor Documentation

◆ Yacsgui()

Yacsgui::Yacsgui ( )

Definition at line 61 of file Yacsgui.cxx.

61 :
62 SalomeWrap_Module( "YACS" ) // default name
63{
64 DEBTRACE("Yacsgui::Yacsgui");
65 _wrapper = 0;
66 _genericGui = 0;
67 _selectFromTree = false;
68 _studyContext = 0;
69}
#define DEBTRACE(msg)
Definition: YacsTrace.hxx:31
SalomeWrap_Module(const char *name)
bool _selectFromTree
Definition: Yacsgui.hxx:83
YACS::HMI::SuitWrapper * _wrapper
Definition: Yacsgui.hxx:81
YACS::HMI::QtGuiContext * _studyContext
Definition: Yacsgui.hxx:86
YACS::HMI::GenericGui * _genericGui
Definition: Yacsgui.hxx:82

References _genericGui, _selectFromTree, _studyContext, _wrapper, and DEBTRACE.

◆ ~Yacsgui()

Yacsgui::~Yacsgui ( )
virtual

Definition at line 71 of file Yacsgui.cxx.

72{
73 if ( getApp() )
74 disconnect( getApp(), SIGNAL(studyClosed()), this, SLOT (onCleanOnExit()));
75 delete _wrapper;
76 delete _genericGui;
77}
void onCleanOnExit()
Definition: Yacsgui.cxx:366

References _genericGui, _wrapper, and onCleanOnExit().

Member Function Documentation

◆ activateModule

bool Yacsgui::activateModule ( SUIT_Study *  theStudy)
slot

Definition at line 154 of file Yacsgui.cxx.

155{
156 DEBTRACE("Yacsgui::activateModule");
157 bool bOk = SalomeApp_Module::activateModule( theStudy );
158
159 QMainWindow* parent = application()->desktop();
160 if(Resource::dockWidgetPriority)
161 {
162 parent->setCorner(Qt::TopLeftCorner, Qt::LeftDockWidgetArea);
163 parent->setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea);
164 parent->setCorner(Qt::TopRightCorner, Qt::RightDockWidgetArea);
165 parent->setCorner(Qt::BottomRightCorner, Qt::RightDockWidgetArea);
166 }
167 setMenuShown( true );
168 setToolShown( true );
170
171 // import Python module that manages YACS plugins (need to be here because SalomePyQt API uses active module)
172 PyGILState_STATE gstate = PyGILState_Ensure();
173 PyObject* pluginsmanager=PyImport_ImportModule((char*)"salome_pluginsmanager");
174 if(pluginsmanager==NULL)
175 PyErr_Print();
176 else
177 {
178 Py_ssize_t l = 12; // size of YACS_PLUGINS string
179 PyObject* result=PyObject_CallMethod( pluginsmanager, (char*)"initialize", (char*)"isss",1,"yacs","YACS",tr("YACS_PLUGINS").toStdString().c_str(),l);
180 if(result==NULL)
181 PyErr_Print();
182 Py_XDECREF(result);
183 }
184 Py_XDECREF(pluginsmanager);
185
186 PyGILState_Release(gstate);
187 // end of YACS plugins loading
188
189 if (_currentSVW)
191
192 return bOk;
193}
int Py_ssize_t
Definition: PythonNode.cxx:45
void showDockWidgets(bool isVisible)
Definition: GenericGui.cxx:983
void onWindowActivated(SUIT_ViewWindow *svw)
Definition: Yacsgui.cxx:256
SUIT_ViewWindow * _currentSVW
Definition: Yacsgui.hxx:85

References _currentSVW, _genericGui, DEBTRACE, testCppPluginInvokation::l, onWindowActivated(), and YACS::HMI::GenericGui::showDockWidgets().

Referenced by onWindowActivated().

◆ createDataModel()

CAM_DataModel * Yacsgui::createDataModel ( )
protectedvirtual

Reimplemented from SalomeWrap_Module.

Definition at line 304 of file Yacsgui.cxx.

305{
306 return new Yacsgui_DataModel(this);
307}

◆ createPreferences()

void Yacsgui::createPreferences ( )
virtual

Definition at line 345 of file Yacsgui.cxx.

346{
347 DEBTRACE("Yacsgui::createPreferences");
349}
virtual void createPreferences(Yacsgui *swm)
Yacsgui_Resource * _myresource
Definition: Yacsgui.hxx:84

References _myresource, Yacsgui_Resource::createPreferences(), and DEBTRACE.

◆ createSComponent()

bool Yacsgui::createSComponent ( )
protected

Definition at line 309 of file Yacsgui.cxx.

310{
311 DEBTRACE("Yacsgui::createSComponent");
312 _PTR(Study) aStudy = (( SalomeApp_Study* )(getApp()->activeStudy()))->studyDS();
313 _PTR(StudyBuilder) aBuilder (aStudy->NewBuilder());
314 _PTR(GenericAttribute) anAttr;
315 _PTR(AttributeName) aName;
316
317 // --- Find or create "YACS" SComponent in the study
318
319 _PTR(SComponent) aComponent = aStudy->FindComponent("YACS");
320 if ( !aComponent )
321 {
322 aComponent = aBuilder->NewComponent("YACS");
323 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributeName");
324 aName = _PTR(AttributeName) (anAttr);
325 aName->SetValue(getApp()->moduleTitle("YACS").toStdString());
326
327 anAttr = aBuilder->FindOrCreateAttribute(aComponent, "AttributePixMap");
328 _PTR(AttributePixMap) aPixmap(anAttr);
329 aPixmap->SetPixMap("ModuleYacs.png");
330
331 aBuilder->DefineComponentInstance(aComponent, engineIOR().toLatin1().constData());
332
333 return true;
334 }
335 return false;
336}
virtual QString engineIOR() const
Definition: Yacsgui.cxx:224

References DEBTRACE, and engineIOR().

Referenced by initialize().

◆ deactivateModule

bool Yacsgui::deactivateModule ( SUIT_Study *  theStudy)
slot

Definition at line 195 of file Yacsgui.cxx.

196{
197 DEBTRACE("Yacsgui::deactivateModule");
198
199 QMainWindow* parent = application()->desktop();
200 parent->setCorner(Qt::TopLeftCorner, Qt::TopDockWidgetArea);
201 parent->setCorner(Qt::BottomLeftCorner, Qt::BottomDockWidgetArea);
202 parent->setCorner(Qt::TopRightCorner, Qt::TopDockWidgetArea);
203 parent->setCorner(Qt::BottomRightCorner, Qt::BottomDockWidgetArea);
204
205 setMenuShown( false );
206 setToolShown( false );
208 QtGuiContext *context = QtGuiContext::getQtCurrent();
209 _studyContext = context;
210 DEBTRACE("_studyContext " << theStudy << " " << context);
211 return SalomeApp_Module::deactivateModule( theStudy );
212}

References _genericGui, _studyContext, DEBTRACE, and YACS::HMI::GenericGui::showDockWidgets().

◆ engineIOR()

QString Yacsgui::engineIOR ( ) const
virtual

Definition at line 224 of file Yacsgui.cxx.

225{
226 DEBTRACE("Yacsgui::engineIOR");
227 QString anEngineIOR = SalomeApp_Engine_i::EngineIORForComponent( "YACS", true ).c_str();
228 return anEngineIOR;
229}

References DEBTRACE.

Referenced by createSComponent().

◆ initialize()

void Yacsgui::initialize ( CAM_Application *  app)

Definition at line 79 of file Yacsgui.cxx.

80{
81 DEBTRACE("Yacsgui::initialize");
82 _currentSVW = 0;
83 SalomeApp_Module::initialize( app );
84
85 QWidget* aParent = application()->desktop();
86 DEBTRACE(app << " " << application() << " " << application()->desktop() << " " << aParent);
87
88 SUIT_ResourceMgr* aResourceMgr = app->resourceMgr();
89 setResource(aResourceMgr);
90
91 _wrapper = new SuitWrapper(this);
92 _genericGui = new GenericGui(_wrapper, app->desktop());
93
94 if ( app && app->desktop() )
95 {
96 connect( app->desktop(), SIGNAL( windowActivated( SUIT_ViewWindow* ) ),
97 this, SLOT(onWindowActivated( SUIT_ViewWindow* )) );
98
99 connect( getApp(),
100 SIGNAL(objectDoubleClicked( SUIT_DataObject* )),
101 this,
102 SLOT (onDblClick( SUIT_DataObject* )));
103
104 connect( getApp(),
105 SIGNAL(studyClosed()),
106 this,
107 SLOT (onCleanOnExit()));
108 }
112 _studyContext = QtGuiContext::getQtCurrent();
113
114 // VSR 23/10/2014: note that this is not a good way to create SComponent from this point
115 // as initialize() method can be potentially called when there's no yet open study;
116 // this is better to do in activateModule()
117 SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
118 if ( aStudy ) {
119 bool aLocked = (_PTR(AttributeStudyProperties)(aStudy->studyDS()->GetProperties()))->IsLocked();
120 if ( aLocked ) {
121 SUIT_MessageBox::warning ( app->desktop(), QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED") );
122 }
123 else {
124 if (createSComponent()) updateObjBrowser();
125 }
126 }
127
128 // Load SALOME module catalogs
129 QStringList appModules;
130 app->modules(appModules,false);
131 for ( QStringList::const_iterator it = appModules.begin(); it != appModules.end(); ++it )
132 {
133 QString aModule=*it;
134 QString modName = app->moduleName( aModule ); // module name
135 if ( modName.isEmpty() ) modName = aModule;
136 QString rootDir = QString( "%1_ROOT_DIR" ).arg( modName ); // module root dir variable
137 QString modDir = getenv( rootDir.toLatin1().constData() ); // module root dir
138 if ( !modDir.isEmpty() )
139 {
140 QStringList cataLst = QStringList() << modDir << "share" << "salome" << "resources" << modName.toLower() << modName+"SchemaCatalog.xml";
141 QString cataFile = cataLst.join( QDir::separator() ); // YACS module catalog
142 if ( QFile::exists( cataFile ) )
143 _genericGui->getCatalogWidget()->addCatalogFromFile(cataFile.toStdString());
144 }
145 }
146}
virtual bool addCatalogFromFile(std::string fileName)
CatalogWidget * getCatalogWidget()
Definition: GenericGui.hxx:77
viewer QGraphicsScene: deriver SUIT_ViewModel comme QxGraph_Viewer
Definition: SuitWrapper.hxx:43
void onDblClick(SUIT_DataObject *object)
Definition: Yacsgui.cxx:231
virtual void setResource(SUIT_ResourceMgr *r)
Definition: Yacsgui.cxx:338
bool createSComponent()
Definition: Yacsgui.cxx:309

References _currentSVW, _genericGui, _studyContext, _wrapper, YACS::HMI::CatalogWidget::addCatalogFromFile(), gui.Appli::app, YACS::HMI::GenericGui::createActions(), YACS::HMI::GenericGui::createMenus(), createSComponent(), YACS::HMI::GenericGui::createTools(), DEBTRACE, YACS::HMI::GenericGui::getCatalogWidget(), onCleanOnExit(), onDblClick(), onWindowActivated(), and setResource().

◆ loadSchema()

void Yacsgui::loadSchema ( const std::string &  filename,
bool  edit = true,
bool  arrangeLocalNodes = false 
)
virtual

Definition at line 361 of file Yacsgui.cxx.

362{
363 _genericGui->loadSchema(filename,edit,arrangeLocalNodes);
364}
virtual void loadSchema(const std::string &filename, bool edit=true, bool arrangeLocalNodes=false)

References _genericGui, and YACS::HMI::GenericGui::loadSchema().

◆ onCleanOnExit

void Yacsgui::onCleanOnExit ( )
slot

Definition at line 366 of file Yacsgui.cxx.

367{
368 if ( _genericGui )
370 _currentSVW = 0;
371}

References _currentSVW, _genericGui, and YACS::HMI::GenericGui::onCleanOnExit().

Referenced by initialize(), and ~Yacsgui().

◆ onDblClick

void Yacsgui::onDblClick ( SUIT_DataObject *  object)
slot

Definition at line 231 of file Yacsgui.cxx.

232{
233 DEBTRACE("Yacsgui::onDblClick");
234 DataObjectList dol =getApp()->objectBrowser()->getSelected();
235 if (dol.isEmpty()) return;
236
237 SalomeApp_DataObject* item = dynamic_cast<SalomeApp_DataObject*>(dol[0]);
238 if (!item) return;
239
240 DEBTRACE(item->name().toStdString());
241 SalomeWrap_DataModel *model = dynamic_cast<SalomeWrap_DataModel*>(dataModel());
242 if (!model) return;
243 DEBTRACE(item->entry().toStdString());
244 QWidget * viewWindow = model->getViewWindow(item->entry().toStdString());
245 if (!_genericGui) return;
246 if (!viewWindow) return;
247 DEBTRACE("--- " << viewWindow << " " << item->entry().toStdString());
248 if (getApp()->activeModule()->moduleName().compare("YACS") != 0)
249 getApp()->activateModule("YACS");
250
251 _selectFromTree = true;
252 viewWindow->setFocus();
253 _selectFromTree = false;
254}
QWidget * getViewWindow(std::string entry)

References _genericGui, _selectFromTree, DEBTRACE, and SalomeWrap_DataModel::getViewWindow().

Referenced by initialize().

◆ onTryClose

void Yacsgui::onTryClose ( bool &  isClosed,
QxScene_ViewWindow *  window 
)
protectedslot

Definition at line 297 of file Yacsgui.cxx.

298{
299 DEBTRACE("Yacsgui::onTryClose");
301 isClosed = _genericGui->closeContext(window);
302}
#define YASSERT(val)
YASSERT macro is always defined, used like assert, but throw a YACS::Exception instead of abort.
Definition: YacsTrace.hxx:59
bool closeContext(QWidget *view, bool onExit=false)
Definition: GenericGui.cxx:863

References _genericGui, YACS::HMI::GenericGui::closeContext(), DEBTRACE, and YASSERT.

Referenced by onWindowActivated().

◆ onWindowActivated

void Yacsgui::onWindowActivated ( SUIT_ViewWindow *  svw)
protectedslot

Definition at line 256 of file Yacsgui.cxx.

257{
258 DEBTRACE("Yacsgui::onWindowActivated");
259 QxScene_ViewWindow* viewWindow = dynamic_cast<QxScene_ViewWindow*>(svw);
260 _currentSVW = svw;
261 if (!viewWindow)
262 {
263 _currentSVW = 0; // switch to another module
264 return;
265 }
266 DEBTRACE("viewWindow " << viewWindow);
267 DEBTRACE("activeModule()->moduleName() " << (getApp()->activeModule() ? getApp()->activeModule()->moduleName().toStdString() : "") );
268 if (!getApp()->activeModule() || getApp()->activeModule()->moduleName() != "YACS")
269 if ( !getApp()->activateModule("YACS") ) return;
270
271 disconnect(viewWindow, SIGNAL( tryClose( bool&, QxScene_ViewWindow* ) ),
272 this, SLOT(onTryClose( bool&, QxScene_ViewWindow* )) );
273 disconnect(viewWindow->getViewManager(), SIGNAL( deleteView( SUIT_ViewWindow* ) ),
274 this, SLOT(onWindowClosed( SUIT_ViewWindow* )) );
275 connect(viewWindow, SIGNAL( tryClose( bool&, QxScene_ViewWindow* ) ),
276 this, SLOT(onTryClose( bool&, QxScene_ViewWindow* )) );
277 connect(viewWindow->getViewManager(), SIGNAL( deleteView( SUIT_ViewWindow* ) ),
278 this, SLOT(onWindowClosed( SUIT_ViewWindow* )) );
279
281 _genericGui->switchContext(viewWindow);
282 _studyContext = QtGuiContext::getQtCurrent();
283
284 if (_selectFromTree) return;
285 SalomeWrap_DataModel *model = dynamic_cast<SalomeWrap_DataModel*>(dataModel());
286 if (!model) return;
287 model->setSelected(svw);
288}
virtual void setSelected(QWidget *viewWindow)
void switchContext(QWidget *view, bool onExit=false)
Definition: GenericGui.cxx:824
void onWindowClosed(SUIT_ViewWindow *svw)
Definition: Yacsgui.cxx:290
void onTryClose(bool &isClosed, QxScene_ViewWindow *window)
Definition: Yacsgui.cxx:297
bool activateModule(SUIT_Study *theStudy)
Definition: Yacsgui.cxx:154

References _currentSVW, _genericGui, _selectFromTree, _studyContext, activateModule(), DEBTRACE, onTryClose(), onWindowClosed(), SalomeWrap_DataModel::setSelected(), YACS::HMI::GenericGui::switchContext(), and YASSERT.

Referenced by activateModule(), and initialize().

◆ onWindowClosed

void Yacsgui::onWindowClosed ( SUIT_ViewWindow *  svw)
protectedslot

Definition at line 290 of file Yacsgui.cxx.

291{
292 DEBTRACE("Yacsgui::onWindowClosed");
293 if ( svw && svw == _currentSVW )
294 _currentSVW = 0;
295}

References _currentSVW, and DEBTRACE.

Referenced by onWindowActivated().

◆ preferencesChanged()

void Yacsgui::preferencesChanged ( const QString &  sect,
const QString &  name 
)
virtual

Definition at line 351 of file Yacsgui.cxx.

352{
353 DEBTRACE("Yacsgui::preferencesChanged");
354 _myresource->preferencesChanged(sect, name);
355 if(name=="userCatalog")
356 {
357 _genericGui->getCatalogWidget()->addCatalogFromFile(Resource::userCatalog.toStdString());
358 }
359}
virtual void preferencesChanged(const QString &sect, const QString &name)

References _genericGui, _myresource, YACS::HMI::CatalogWidget::addCatalogFromFile(), DEBTRACE, YACS::HMI::GenericGui::getCatalogWidget(), and Yacsgui_Resource::preferencesChanged().

◆ setResource()

void Yacsgui::setResource ( SUIT_ResourceMgr *  r)
virtual

Definition at line 338 of file Yacsgui.cxx.

339{
340 DEBTRACE("Yacsgui::setResource");
343}
friend class Yacsgui_Resource
Definition: Yacsgui.hxx:50

References _myresource, DEBTRACE, Yacsgui_Resource::preferencesChanged(), testCppPluginInvokation::r, and Yacsgui_Resource.

Referenced by initialize().

◆ viewManagers()

void Yacsgui::viewManagers ( QStringList &  list) const
virtual

Definition at line 148 of file Yacsgui.cxx.

149{
150 DEBTRACE("Yacsgui::viewManagers");
151 list.append( QxScene_Viewer::Type() );
152}

References DEBTRACE.

◆ windows()

void Yacsgui::windows ( QMap< int, int > &  theMap) const

Definition at line 216 of file Yacsgui.cxx.

217{
218 DEBTRACE("Yacsgui::windows");
219 theMap.clear();
220 theMap.insert( SalomeApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
221 theMap.insert( SalomeApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
222}

References DEBTRACE.

Friends And Related Function Documentation

◆ Yacsgui_Resource

friend class Yacsgui_Resource
friend

Definition at line 50 of file Yacsgui.hxx.

Referenced by setResource().

Member Data Documentation

◆ _currentSVW

SUIT_ViewWindow* Yacsgui::_currentSVW
protected

◆ _genericGui

◆ _myresource

Yacsgui_Resource* Yacsgui::_myresource
protected

Definition at line 84 of file Yacsgui.hxx.

Referenced by createPreferences(), preferencesChanged(), and setResource().

◆ _selectFromTree

bool Yacsgui::_selectFromTree
protected

Definition at line 83 of file Yacsgui.hxx.

Referenced by onDblClick(), onWindowActivated(), and Yacsgui().

◆ _studyContext

YACS::HMI::QtGuiContext* Yacsgui::_studyContext
protected

Definition at line 86 of file Yacsgui.hxx.

Referenced by deactivateModule(), initialize(), onWindowActivated(), and Yacsgui().

◆ _wrapper

YACS::HMI::SuitWrapper* Yacsgui::_wrapper
protected

Definition at line 81 of file Yacsgui.hxx.

Referenced by initialize(), Yacsgui(), and ~Yacsgui().


The documentation for this class was generated from the following files: