// MULTIPR Includes
#include "MULTIPR_GUI.h"
#include "MULTIPR_GUI_Dlg.h"
+#include "MULTIPR_Utils.hxx"
// Salome Includes
#include <SUIT_MessageBox.h>
#include <qimage.h>
#include <qpixmap.h>
#include <qmessagebox.h>
+#include <qaction.h>
+#include <stdexcept>
+
using namespace std;
}
+//*****************************************************************************
+// Global function
+//*****************************************************************************
+
+// singleton
+MULTIPR_ORB::MULTIPR_Gen_ptr GetMultiprGen(const CAM_Module* theModule)
+{
+ static MULTIPR_ORB::MULTIPR_Gen_ptr aGen = NULL;
+
+ if (!aGen)
+ {
+ SALOME_LifeCycleCORBA aLCC(SalomeApp_Application::namingService());
+ Engines::Component_var aComponent = aLCC.FindOrLoad_Component("FactoryServer", "MULTIPR");
+ aGen = MULTIPR_ORB::MULTIPR_Gen::_narrow(aComponent);
+ if (!CORBA::is_nil(aGen))
+ {
+ //aGen->SetCurrentStudy(GetDSStudy(GetCStudy(GetAppStudy(theModule))));
+ }
+ }
+
+ if (CORBA::is_nil(aGen))
+ throw std::runtime_error("Can't find MULTIPR component");
+
+ return aGen;
+}
+
+
//*****************************************************************************
// Class MULTIPR_GUI implementation
//*****************************************************************************
}
-MULTIPR_ORB::MULTIPR_Obj_ptr MULTIPR_GUI::getMULTIPRObj()
+MULTIPR_GUI::~MULTIPR_GUI()
{
- return mMULTIPRObj;
+ if (mMULTIPRObj != NULL)
+ {
+ CORBA::release(mMULTIPRObj);
+ }
}
-SalomeApp_Application* MULTIPR_GUI::getAppli() const
+MULTIPR_ORB::MULTIPR_Obj_ptr MULTIPR_GUI::getMULTIPRObj()
{
- return getApp();
+ return mMULTIPRObj;
}
-MULTIPR_ORB::MULTIPR_Gen_ptr MULTIPR_GUI::InitMULTIPRGen(SalomeApp_Application* app)
+SalomeApp_Application* MULTIPR_GUI::getAppli() const
{
- Engines::Component_var comp = app->lcc()->FindOrLoad_Component("FactoryServer", "MULTIPR");
- MULTIPR_ORB::MULTIPR_Gen_ptr clr = MULTIPR_ORB::MULTIPR_Gen::_narrow(comp);
- ASSERT(!CORBA::is_nil(clr));
- return clr;
+ return getApp();
}
{
SalomeApp_Module::initialize(app);
- InitMULTIPRGen(dynamic_cast<SalomeApp_Application*>(app));
+ GetMultiprGen(this);
QWidget* aParent = app->desktop();
SUIT_ResourceMgr* aResourceMgr = app->resourceMgr();
QString MULTIPR_GUI::engineIOR() const
{
- CORBA::String_var anIOR = getApp()->orb()->object_to_string(InitMULTIPRGen(getApp()));
+ CORBA::String_var anIOR = getApp()->orb()->object_to_string(GetMultiprGen(this));
return QString(anIOR.in());
}
setMenuShown(true);
setToolShown(true);
+ action(ACTION_IMPORT_MED)->setAccel(QKeySequence(CTRL + Key_I));
+
return bOk;
}
setMenuShown(false);
setToolShown(false);
+ // Unset actions accelerator keys
+ action(ACTION_IMPORT_MED)->setAccel(QKeySequence());
+
return SalomeApp_Module::deactivateModule(theStudy);
}
-
+
void MULTIPR_GUI::windows(QMap<int, int>& theMap) const
{
theMap.clear();
SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg(
this->application()->desktop(),
true,
- tr("MULTIPR_USE_BUILD_PROGRESS") );
+ tr("") );
fd->setCaption(tr("MULTIPR_MEN_IMPORT_FROM_MED_FILE"));
fd->setFilters(aFilter);
- fd->exec();
+ if (fd->exec() == QDialog::Rejected)
+ {
+ delete fd;
+ return;
+ }
+
QFileInfo aFileInfo(fd->selectedFile());
delete fd;
try
{
- MULTIPR_ORB::MULTIPR_Gen_ptr multiprgen = MULTIPR_GUI::InitMULTIPRGen(getApp());
+ MULTIPR_ORB::MULTIPR_Gen_ptr multiprgen = GetMultiprGen(this);
mMULTIPRObj = multiprgen->getObject(mMEDFileName.latin1());
}
catch(...)
getApp()->desktop(),
"Import MED file error",
"Invalid MED file (not recognized by MULTIPR)",
- tr("MULTIPR_OK") );
+ tr("MULTIPR_BUT_OK") );
}
QApplication::restoreOverrideCursor();
getApp()->desktop(),
"Split warning",
"No parts selected",
- tr("MULTIPR_OK") );
+ tr("MULTIPR_BUT_OK") );
return;
}
getApp()->desktop(),
"Decimation warning",
"No parts selected",
- tr("MULTIPR_OK") );
+ tr("MULTIPR_BUT_OK") );
return;
}
getApp()->desktop(),
"Remove warning",
"No parts selected",
- tr("MULTIPR_OK") );
+ tr("MULTIPR_BUT_OK") );
return;
}
getApp()->desktop(),
"Remove error",
"Error while removing selected part(s)",
- tr("MULTIPR_OK") );
+ tr("MULTIPR_BUT_OK") );
}
QApplication::restoreOverrideCursor();
{
return;
}
-
+
+ SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg(
+ this->application()->desktop(),
+ true,
+ tr("") );
+
+ fd->setCaption(tr("Save distributed MED file - Destination directory"));
+ fd->setMode(QFileDialog::DirectoryOnly);
+
+ if (fd->exec() == QDialog::Rejected)
+ {
+ delete fd;
+ return;
+ }
+
+ QFileInfo aFileInfo(fd->selectedFile());
+ delete fd;
+
+ QString path = aFileInfo.filePath();
+
QApplication::setOverrideCursor(Qt::waitCursor);
try
{
- mMULTIPRObj->save();
+ mMULTIPRObj->save(path);
getApp()->updateObjectBrowser();
}
catch(...)
getApp()->desktop(),
"Save distributed MED file error",
"Error while writing distributed MED file",
- tr("MULTIPR_OK") );
+ tr("MULTIPR_BUT_OK") );
}
QApplication::restoreOverrideCursor();
getApp()->desktop(),
"Remove error",
"Error while removing previous results",
- tr("OK") );
+ tr("MULTIPR_BUT_OK") );
}
QApplication::restoreOverrideCursor();
lPath,
lMEDFileName);
- if (ret != 5) return;
+ if (ret != 5)
+ {
+ cout << "MULTIPR: build() tree; error while parsing part info" << endl;
+ std::runtime_error("MULTIPR: build() tree; error while parsing part info");
+ return;
+ }
MULTIPR_GUI_DataObject_Mesh* dataObjectMesh = new MULTIPR_GUI_DataObject_Mesh(modelRoot, lMeshName);
if (ret != 5) return;
- //cout << "Part : " << lPartName << endl;
if ((strstr(lPartName,"_MED") != NULL) || (strstr(lPartName,"_LOW") != NULL))
{
- //cout << "Found MED/LOW" << endl;
new MULTIPR_GUI_DataObject_Resolution(dataObjectPart_prev, strItem, strPartInfo);
}
else