#include <ModelAPI_Validator.h>
#include <ModelAPI_Tools.h>
#include <ModelAPI_ResultField.h>
+#include <ModuleBase_IconFactory.h>
//#include <PartSetPlugin_Part.h>
#include <ExchangePlugin_ExportPart.h>
#include <ExchangePlugin_ImportPart.h>
+#include <ExchangePlugin_Import.h>
#include <GeomAPI_Pnt.h>
#include <GeomAPI_ShapeExplorer.h>
#include <QDesktopWidget>
#include <QProcess>
#include <QDesktopServices>
+#include <QFormLayout>
+#include <QSpinBox>
+#include <QDialogButtonBox>
#include <iterator>
// Load translations
QStringList aLangs;
aLangs << "*_en.ts"; // load by default eng translations
+
+ /// If version of OCCT is 7.4.0 or more then it means that
+ /// this is version of SALOME older then 9.4.0
+#if OCC_VERSION_HEX >= 0x070400
+ QString aCurrLang = aResMgr->language();
+#else
QString aCurrLang = aResMgr->stringValue("language", "language", "en");
+#endif
+
if(aCurrLang != "en") {
aLangs << "*_" + aCurrLang + ".ts"; // then replace with translated files
}
QIcon(), QKeySequence(),
false, "MEN_DESK_FILE");
connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onImportPart()));
+
+ aAction = salomeConnector()->addDesktopCommand("IMPORT_SHAPE_CMD", tr("Import shape..."),
+ tr("Import shape from a file"),
+ ModuleBase_IconFactory::loadIcon("icons/Exchange/import.png"),
+ QKeySequence(), false, "MEN_DESK_FILE");
+ connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onImportShape()));
+
salomeConnector()->addDesktopMenuSeparator("MEN_DESK_FILE");
#else
if (Config_PropManager::boolean("Windows", "use_hide_faces_panel")) {
if (!theOperation->isHideFacesVisible())
- myFacesPanel->hide();
+ myFacesPanel->close();
}
}
if (abortAllOperations()) {
ModuleBase_OperationFeature* anImportPartOp = dynamic_cast<ModuleBase_OperationFeature*>(
module()->createOperation(ExchangePlugin_ImportPart::ID()));
+ myPropertyPanel->updateApplyPlusButton(anImportPartOp->feature());
operationMgr()->startOperation(anImportPartOp);
}
}
+//******************************************************
+void XGUI_Workshop::onImportShape()
+{
+ if (abortAllOperations()) {
+ ModuleBase_OperationFeature* anImportOp = dynamic_cast<ModuleBase_OperationFeature*>(
+ module()->createOperation(ExchangePlugin_Import::ID()));
+ myPropertyPanel->updateApplyPlusButton(anImportOp->feature());
+ operationMgr()->startOperation(anImportOp);
+ }
+}
+
//******************************************************
void XGUI_Workshop::onExportPart()
{
if (abortAllOperations()) {
ModuleBase_OperationFeature* anExportPartOp = dynamic_cast<ModuleBase_OperationFeature*>(
module()->createOperation(ExchangePlugin_ExportPart::ID()));
+ myPropertyPanel->updateApplyPlusButton(anExportPartOp->feature());
operationMgr()->startOperation(anExportPartOp);
}
}
myObjectBrowser->initialize(myModule->rootNode());
myModule->customizeObjectBrowser(myObjectBrowser);
aObjDock->setWidget(myObjectBrowser);
+ aObjDock->setObjectName("Object browser");
connect(myObjectBrowser, SIGNAL(sizeChanged()), SLOT(onDockSizeChanged()));
// in order to operation manager could process key events of the panel.
// otherwise they are ignored. It happens only if the same(activateWindow) is
// not happened by property panel activation(e.g. resume operation of Sketch)
- ModuleBase_Tools::setFocus(theDockWidget, "XGUI_Workshop::showPanel()");
+ //ModuleBase_Tools::setFocus(theDockWidget, "XGUI_Workshop::showPanel()");
}
//******************************************************
moveObjects(theId == "MOVE_SPLIT_CMD");
else if (theId == "COLOR_CMD")
changeColor(aObjects);
+ else if (theId == "ISOLINES_CMD")
+ changeIsoLines(aObjects);
else if (theId == "DEFLECTION_CMD")
changeDeflection(aObjects);
else if (theId == "TRANSPARENCY_CMD")
}
QObjectPtrList anObjects = mySelector->selection()->selectedObjects();
+ if (anObjects.isEmpty())
+ return;
+
if (!abortAllOperations())
return;
return false;
}
-//******************************************************
-void setColor(ResultPtr theResult, const std::vector<int>& theColor)
-{
- if (!theResult.get())
- return;
-
- AttributeIntArrayPtr aColorAttr = theResult->data()->intArray(ModelAPI_Result::COLOR_ID());
- if (aColorAttr.get() != NULL) {
- if (!aColorAttr->size()) {
- aColorAttr->setSize(3);
- }
- aColorAttr->setValue(0, theColor[0]);
- aColorAttr->setValue(1, theColor[1]);
- aColorAttr->setValue(2, theColor[2]);
- }
-}
//**************************************************************
void getDefaultColor(ObjectPtr theObject, const bool isEmptyColorValid,
std::list<ResultPtr> allRes;
ModelAPI_Tools::allSubs(aBodyResult, allRes);
for(std::list<ResultPtr>::iterator aRes = allRes.begin(); aRes != allRes.end(); aRes++) {
- setColor(*aRes, !isRandomColor ? aColorResult : aDlg->getRandomColor());
+ ModelAPI_Tools::setColor(*aRes, !isRandomColor ? aColorResult : aDlg->getRandomColor());
}
}
- setColor(aResult, !isRandomColor ? aColorResult : aDlg->getRandomColor());
+ ModelAPI_Tools::setColor(aResult, !isRandomColor ? aColorResult : aDlg->getRandomColor());
}
}
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
myViewerProxy->update();
}
-//**************************************************************
-void setDeflection(ResultPtr theResult, const double theDeflection)
-{
- if (!theResult.get())
- return;
-
- AttributeDoublePtr aDeflectionAttr = theResult->data()->real(ModelAPI_Result::DEFLECTION_ID());
- if (aDeflectionAttr.get() != NULL) {
- aDeflectionAttr->setValue(theDeflection);
- }
-}
-
-//**************************************************************
-void setTransparency(ResultPtr theResult, double theTransparency)
-{
- if (!theResult.get())
- return;
-
- AttributeDoublePtr anAttribute = theResult->data()->real(ModelAPI_Result::TRANSPARENCY_ID());
- if (anAttribute.get() != NULL) {
- anAttribute->setValue(theTransparency);
- }
-}
-
//**************************************************************
void setTransparency(double theTransparency, const QObjectPtrList& theObjects)
{
ModelAPI_Tools::allSubs(aBodyResult, allRes);
std::list<ResultPtr>::iterator aRes;
for(aRes = allRes.begin(); aRes != allRes.end(); aRes++) {
- setTransparency(*aRes, theTransparency);
+ ModelAPI_Tools::setTransparency(*aRes, theTransparency);
}
}
- setTransparency(aResult, theTransparency);
+ ModelAPI_Tools::setTransparency(aResult, theTransparency);
}
}
}
std::list<ResultPtr> allRes;
ModelAPI_Tools::allSubs(aBodyResult, allRes);
for(std::list<ResultPtr>::iterator aRes = allRes.begin(); aRes != allRes.end(); aRes++) {
- setDeflection(*aRes, aDeflection);
+ ModelAPI_Tools::setDeflection(*aRes, aDeflection);
}
}
- setDeflection(aResult, aDeflection);
+ ModelAPI_Tools::setDeflection(aResult, aDeflection);
}
}
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
{
myActiveControlMgr->deactivateSelector(myActiveControlMgr->activeSelector());
}
+
+void XGUI_Workshop::changeIsoLines(const QObjectPtrList& theObjects)
+{
+ if (theObjects.isEmpty())
+ return;
+
+ std::vector<int> aValues;
+ if (theObjects.size() == 1) {
+ ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(theObjects.first());
+ if (aRes.get())
+ ModelAPI_Tools::getIsoLines(aRes, aValues);
+ else
+ return;
+ }
+ if (aValues.size() == 0) {
+ aValues.push_back(1);
+ aValues.push_back(1);
+ }
+
+ if (!abortAllOperations())
+ return;
+
+ QDialog aDlg;
+ aDlg.setWindowTitle(tr("Number of Iso-lines"));
+ QFormLayout* aLayout = new QFormLayout(&aDlg);
+
+ QSpinBox* aUNb = new QSpinBox(&aDlg);
+ aUNb->setValue(aValues[0]);
+ aLayout->addRow("U:", aUNb);
+
+ QSpinBox* aVNb = new QSpinBox(&aDlg);
+ aVNb->setValue(aValues[1]);
+ aLayout->addRow("V:", aVNb);
+
+ QDialogButtonBox* aButtons =
+ new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, &aDlg);
+ connect(aButtons, SIGNAL(accepted()), &aDlg, SLOT(accept()));
+ connect(aButtons, SIGNAL(rejected()), &aDlg, SLOT(reject()));
+ aLayout->addRow(aButtons);
+
+ if (aDlg.exec() == QDialog::Accepted) {
+ SessionPtr aMgr = ModelAPI_Session::get();
+ QString aDescription = contextMenuMgr()->action("ISOLINES_CMD")->text();
+ aMgr->startOperation(aDescription.toStdString());
+
+ aValues[0] = aUNb->value();
+ aValues[1] = aVNb->value();
+ ResultPtr aRes;
+ foreach(ObjectPtr aObj, theObjects) {
+ aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
+ if (aRes.get()) {
+ ModelAPI_Tools::setIsoLines(aRes, aValues);
+ }
+ }
+ Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
+ aMgr->finishOperation();
+ updateCommandStatus();
+ }
+}
\ No newline at end of file