//info = new SUPERVGUI_Information();
cursor = application()->desktop()->cursor();
+ fillInterfaceNameMap();
+
// ----- create actions --------------
createSupervAction( 301, "IMPORT" );
createSupervAction( 302, "EXPORT" );
buffer[0] = (int)VIEW_GRAPHSUPERV;
}*/
+void SUPERVGUI::fillInterfaceNameMap() {
+ //fill map: interface_name <-> component_name for all
+ //interfaces of all loaded components, it is necessary
+ //for correct adding factory nodes from AddComponent,
+ //SubComponent, MulComponent, etc. components.
+ myInterfaceNameMap.clear();
+
+ //get naming service
+ SALOME_NamingService* namingService = (( SalomeApp_Application* )application())->namingService();
+ //get module catalog
+ CORBA::Object_ptr obj = namingService->Resolve("/Kernel/ModulCatalog");
+ SALOME_ModuleCatalog::ModuleCatalog_var* aModuleCatalog = new SALOME_ModuleCatalog::ModuleCatalog_var;
+ *aModuleCatalog = SALOME_ModuleCatalog::ModuleCatalog::_narrow(obj);
+ if (!CORBA::is_nil(*aModuleCatalog)) {
+ //get component list
+ SALOME_ModuleCatalog::ListOfComponents_var aCompList = (*aModuleCatalog)->GetComponentList();
+ for (int ind1 = 0; ind1 < aCompList->length(); ind1++) {
+ //get component
+ SALOME_ModuleCatalog::Acomponent_ptr aComponent = (*aModuleCatalog)->GetComponent(aCompList[ind1]);
+ if ( aComponent != NULL ) {
+ //get interface list
+ SALOME_ModuleCatalog::ListOfInterfaces_var anIntList = aComponent->GetInterfaceList();
+ for (int ind2 = 0; ind2 < anIntList->length(); ind2++) {
+ const char* anIntName = anIntList[ind2];
+ myInterfaceNameMap.insert(QString(anIntName), QString(aComponent->componentname()));
+ }
+ }
+ }
+ }
+}
+
+QMap<QString, QString> SUPERVGUI::getInterfaceNameMap() const {
+ return myInterfaceNameMap;
+}
virtual void windows( QMap<int, int>& ) const;
+ QMap<QString, QString> getInterfaceNameMap() const;
+
signals:
void KillMainThread(bool theValue);
void createSupervAction( const int id, const QString& po_id, const QString& icon_id = QString(""),
const int key = 0, const bool toggle = false );
+ void fillInterfaceNameMap();
+
static int factory;
SUIT_Study* study;
SUPERV_Engine engine;
SUPERVGUI_Main* main; // active main
QPtrList<SUPERVGUI_Main> myGraphList;
+ QMap<QString, QString> myInterfaceNameMap;
};
#endif
if (item->isSelected()) {
const char* service = item->text(0).latin1();
const char* interface = item->parent()->text(0).latin1();
- const char* component = anApp->moduleName(item->parent()->parent()->text(0).latin1());
- SALOME_ModuleCatalog::Acomponent_ptr myComponent = (*aModuleCatalog)->GetComponent(component);
- if (myComponent==NULL) {
- QMessageBox::warning(aDesktop, tr("ERROR"), tr("MSG_CANT_CHOOSE_SERVICE"));
- }
- else {
- const SALOME_ModuleCatalog::Service* myService = myComponent->GetService(interface, service);
- SUPERV_CNode aNode;
- if ( myService->TypeOfNode == 0 ) { // ComputeNode
- aNode = aMain->getDataflow()->CNode(*myService);
- if (CORBA::is_nil( aNode ) ) {
- QMessageBox::warning(aDesktop, tr("ERROR"), tr("MSG_CANT_CREATE_NODE"));
- return;
- }
+ //const char* component = anApp->moduleName(item->parent()->parent()->text(0).latin1());
+ if ( aSupMod->getInterfaceNameMap().contains(item->parent()->text(0)) ) {
+ const char* component = aSupMod->getInterfaceNameMap().find(item->parent()->text(0)).data();
+
+ SALOME_ModuleCatalog::Acomponent_ptr myComponent = (*aModuleCatalog)->GetComponent(component);
+ if (myComponent==NULL) {
+ QMessageBox::warning(aDesktop, tr("ERROR"), tr("MSG_CANT_CHOOSE_SERVICE"));
}
- else { // Factory Node
- aNode = aMain->getDataflow()->FNode(component, interface, *myService);
- if ( CORBA::is_nil( aNode ) ) {
- QMessageBox::warning(aDesktop, tr("ERROR"), tr("MSG_CANT_CREATE_NODE"));
- return;
+ else {
+ const SALOME_ModuleCatalog::Service* myService = myComponent->GetService(interface, service);
+ SUPERV_CNode aNode;
+ if ( myService->TypeOfNode == 0 ) { // ComputeNode
+ aNode = aMain->getDataflow()->CNode(*myService);
+ if (CORBA::is_nil( aNode ) ) {
+ QMessageBox::warning(aDesktop, tr("ERROR"), tr("MSG_CANT_CREATE_NODE"));
+ return;
+ }
+ }
+ else { // Factory Node
+ aNode = aMain->getDataflow()->FNode(component, interface, *myService);
+ if ( CORBA::is_nil( aNode ) ) {
+ QMessageBox::warning(aDesktop, tr("ERROR"), tr("MSG_CANT_CREATE_NODE"));
+ return;
+ }
}
+ SUPERV::INode_var aDummyEndNode;
+ addNode( aNode, aDummyEndNode, myX, myY );
+ b = true;
}
- SUPERV::INode_var aDummyEndNode;
- addNode( aNode, aDummyEndNode, myX, myY );
- b = true;
- }
+ }
}
}
if ( !b ) {
SUPERVGUI_Main* aMain = aSupMod->getMain();
if ( !CORBA::is_nil( theNode ) && aMain ) {
-
+
aMain->Editing(); // PAL6170: GUI->Engine: setting "Editing" flag, why here? -> PAL7960
int cx, cy; //to appear a new node in the top-left corner of the current viewport
aMain->addControlNode( theNode, SUPERV::CNode::_narrow( theEndNode ), true );
else
aMain->addComputeNode( theNode );
- }
+ }
}