-// Project MULTIPR, IOLS WP1.2.1 - EDF/CS
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+
// Partitioning/decimation module for the SALOME v3.2 platform
/**
* \brief see MULTIPR_GUI.h
*
* \author Olivier LE ROUX - CS, Virtual Reality Dpt
- *
+ *
* \date 01/2007
*/
-
+
//*****************************************************************************
// Includes section
//*****************************************************************************
if (myIsError) {
SUIT_MessageBox::critical((QWidget*) MULTIPR_GUI::desktop(),
QObject::tr("SAVE_DISTMED_ERROR"),
-// QString("Save distributed MED file error"),
+// QString("Save distributed MED file error"),
QObject::tr("WRIT_DISTMED_ERROR"));
// QString("Error while writing distributed MED file"));
}
if (!aGen)
{
SALOME_LifeCycleCORBA aLCC (SalomeApp_Application::namingService());
- Engines::Component_var comp = app->lcc()->FindOrLoad_Component( "FactoryServer","MULTIPR" );
+ Engines::EngineComponent_var comp = app->lcc()->FindOrLoad_Component( "FactoryServer","MULTIPR" );
aGen = MULTIPR_ORB::MULTIPR_Gen::_narrow(comp);
if (!CORBA::is_nil(aGen))
{
void MULTIPR_GUI::initialize(CAM_Application* app)
{
SalomeApp_Module::initialize(app);
-
+
GetMultiprGen(dynamic_cast<SalomeApp_Application*>( app ));
-
+
QWidget* aParent = (QWidget*) application()->desktop();
SUIT_ResourceMgr* aResourceMgr = app->resourceMgr();
-
+
//-------------------------------------------------------------------------
// create actions
- //-------------------------------------------------------------------------
+ //-------------------------------------------------------------------------
QPixmap aPixmapImportFromMEDFile = aResourceMgr->loadPixmap("MULTIPR", tr("MULTIPR_ICON_IMPORT_MED"));
-
- createAction(
- ACTION_IMPORT_MED,
- tr("MULTIPR_TLT_IMPORT_FROM_MED_FILE"),
- QIcon(aPixmapImportFromMEDFile),
- tr("MULTIPR_MEN_IMPORT_FROM_MED_FILE"),
- tr("MULTIPR_STS_IMPORT_FROM_MED_FILE"),
+
+ createAction(
+ ACTION_IMPORT_MED,
+ tr("MULTIPR_TLT_IMPORT_FROM_MED_FILE"),
+ QIcon(aPixmapImportFromMEDFile),
+ tr("MULTIPR_MEN_IMPORT_FROM_MED_FILE"),
+ tr("MULTIPR_STS_IMPORT_FROM_MED_FILE"),
(Qt::CTRL + Qt::Key_I),
- aParent,
+ aParent,
false,
- this,
+ this,
SLOT(OnImportFromMEDFile()));
-
- createAction(
- ACTION_SPLIT,
- tr("MULTIPR_TLT_SPLIT"),
- QIcon(),
- tr("MULTIPR_MEN_SPLIT"),
- tr("MULTIPR_STS_SPLIT"),
+
+ createAction(
+ ACTION_SPLIT,
+ tr("MULTIPR_TLT_SPLIT"),
+ QIcon(),
+ tr("MULTIPR_MEN_SPLIT"),
+ tr("MULTIPR_STS_SPLIT"),
0,
- aParent,
+ aParent,
false,
- this,
+ this,
SLOT(OnPartition2()));
-
- createAction(
- ACTION_DECIMATE,
- tr("MULTIPR_TLT_DECIMATE"),
- QIcon(),
- tr("MULTIPR_MEN_DECIMATE"),
- tr("MULTIPR_STS_DECIMATE"),
+
+ createAction(
+ ACTION_DECIMATE,
+ tr("MULTIPR_TLT_DECIMATE"),
+ QIcon(),
+ tr("MULTIPR_MEN_DECIMATE"),
+ tr("MULTIPR_STS_DECIMATE"),
0,
- aParent,
+ aParent,
false,
- this,
+ this,
SLOT(OnDecimate()));
-
- createAction(
- ACTION_REMOVE,
- tr("MULTIPR_TLT_REMOVE"),
- QIcon(),
- tr("MULTIPR_MEN_REMOVE"),
- tr("MULTIPR_STS_REMOVE"),
+
+ createAction(
+ ACTION_REMOVE,
+ tr("MULTIPR_TLT_REMOVE"),
+ QIcon(),
+ tr("MULTIPR_MEN_REMOVE"),
+ tr("MULTIPR_STS_REMOVE"),
0,
- aParent,
+ aParent,
false,
- this,
+ this,
SLOT(OnRemove()));
-
+
QPixmap aPixmapSaveMEDFile = aResourceMgr->loadPixmap("MULTIPR", tr("MULTIPR_ICON_SAVE_MED"));
-
- createAction(
- ACTION_SAVE,
- tr("MULTIPR_TLT_SAVE"),
- QIcon(aPixmapSaveMEDFile),
- tr("MULTIPR_MEN_SAVE"),
- tr("MULTIPR_STS_SAVE"),
+
+ createAction(
+ ACTION_SAVE,
+ tr("MULTIPR_TLT_SAVE"),
+ QIcon(aPixmapSaveMEDFile),
+ tr("MULTIPR_MEN_SAVE"),
+ tr("MULTIPR_STS_SAVE"),
0,
- aParent,
+ aParent,
false,
- this,
+ this,
SLOT(OnSave()));
-
+
//-------------------------------------------------------------------------
// create menus
//-------------------------------------------------------------------------
createMenu(separator(), aMenuId, -1, 10);
aMenuId = createMenu(tr("MULTIPR_MEN_FILE_MULTIPR"), aMenuId, -1, 10);
createMenu(ACTION_IMPORT_MED, aMenuId);
-
+
aMenuId = createMenu(tr("MULTIPR_MEN_MULTIPR"), -1, -1, 30);
createMenu(ACTION_IMPORT_MED, aMenuId, 10);
createMenu(ACTION_SAVE, aMenuId, 10);
createMenu(ACTION_SPLIT, aMenuId, 10);
createMenu(ACTION_DECIMATE, aMenuId, 10);
createMenu(ACTION_REMOVE, aMenuId, 10);
-
+
//-------------------------------------------------------------------------
// create toolbars
//-------------------------------------------------------------------------
int aToolId = createTool(tr("MULTIPR_TOOL_MULTIPR"));
createTool(ACTION_IMPORT_MED, aToolId);
createTool(ACTION_SAVE, aToolId);
-
+
//-------------------------------------------------------------------------
// create popup menus
//-------------------------------------------------------------------------
mgr->insert( action(ACTION_DECIMATE), -1, -1, -1 );
mgr->insert( action(ACTION_REMOVE), -1, -1, -1 );
mgr->insert( action(ACTION_SAVE), -1, -1, -1 );
-
+
QString aRule = "client='ObjectBrowser' and selcount>=1"; // $type in {'VISU::TMESH'}";
mgr->setRule(action(ACTION_SPLIT), aRule);
mgr->setRule(action(ACTION_DECIMATE), aRule);
mgr->setRule(action(ACTION_REMOVE), aRule);
mgr->setRule(action(ACTION_SAVE), aRule);
-
+
//-------------------------------------------------------------------------
// set progress dialog
//-------------------------------------------------------------------------
//MULTIPR_GUI_ProgressCallbackDlg* progressDlg =
// new MULTIPR_GUI_ProgressCallbackDlg(application()->desktop());
//multipr::gProgressCallback = progressDlg;
-
+
//MULTIPR_GUI_EmptyMeshCallbackDlg* emptyMeshDlg =
// new MULTIPR_GUI_EmptyMeshCallbackDlg(application()->desktop());
//multipr::gEmptyMeshCallback = emptyMeshDlg;
void MULTIPR_GUI::selected(QStringList& entries, const bool multiple)
{
LightApp_SelectionMgr* mgr = getApp()->selectionMgr();
-
+
if(!mgr) return;
-
+
SUIT_DataOwnerPtrList anOwnersList;
mgr->selected(anOwnersList);
-
+
for (int i = 0 ; i < anOwnersList.size() ; i++)
{
const LightApp_DataOwner* owner = dynamic_cast<const LightApp_DataOwner*>(anOwnersList[i].get());
-
+
if (!entries.contains(owner->entry()))
{
entries.append(owner->entry());
}
-
+
if (!multiple)
break;
}
QStringList aFilter;
aFilter.append(tr("MULTIPR_FLT_MED_FILES"));
aFilter.append(tr("MULTIPR_FLT_ALL_FILES"));
-
+
SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg(
- (QWidget*) MULTIPR_GUI::desktop(),
- true,
+ (QWidget*) MULTIPR_GUI::desktop(),
+ true,
tr("") );
-
+
fd->setWindowTitle(tr("MULTIPR_MEN_IMPORT_FROM_MED_FILE"));
fd->setFilters(aFilter);
if (fd->exec() == QDialog::Rejected)
delete fd;
return;
}
-
+
QFileInfo aFileInfo(fd->selectedFile());
delete fd;
-
+
// Check the file name
if (!aFileInfo.exists())
return;
}
catch(...)
{
- SUIT_MessageBox::critical(
+ SUIT_MessageBox::critical(
(QWidget*) MULTIPR_GUI::desktop(),
- QObject::tr("IMPORT_MED_ERROR"),
-// "Import MED file error",
+ QObject::tr("IMPORT_MED_ERROR"),
+// "Import MED file error",
QObject::tr("INVALID_MED_FILE"));
-// "Invalid MED file (not recognized by MULTIPR)");
+// "Invalid MED file (not recognized by MULTIPR)");
}
QApplication::restoreOverrideCursor();
-
+
//if (mMULTIPRObj != NULL)
if (!CORBA::is_nil(mMULTIPRObj))
{
{
return;
}
-
- // do the partition.
+
+ // do the partition.
MULTIPR_GUI_Partition1Dlg* dialog = new MULTIPR_GUI_Partition1Dlg(this);
dialog->exec();
delete dialog;
// Now we need to save the file.
SalomeApp_CheckFileDlg* fd = new SalomeApp_CheckFileDlg(
- (QWidget*) MULTIPR_GUI::desktop(),
- true,
+ (QWidget*) MULTIPR_GUI::desktop(),
+ true,
tr("") );
-
+
fd->setWindowTitle(tr("Save distributed MED file - Destination directory"));
fd->setFileMode(QFileDialog::DirectoryOnly);
-
+
if (fd->exec() == QDialog::Rejected)
{
delete fd;
getApp()->updateObjectBrowser();
return;
}
-
+
QFileInfo aFileInfo(fd->selectedFile());
delete fd;
-
+
QString path = aFileInfo.filePath();
-
+
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
mMULTIPRObj->resetSaveProgress();
MULTIPR_GUI_SaveThread* a = new MULTIPR_GUI_SaveThread (this, mMULTIPRObj, path);
a->start();
-
+
// save progress
//mProgress = new MULTIPR_GUI_ProgressCallbackDlg (getApp()->desktop());
//mProgress->start("Save mesh", 100);
//mTimer->start(500); // 0.5 seconds timer
//QApplication::restoreOverrideCursor();
//getApp()->updateObjectBrowser();
-
+
}
{
return;
}
-
+
retrieveSelectedParts();
-
+
if (mSelectedParts.count() == 0)
{
- SUIT_MessageBox::warning(
+ SUIT_MessageBox::warning(
(QWidget*) MULTIPR_GUI::desktop(),
- QObject::tr("SPLIT_WARN"),
-// "Split warning",
- QObject::tr("NO_PART_SELECTED"));
-// "No parts selected");
+ QString("Split warning"),
+ QString("No parts selected"));
return;
}
-
+
if (!removeLowerResolution())
{
return;
}
-
+
MULTIPR_GUI_Partition2Dlg* dialog = new MULTIPR_GUI_Partition2Dlg(this);
dialog->exec();
delete dialog;
{
return;
}
-
+
retrieveSelectedParts();
-
+
if (mSelectedParts.count() == 0)
{
- SUIT_MessageBox::warning(
+ SUIT_MessageBox::warning(
(QWidget*) MULTIPR_GUI::desktop(),
- QObject::tr("DECIMATION_WARN"),
-// "Decimation warning",
- QObject::tr("NO_PART_SELECTED"));
-// "No parts selected");
+ QString("Decimation warning"),
+ QString("No parts selected"));
return;
}
MULTIPR_ORB::string_array* listFields = this->getMULTIPRObj()->getFields(allParts.toLatin1());
if (listFields->length() == 0)
{
- SUIT_MessageBox::critical(
+ SUIT_MessageBox::critical(
(QWidget*) MULTIPR_GUI::desktop(),
- QObject::tr("DECIM_ERROR"),
-// "Decimation error",
+ QObject::tr("DECIM_ERROR"),
+// "Decimation error",
QObject::tr("NO_FIELD_ON_PART"));
// "No field for this part.",);
return ;
{
return;
}
-
+
retrieveSelectedParts();
-
+
if (mSelectedParts.count() == 0)
{
- SUIT_MessageBox::warning(
+ SUIT_MessageBox::warning(
(QWidget*) MULTIPR_GUI::desktop(),
- QObject::tr("DEL_WARN"),
-// "Remove warning",
- QObject::tr("NO_PART_SELECTED"));
-// "No parts selected");
+ QString("Remove warning"),
+ QString("No parts selected"));
return;
}
-
+
if (QMessageBox::question(
(QWidget*) MULTIPR_GUI::desktop(),
- QObject::tr("DEL_SELECTED_PARTS"),
-// QObject::tr("Remove selected part(s)"),
- QObject::tr("DEL_SELECTED_PARTS_QUEST"),
-// QObject::tr("Do you want to remove selected part(s)?"),
- QObject::tr("&Yes"), tr("&No"),
+ QString("Remove selected part(s)"),
+ QString("Do you want to remove selected part(s)?"),
+ QString("&Yes"), QString("&No"),
QString::null, 0, 1 ) )
{
return;
}
catch(...)
{
- SUIT_MessageBox::critical(
+ SUIT_MessageBox::critical(
(QWidget*) MULTIPR_GUI::desktop(),
- QObject::tr("DEL_ERROR"),
-// "Remove error",
- QObject::tr("ERROR_DEL_PART"));
-// "Error while removing selected part(s)");
+ QString("Remove error"),
+ QString("Error while removing selected part(s)"));
}
QApplication::restoreOverrideCursor();
{
//if (mMULTIPRObj == NULL) return false;
if (CORBA::is_nil(mMULTIPRObj)) return false;
-
+
MULTIPR_ORB::string_array* listParts = mMULTIPRObj->getParts();
for (int i=0 ; i<listParts->length() ; i++)
{
const char* strItem = (*listParts)[i];
- if (strcmp(strItem, partName) == 0)
+ if (strcmp(strItem, partName) == 0)
{
return true;
}
QString partNameMed = partName + "_MED";
const char* strPartNameLow = partNameLow.toLatin1();
const char* strPartNameMed = partNameMed.toLatin1();
-
+
if (isPartExist(strPartNameLow))
{
partNameLowerResolution.push_back(partNameLow);
cout << "Part to be removed: " << strPartNameLow << endl;
}
-
+
if (isPartExist(strPartNameMed))
{
partNameLowerResolution.push_back(partNameMed);
cout << "Part to be removed: " << strPartNameMed << endl;
}
}
-
+
if (partNameLowerResolution.count() > 0)
{
if (QMessageBox::question(
{
return false;
}
-
+
QApplication::setOverrideCursor(Qt::WaitCursor);
-
+
try
{
for (QStringList::const_iterator it = partNameLowerResolution.begin(),
cout << "Remove " << (const char*)partName.toLatin1() << endl;
mMULTIPRObj->removeParts(partName.toLatin1());
}
-
}
catch(...)
{
- SUIT_MessageBox::critical(
+ SUIT_MessageBox::critical(
(QWidget*) MULTIPR_GUI::desktop(),
QObject::tr("DEL_ERROR"),
-// "Remove error",
- QObject::tr("ERROR_DEL_PREV_RESULT"));
-// "Error while removing previous results",
+// "Remove error",
+ QObject::tr("ERROR_DEL_PREV_RESULT"));
+// "Error while removing previous results",
}
-
+
QApplication::restoreOverrideCursor();
-
+
getApp()->updateObjectBrowser();
getApp()->updateActions();
}
-
+
return true;
}
{
//static QPixmap icon = SUIT_Session::session()->resourceMgr()->loadPixmap("MULTIPR", QObject::tr("ICON_IMPORT_MED"), false);
return QPixmap();
-
+
}
mId = 0;
mPath = "";
mMEDFileName = "";
-
+
mTooltip = info;
-
+
// parse info to retrieve all the fields
char lMeshName[256];
int lId;
char lPartName[256];
char lPath[256];
char lMEDFileName[256];
-
- int ret = sscanf(info, "%s %d %s %s %s",
+
+ int ret = sscanf(info, "%s %d %s %s %s",
lMeshName,
&lId,
lPartName,
lPath,
lMEDFileName);
-
+
// number of read parameters should be 5
if (ret != 5) return;
-
+
mMeshName = lMeshName;
mId = lId;
mPath = lPath;
if (!aSAStudy) return;
MULTIPR_GUI_DataObject_Module* modelRoot = dynamic_cast<MULTIPR_GUI_DataObject_Module*>(root());
- if (!modelRoot)
- {
+ if (!modelRoot)
+ {
// root is not set yet
modelRoot = new MULTIPR_GUI_DataObject_Module(this, NULL, "MULTIPR");
setRoot(modelRoot);
int lId;
char lPartName[256];
char lPath[256];
- char lMEDFileName[256];
+ char lMEDFileName[256];
// parse infos
- int ret = sscanf(strPartInfo0, "%s %d %s %s %s",
+ int ret = sscanf(strPartInfo0, "%s %d %s %s %s",
lMeshName,
&lId,
lPartName,
lPath,
lMEDFileName);
- if (ret != 5)
+ if (ret != 5)
{
cout << "MULTIPR: build() tree; error while parsing part info" << endl;
std::runtime_error("MULTIPR: build() tree; error while parsing part info");
char* strPartInfo = obj->getPartInfo(strItem);
// parse infos
- int ret = sscanf(strPartInfo, "%s %d %s %s %s",
+ int ret = sscanf(strPartInfo, "%s %d %s %s %s",
lMeshName,
&lId,
lPartName,
}
-extern "C"
+extern "C"
{
CAM_Module* createModule()
{