// Module : SALOME
// $Header$
-using namespace std;
#include "SALOMEGUI_Application.h"
#include "SALOMEGUI_Desktop.h"
#include "SALOMEGUI_ImportOperation.h"
+#include "SALOMEGUI.h"
#include "SALOME_Selection.h"
#include "SALOME_ListIO.hxx"
#include "SALOME_ListIteratorOfListIO.hxx"
#include "QAD_Resource.h"
#include "QAD_Tools.h"
#include "QAD_WaitCursor.h"
+#include "QAD_MessageBox.h"
// QT Includes
#include <qapplication.h>
// Open CASCADE Include
#include <Standard_Failure.hxx>
#include <TCollection_AsciiString.hxx>
+using namespace std;
/*!
Constructor
}
QAD_StudyFrame* sf = myActiveStudy->getActiveStudyFrame();
- Standard_CString name = strdup(sf->title().latin1());
+ Standard_CString name = CORBA::string_dup(sf->title().latin1());
SALOMEDS::SComponent_var father = aStudy->FindComponent("Interface Applicative");
SALOMEDS::SObject_var newObj = B->NewObject(father);
return;
}
- // Obtain the component's GUI library
- // Library cashing will be implemented soon in QAD_Desktop to increase performance
- OSD_Function osdF, osdViewTypeFunc;
- OSD_SharedLibrary foreignGUI;
- void (*builder)(const Handle(SALOME_InteractiveObject)&);
- bool isForeignGUIUsed = false;
bool isViewTypeOK = true;
int viewTypes[VIEW_TYPE_MAX];
for (int i = 0; i < VIEW_TYPE_MAX; i++)
viewTypes[i] = -1;
- if (parentComp.compare(desktop->getActiveComponent()) == 0) { // use active GUI library
- const OSD_SharedLibrary& compGUI = desktop->getHandle();
- osdF = compGUI.DlSymb("buildPresentation");
- if ( osdF == NULL ) {
- MESSAGE("BuildPresentation method not found in component's GUI")
- return;
- }
- osdViewTypeFunc = compGUI.DlSymb("supportedViewType");
- if ( osdViewTypeFunc == NULL ) {
- MESSAGE("supportedViewType method not found in component's GUI")
- }
- MESSAGE("onDisplay(): using active GUI to build presentations")
- } else { // use native GUI library
- QString ComponentLib;
- QCString dir;
- QFileInfo fileInfo ;
- bool found = false;
- if ( getenv("SALOME_SITE_DIR") ) {
- dir.fill('\0');
- dir.sprintf("%s",getenv("SALOME_SITE_DIR"));
- dir = QAD_Tools::addSlash(dir) ;
- dir = dir + "lib" ;
- dir = QAD_Tools::addSlash(dir) ;
-#ifdef WNT
- dir = dir + "lib" + parentComp.latin1() + "GUI.dll" ;
-#else
- dir = dir + "lib" + parentComp.latin1() + "GUI.so" ;
-#endif
- MESSAGE ( " GUI library = " << dir )
- fileInfo.setFile(dir) ;
- if (fileInfo.exists()) {
- ComponentLib = fileInfo.fileName();
- found = true;
- MESSAGE ( " found " )
- } else {
- MESSAGE ( " Not found " )
- }
- }
- if ( !found && getenv("SALOME_ROOT_DIR") ) {
- dir.fill('\0');
- dir.sprintf("%s", getenv("SALOME_ROOT_DIR"));
- dir = QAD_Tools::addSlash(dir) ;
- dir = dir + "lib" ;
- dir = QAD_Tools::addSlash(dir) ;
-#ifdef WNT
- dir = dir + "lib" + parentComp.latin1() + "GUI.dll" ;
-#else
- dir = dir + "lib" + parentComp.latin1() + "GUI.so" ;
-#endif
- MESSAGE ( " GUI library = " << dir )
- fileInfo.setFile(dir) ;
- if (fileInfo.exists()) {
- ComponentLib = fileInfo.fileName() ;
- found = true;
- MESSAGE ( " found " )
- } else {
- MESSAGE ( " Not found " )
- }
- }
- if ( !found && getenv( parentComp + "_ROOT_DIR") ) {
- dir.fill('\0');
- dir.sprintf("%s", getenv(parentComp + "_ROOT_DIR"));
- dir = QAD_Tools::addSlash(dir) ;
- dir = dir + "lib" ;
- dir = QAD_Tools::addSlash(dir) ;
- dir = dir + "salome" ;
- dir = QAD_Tools::addSlash(dir) ;
-#ifdef WNT
- dir = dir + "lib" + parentComp.latin1() + "GUI.dll" ;
-#else
- dir = dir + "lib" + parentComp.latin1() + "GUI.so" ;
-#endif
- MESSAGE ( " GUI library = " << dir )
- fileInfo.setFile(dir) ;
- if (fileInfo.exists()) {
- ComponentLib = fileInfo.fileName() ;
- found = true;
- MESSAGE ( " found " )
- } else {
- MESSAGE ( " Not found " )
- }
- }
-
- if (ComponentLib.isEmpty()) {
- waitCursor.stop();
- QMessageBox::critical( desktop,
- tr("ERR_ERROR"),
- "Empty name of component "+ parentComp + " library");
- return;
- }
-
- foreignGUI.SetName(TCollection_AsciiString((char*)ComponentLib.latin1()).ToCString());
-
- bool ok = foreignGUI.DlOpen(OSD_RTLD_LAZY);
- if (!ok) {
- waitCursor.stop();
- QMessageBox::critical( desktop,
- tr("ERR_ERROR"),
- tr( foreignGUI.DlError() ) );
- return;
- }
-
- osdF = foreignGUI.DlSymb("buildPresentation");
- if ( osdF == NULL ) {
- MESSAGE("BuildPresentation method not found in component's GUI")
- foreignGUI.DlClose();
- return;
- }
- osdViewTypeFunc = foreignGUI.DlSymb("supportedViewType");
- if ( osdViewTypeFunc == NULL ) {
- MESSAGE("supportedViewType method not found in component's GUI")
- }
- isForeignGUIUsed = true;
- MESSAGE("onDisplay(): using parent component's GUI to build presentations")
- }
+ // Obtain the component's GUI
+ SALOMEGUI* aGUI = desktop->getComponentGUI( parentComp );
+ if ( !aGUI )
+ return;
// Check if another view type is required (if viewToActivate < 0 then any type of view is acceptable)
- if (osdViewTypeFunc) {
- void (*viewTypeChecker)(int*, int) = (void (*)(int*, int)) osdViewTypeFunc;
- (*viewTypeChecker)(viewTypes, VIEW_TYPE_MAX);
- if (viewTypes[0] >= 0) { // not all the view types are supported
- for (int i = 0; i < VIEW_TYPE_MAX; i++) {
- if (viewTypes[i] < 0) // no more types supported
- break;
- isViewTypeOK = ((int)myActiveStudy->getActiveStudyFrame()->getTypeView() == viewTypes[i]);
- if (isViewTypeOK) // one of supported views is already active
- break;
- }
+ aGUI->SupportedViewType(viewTypes, VIEW_TYPE_MAX);
+ if (viewTypes[0] >= 0) { // not all the view types are supported
+ for (int i = 0; i < VIEW_TYPE_MAX; i++) {
+ if (viewTypes[i] < 0) // no more types supported
+ break;
+ isViewTypeOK = ((int)myActiveStudy->getActiveStudyFrame()->getTypeView() == viewTypes[i]);
+ if (isViewTypeOK) // one of supported views is already active
+ break;
}
}
QAD_ViewFrame* viewFrame = myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame();
+ // Ensure that parent component's data are loaded
+ QString compName = desktop->getComponentName( parentComp );
+ if ( compName.isEmpty() ) {
+ waitCursor.stop();
+ QAD_MessageBox::error1( desktop,
+ tr("ERR_ERROR"),
+ tr("ERR_EMPTY_COMP_NAME").arg( parentComp ),
+ tr("BUT_OK"));
+ return;
+ }
+
+ desktop->loadComponentData( compName );
+
// Build the graphic presentation (it is stored in the corresponding viewer)
- builder = (void (*) (const Handle(SALOME_InteractiveObject)&)) osdF;
+
+ bool isComponent = false;
+ SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
+ bool needRepaint = false;
// Copy the selection
SALOME_ListIteratorOfListIO itInit( Sel->StoredIObjects() );
SALOME_ListIO selList;
for (; itInit.More(); itInit.Next()) {
- selList.Append(itInit.Value());
+ Handle(SALOME_InteractiveObject) IObject = itInit.Value();
+ if ( IObject->hasEntry() ) {
+ // check whether the component is selected
+ SALOMEDS::SObject_var obj = aStudy->FindObjectID(IObject->getEntry() );
+ if ( !obj->_is_nil() && strcmp( obj->GetFatherComponent()->GetID(), obj->GetID() ) == 0 ) {
+ selList.Clear();
+ isComponent = true;
+ selList.Append( IObject );
+ break;
+ }
+ }
+ selList.Append( IObject );
}
-
- SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument();
- bool needRepaint = false;
-
if (id == QAD_DisplayOnly_Popup_ID)
viewFrame->EraseAll();
- SALOME_ListIteratorOfListIO It( selList );
- for(;It.More();It.Next()) {
- Handle(SALOME_InteractiveObject) IObject = It.Value();
-
- // First check whether the object is a component or a child object
- bool isComponent = false;
-
- if (!IObject->hasEntry()) continue;
-
- SALOMEDS::SObject_var obj = aStudy->FindObjectID(IObject->getEntry());
- if (!obj->_is_nil()) {
- SALOMEDS::SComponent_var comp = obj->GetFatherComponent();
- isComponent = (strcmp(comp->GetID(), obj->GetID()) == 0);
- }
-
- // For component -> display all children
- if (isComponent) {
- SALOMEDS::ChildIterator_ptr it = aStudy->NewChildIterator(obj);
- it->InitEx(true);
- for ( ; it->More(); it->Next()) {
- SALOMEDS::SObject_ptr child = it->Value();
+ // For component -> display all children
+ if ( isComponent ) {
+ SALOMEDS::SObject_var obj = aStudy->FindObjectID( selList.First()->getEntry() );
+ SALOMEDS::ChildIterator_ptr It = aStudy->NewChildIterator( obj );
+ It->InitEx( true );
+ for ( ; It->More(); It->Next() ) {
+ SALOMEDS::SObject_ptr child = It->Value();
+ SALOMEDS::SObject_ptr ref;
+ if ( !child->ReferencedObject( ref ) ) {
Handle(SALOME_InteractiveObject) childIObject = new SALOME_InteractiveObject();
- childIObject->setEntry(child->GetID());
-
+ childIObject->setEntry( child->GetID() );
// Ensure that proper 3D presentation exists for IObject
- (*builder)(childIObject);
+ aGUI->BuildPresentation(childIObject);
viewFrame->Display(childIObject, false);
needRepaint = true;
}
- } else { // for child object -> simply display it (no children are displayed)
+ }
+ }
+ else { // for child object -> simply display it (no children are displayed)
+ SALOME_ListIteratorOfListIO It( selList );
+ for( ;It.More();It.Next() ) {
+ Handle(SALOME_InteractiveObject) IObject = It.Value();
// Ensure that proper 3D presentation exists for IObject
- (*builder)(IObject);
+ aGUI->BuildPresentation(IObject);
viewFrame->Display(IObject, false);
needRepaint = true;
}
-
}
- if (needRepaint)
+ if ( needRepaint )
viewFrame->Repaint();
- if (isForeignGUIUsed)
- foreignGUI.DlClose();
myActiveStudy->updateObjBrowser(true);
}