#include <Config_Common.h>
#include <Config_FeatureMessage.h>
#include <Config_PointerMessage.h>
+#include <Config_ModuleReader.h>
#include <QApplication>
#include <QFileDialog>
myDisplayer = new XGUI_Displayer(this);
mySelector = new XGUI_SelectionMgr(this);
- connect(mySelector, SIGNAL(selectionChanged()), this, SLOT(changeCurrentDocument()));
myOperationMgr = new XGUI_OperationMgr(this);
myActionsMgr = new XGUI_ActionsMgr(this);
return;
}
// Remember features icons
- myIcons[QString(theMessage->id().c_str())] = QString(theMessage->icon().c_str());
+ myIcons[QString::fromStdString(theMessage->id())] = QString::fromStdString(theMessage->icon());
//Find or create Workbench
QString aWchName = QString::fromStdString(theMessage->workbenchId());
}
//show file dialog, check if readable and open
- myCurrentFile = QFileDialog::getOpenFileName(mainWindow());
+ myCurrentFile = QFileDialog::getExistingDirectory(mainWindow());
if(myCurrentFile.isEmpty())
return;
QFileInfo aFileInfo(myCurrentFile);
CREATE_FUNC crtInst = 0;
#ifdef WIN32
-
HINSTANCE modLib = ::LoadLibrary((LPTSTR) qPrintable(libName));
if (!modLib) {
LPVOID lpMsgBuf;
}
#else
void* modLib = dlopen( libName.toLatin1(), RTLD_LAZY );
- if ( !modLib )
- err = QString( "Can not load library %1. %2" ).arg( libName ).arg( dlerror() );
- else
- {
+ if ( !modLib ) {
+ err = QString( "Can not load library %1. %2" ).arg( libName ).arg( dlerror() );
+ } else {
crtInst = (CREATE_FUNC)dlsym( modLib, CREATE_MODULE );
- if ( !crtInst )
- err = QString( "Failed to find function %1. %2" ).arg( CREATE_MODULE ).arg( dlerror() );
+ if ( !crtInst ) {
+ err = QString( "Failed to find function %1. %2" ).arg( CREATE_MODULE ).arg( dlerror() );
+ }
}
#endif
XGUI_Module* aModule = crtInst ? crtInst(this) : 0;
if (!err.isEmpty()) {
- if (mainWindow() && mainWindow()->isVisible())
+ if (mainWindow()) {
QMessageBox::warning(mainWindow(), tr("Error"), err);
- else
+ } else {
qWarning( qPrintable( err ));
+ }
}
return aModule;
}
//******************************************************
bool XGUI_Workshop::activateModule()
{
- myPartSetModule = loadModule("PartSet");
+ Config_ModuleReader aModuleReader;
+ QString moduleName = QString::fromStdString(aModuleReader.getModuleName());
+ myPartSetModule = loadModule(moduleName);
if (!myPartSetModule)
return false;
myPartSetModule->createFeatures();
aObjDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
aObjDock->setWindowTitle(tr("Object browser"));
myObjectBrowser = new XGUI_ObjectsBrowser(aObjDock);
+ connect(myObjectBrowser, SIGNAL(activePartChanged(FeaturePtr)), this, SLOT(changeCurrentDocument(FeaturePtr)));
aObjDock->setWidget(myObjectBrowser);
return aObjDock;
}
}
//******************************************************
-void XGUI_Workshop::changeCurrentDocument()
+void XGUI_Workshop::changeCurrentDocument(FeaturePtr thePart)
{
- QFeatureList aFeatures = objectBrowser()->selectedFeatures();
-
- // Set current document
- if (aFeatures.size() > 0) {
- FeaturePtr aFeature = aFeatures.first();
-
- boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
- boost::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = aFeature->data()->docRef("PartDocument");
+ boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
+ if (thePart) {
+ boost::shared_ptr<ModelAPI_AttributeDocRef> aDocRef = thePart->data()->docRef("PartDocument");
if (aDocRef)
aMgr->setCurrentDocument(aDocRef->value());
+ } else {
+ aMgr->setCurrentDocument(aMgr->rootDocument());
}
}