#include <qwhatsthis.h>
#include <qimage.h>
#include <qpixmap.h>
+#include <qmessagebox.h>
using namespace std;
false,
this,
SLOT(OnDecimate()));
+
+ createAction(
+ ACTION_REMOVE,
+ tr("TLT_REMOVE"),
+ QIconSet(),
+ tr("MEN_REMOVE"),
+ tr("STS_REMOVE"),
+ 0,
+ aParent,
+ false,
+ this,
+ SLOT(OnRemove()));
QPixmap aPixmapSaveMEDFile = aResourceMgr->loadPixmap("MULTIPR", tr("ICON_SAVE_MED"));
createMenu(ACTION_SAVE, aMenuId, 10);
createMenu(ACTION_SPLIT, aMenuId, 10);
createMenu(ACTION_DECIMATE, aMenuId, 10);
+ createMenu(ACTION_REMOVE, aMenuId, 10);
//-------------------------------------------------------------------------
// create toolbars
QtxPopupMgr* mgr = popupMgr();
mgr->insert( action(ACTION_SPLIT), -1, -1, -1 );
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, true);
mgr->setRule(action(ACTION_DECIMATE), aRule, true);
+ mgr->setRule(action(ACTION_REMOVE), aRule, true);
mgr->setRule(action(ACTION_SAVE), aRule, true);
//-------------------------------------------------------------------------
catch (...)
{
}
+
+ getApp()->updateObjectBrowser();
}
return;
}
+ // for each selected part, check if there are lower resolution
+ // and then propose to remove them before processing new decimation
+ QStringList partNameLowerResolution;
+ for (QStringList::const_iterator it = mSelectedParts.begin(), last = mSelectedParts.end(); it != last; it++)
+ {
+ const QString& partName = (*it);
+ QString partNameLow = partName + "_LOW";
+ QString partNameMed = partName + "_MED";
+ const char* strPartNameLow = partNameLow.latin1();
+ const char* strPartNameMed = partNameMed.latin1();
+
+ if (isPartExist(strPartNameLow))
+ {
+ partNameLowerResolution.push_back(partNameLow);
+ cout << "Part to be removed: " << partNameLow << endl;
+ }
+
+ if (isPartExist(strPartNameMed))
+ {
+ partNameLowerResolution.push_back(partNameMed);
+ cout << "Part to be removed: " << partNameMed << endl;
+ }
+ }
+
+ if (partNameLowerResolution.count() > 0)
+ {
+ if (QMessageBox::question(
+ getApp()->desktop(),
+ tr("Decimation: remove previous results"),
+ tr("Do you want to remove previous results?"),
+ tr("&Yes"), tr("&No"),
+ QString::null, 0, 1 ) )
+ {
+ return;
+ }
+
+ QApplication::setOverrideCursor(Qt::waitCursor);
+
+ try
+ {
+ for (QStringList::const_iterator it = partNameLowerResolution.begin(), last = partNameLowerResolution.end(); it != last; it++)
+ {
+ const QString& partName = (*it);
+ cout << "Remove " << partName.latin1() << endl;
+ mMULTIPRObj->removePart(partName.latin1());
+ }
+
+ }
+ catch(...)
+ {
+ SUIT_MessageBox::error1(
+ getApp()->desktop(),
+ "Remove error",
+ "Error while removing previous results",
+ tr("OK") );
+ }
+
+ QApplication::restoreOverrideCursor();
+
+ getApp()->updateObjectBrowser();
+ }
+
MULTIPR_GUI_DecimateDlg* dialog = new MULTIPR_GUI_DecimateDlg(this);
dialog->exec();
delete dialog;
}
+void MULTIPR_GUI::OnRemove()
+{
+ retrieveSelectedParts();
+
+ if (mSelectedParts.count() == 0)
+ {
+ SUIT_MessageBox::warn1(
+ getApp()->desktop(),
+ "Remove warning",
+ "No parts selected",
+ tr("OK") );
+ return;
+ }
+
+ if (QMessageBox::question(
+ getApp()->desktop(),
+ tr("Remove selected part(s)"),
+ tr("Do you want to remove selected part(s)?"),
+ tr("&Yes"), tr("&No"),
+ QString::null, 0, 1 ) )
+ {
+ return;
+ }
+
+ QApplication::setOverrideCursor(Qt::waitCursor);
+
+ try
+ {
+ for (QStringList::const_iterator it = mSelectedParts.begin(), last = mSelectedParts.end(); it != last; it++)
+ {
+ const QString& partName = (*it);
+ cout << "Remove " << partName.latin1() << endl;
+ mMULTIPRObj->removePart(partName.latin1());
+ }
+
+ }
+ catch(...)
+ {
+ SUIT_MessageBox::error1(
+ getApp()->desktop(),
+ "Remove error",
+ "Error while removing selected part(s)",
+ tr("OK") );
+ }
+
+ QApplication::restoreOverrideCursor();
+
+ getApp()->updateObjectBrowser();
+}
+
+
void MULTIPR_GUI::OnSave()
{
QApplication::setOverrideCursor(Qt::waitCursor);
}
+bool MULTIPR_GUI::isPartExist(const char* partName)
+{
+ if (mMULTIPRObj == NULL) 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)
+ {
+ return true;
+ }
+ }
+ return false;
+}
+
+
//*****************************************************************************
// Super class Data Object implementation
//*****************************************************************************