#include "XGUI_Tools.h"
#include "XGUI_ViewerProxy.h"
#include "XGUI_WorkshopListener.h"
-#include <XGUI_CustomPrs.h>
#include <XGUI_HistoryMenu.h>
#include <XGUI_QtEvents.h>
#include <XGUI_DataModel.h>
#include <ModelAPI_AttributeDocRef.h>
#include <ModelAPI_AttributeIntArray.h>
#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_AttributeString.h>
#include <ModelAPI_Data.h>
#include <ModelAPI_Events.h>
#include <ModelAPI_Feature.h>
#include <Events_InfoMessage.h>
#include <Events_LongOp.h>
+#include <ExchangePlugin_ExportPart.h>
+#include <ExchangePlugin_ImportPart.h>
+
#include <GeomAPI_Pnt.h>
#include <ModuleBase_IModule.h>
#include <ModuleBase_Tools.h>
#include <ModuleBase_WidgetFactory.h>
#include <ModuleBase_OperationFeature.h>
-#include <ModuleBase_OperationAction.h>
#include <ModuleBase_PagedContainer.h>
#include <ModuleBase_WidgetValidated.h>
#include <ModuleBase_ModelWidget.h>
static QString MyExtension(".cadbld");
#endif
+static QString MyImportPartFilter(QObject::tr("Part files (*.shaperpart);;All files (*.*)"));
+
//******************************************************
XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
#ifndef HAVE_SALOME
connect(myMainWindow, SIGNAL(exitKeySequence()), SLOT(onExit()));
- onTrihedronVisibilityChanged(true);
+ myDisplayer->displayTrihedron(true);
#endif
connect(myEventsListener, SIGNAL(errorOccurred(std::shared_ptr<Events_InfoMessage>)),
myErrorDlg, SLOT(addError(std::shared_ptr<Events_InfoMessage>)));
- //Config_PropManager::registerProp("Visualization", "object_default_color", "Object color",
- // Config_Prop::Color, "225,225,225");
-
- Config_PropManager::registerProp("Visualization", "result_body_color", "Result color",
- Config_Prop::Color, ModelAPI_ResultBody::DEFAULT_COLOR());
- Config_PropManager::registerProp("Visualization", "result_group_color", "Group color",
- Config_Prop::Color, ModelAPI_ResultGroup::DEFAULT_COLOR());
- Config_PropManager::registerProp("Visualization", "result_construction_color",
- "Construction color",
- Config_Prop::Color,
- ModelAPI_ResultConstruction::DEFAULT_COLOR());
- Config_PropManager::registerProp("Visualization", "result_part_color", "Part color",
- Config_Prop::Color, ModelAPI_ResultPart::DEFAULT_COLOR());
- Config_PropManager::registerProp("Visualization", "result_field_color", "Field color",
- Config_Prop::Color, ModelAPI_ResultField::DEFAULT_COLOR());
+ Config_PropManager::registerProp("Visualization", "selection_color", "Selection color",
+ Config_Prop::Color, "255,255,255");
if (ModuleBase_Preferences::resourceMgr()->booleanValue("Viewer", "face-selection", true))
myViewerSelMode.append(TopAbs_FACE);
// Calling of loadCustomProps before activating module is required
// by Config_PropManger to restore user-defined path to plugins
ModuleBase_Preferences::loadCustomProps();
+ std::vector<int> aColor;
+ try {
+ aColor = Config_PropManager::color("Visualization", "selection_color");
+ }
+ catch (...) {
+ }
+ if (aColor.size() == 3)
+ myDisplayer->setSelectionColor(aColor);
+
createModule();
#ifndef HAVE_SALOME
connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onOpen()));
salomeConnector()->addDesktopMenuSeparator("MEN_DESK_FILE");
+ aAction = salomeConnector()->addDesktopCommand("EXPORT_PART_CMD", tr("Export part..."),
+ tr("Export a part of the current document into a file"),
+ QIcon(), QKeySequence(),
+ false, "MEN_DESK_FILE");
+ connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onExportPart()));
+
+ aAction = salomeConnector()->addDesktopCommand("IMPORT_PART_CMD", tr("Import part..."),
+ tr("Import structure of a part"),
+ QIcon(), QKeySequence(),
+ false, "MEN_DESK_FILE");
+ connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onImportPart()));
+ salomeConnector()->addDesktopMenuSeparator("MEN_DESK_FILE");
+
#else
// File commands group
AppElements_MenuGroupPanel* aGroup = myMainWindow->menuObject()->generalPage();
if (!aFOperation)
return;
- showPanel(myPropertyPanel);
myPropertyPanel->cleanContent();
QList<ModuleBase_ModelWidget*> aWidgets;
- if (!module()->createWidgets(theOperation, aWidgets)) {
- QString aXmlRepr = aFOperation->getDescription()->xmlRepresentation();
+ QString aXmlRepr = aFOperation->getDescription()->xmlRepresentation();
+ if (!module()->createWidgets(aFOperation->feature(), aXmlRepr, aWidgets)) {
ModuleBase_WidgetFactory aFactory(aXmlRepr.toStdString(), myModuleConnector);
aFactory.createWidget(myPropertyPanel->contentWidget());
aWidgets = aFactory.getModelWidgets();
myModule->propertyPanelDefined(theOperation);
#ifndef DEBUG_FEATURE_NAME
- myPropertyPanel->setWindowTitle(theOperation->getDescription()->description());
+ myPropertyPanel->setWindowTitle(ModuleBase_Tools::translate("workshop",
+ theOperation->getDescription()->description().toStdString()));
#else
std::string aFeatureName = aFeature->name();
myPropertyPanel->setWindowTitle(QString("%1: %2")
- .arg(theOperation->getDescription()->description())
- .arg(aFeatureName.c_str()));
+ .arg(translate(theOperation->getDescription()->description()))
+ .arg(translate(aFeatureName.c_str())));
#endif
myErrorMgr->setPropertyPanel(myPropertyPanel);
+ theOperation->setHideFacesVisible(myFacesPanel->isVisible());
+ if (aFeatureInfo.get() && aFeatureInfo->isHideFacesPanel() && !myFacesPanel->isVisible())
+ myFacesPanel->show();
+ showPanel(myPropertyPanel);
}
//******************************************************
}
}
activateObjectsSelection(anObjects);
+
+ if (!theOperation->isHideFacesVisible())
+ myFacesPanel->hide();
}
//******************************************************
ModuleBase_Preferences::editPreferences(aModif);
if (aModif.size() > 0) {
QString aSection;
- foreach (ModuleBase_Pref aPref, aModif)
- {
+ foreach (ModuleBase_Pref aPref, aModif) {
aSection = aPref.first;
if (aSection == ModuleBase_Preferences::VIEWER_SECTION) {
myMainWindow->viewer()->updateFromResources();
myMainWindow->menuObject()->updateFromResources();
}
}
+ std::vector<int> aColor;
+ try {
+ aColor = Config_PropManager::color("Visualization", "selection_color");
+ }
+ catch (...) {
+ }
+ if (aColor.size() == 3)
+ displayer()->setSelectionColor(aColor);
+
displayer()->redisplayObjects();
}
}
void XGUI_Workshop::onTrihedronVisibilityChanged(bool theState)
{
XGUI_Displayer* aDisplayer = displayer();
- if (aDisplayer)
+ if (aDisplayer) {
aDisplayer->displayTrihedron(theState);
+ aDisplayer->updateViewer();
+ }
}
//******************************************************
void XGUI_Workshop::onWidgetObjectUpdated()
{
operationMgr()->onValidateOperation();
+ myDisplayer->updateViewer();
+}
+
+//******************************************************
+void XGUI_Workshop::onImportPart()
+{
+ if (abortAllOperations()) {
+ ModuleBase_OperationFeature* anImportPartOp = dynamic_cast<ModuleBase_OperationFeature*>(
+ module()->createOperation(ExchangePlugin_ImportPart::ID()));
+ operationMgr()->startOperation(anImportPartOp);
+ }
+}
+
+//******************************************************
+void XGUI_Workshop::onExportPart()
+{
+ if (abortAllOperations()) {
+ ModuleBase_OperationFeature* anExportPartOp = dynamic_cast<ModuleBase_OperationFeature*>(
+ module()->createOperation(ExchangePlugin_ExportPart::ID()));
+ operationMgr()->startOperation(anExportPartOp);
+ }
}
//******************************************************
hidePanel(myPropertyPanel); ///<! Invisible by default
- myFacesPanel = new XGUI_FacesPanel(aDesktop, myModuleConnector);
+ myFacesPanel = new XGUI_FacesPanel(aDesktop, this);
myActiveControlMgr->addSelector(new XGUI_FacesPanelSelector(myFacesPanel));
myFacesPanel->setAllowedAreas(Qt::LeftDockWidgetArea |
Qt::RightDockWidgetArea |
Qt::BottomDockWidgetArea);
connect(myFacesPanel, SIGNAL(closed()), myFacesPanel, SLOT(onClosed()));
- myInspectionPanel = new XGUI_InspectionPanel(aDesktop, mySelector);
+ myInspectionPanel = new XGUI_InspectionPanel(aDesktop, this);
myInspectionPanel->setAllowedAreas(Qt::LeftDockWidgetArea |
Qt::RightDockWidgetArea);
aDesktop->addDockWidget(Qt::RightDockWidgetArea, myInspectionPanel);
// allow the module to delete objects, do nothing if it has succeed
if (aModule->deleteObjects()) {
updateCommandStatus();
+ myDisplayer->updateViewer();
return;
}
if (!(hasResult || hasFeature || hasParameter || hasFolder))
return;
+ // Remove from the list non-deletable objects: infinite constructions which are not in history
+ bool notDelete = true;
+ QObjectPtrList::iterator aIt;
+ for (aIt = anObjects.begin(); aIt != anObjects.end(); aIt++) {
+ ObjectPtr aObj = (*aIt);
+ ResultConstructionPtr aConstr = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aObj);
+ FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
+ if (aFeature) {
+ notDelete = (!aFeature->isInHistory()) && aConstr->isInfinite();
+ if (notDelete) {
+ anObjects.removeAll(aObj);
+ aIt--;
+ }
+ }
+ }
// delete objects
std::map<FeaturePtr, std::set<FeaturePtr> > aReferences;
std::set<FeaturePtr> aFeatures;
bool aDone = false;
QString aDescription = contextMenuMgr()->action("DELETE_CMD")->text() + " %1";
aDescription = aDescription.arg(XGUI_Tools::unionOfObjectNames(anObjects, ", "));
- ModuleBase_OperationAction* anOpAction = new ModuleBase_OperationAction(aDescription, module());
+ ModuleBase_Operation* anOpAction = new ModuleBase_Operation(aDescription, module());
operationMgr()->startOperation(anOpAction);
operationMgr()->commitOperation();
else
operationMgr()->abortOperation(operationMgr()->currentOperation());
+
+ myDisplayer->updateViewer();
}
//**************************************************************
QString anUnusedNames = aNames.join(", ");
QString anActionId = "CLEAN_HISTORY_CMD";
- QString aDescription = contextMenuMgr()->action(anActionId)->text();
+ QString aDescription = ModuleBase_Tools::translate("workshop",
+ contextMenuMgr()->action(anActionId)->text().toStdString());
QMessageBox aMessageBox(desktop());
aMessageBox.setWindowTitle(aDescription);
// 1. start operation
aDescription += "by deleting of " +
aDescription.arg(XGUI_Tools::unionOfObjectNames(anObjects, ", "));
- ModuleBase_OperationAction* anOpAction = new ModuleBase_OperationAction(aDescription, module());
+ ModuleBase_Operation* anOpAction = new ModuleBase_Operation(aDescription, module());
operationMgr()->startOperation(anOpAction);
// WORKAROUND, should be done before each object remove, if it presents in XGUI_DataModel tree
SessionPtr aMgr = ModelAPI_Session::get();
- QString anActionId = "MOVE_CMD";
- QString aDescription = contextMenuMgr()->action(anActionId)->text();
- aMgr->startOperation(aDescription.toStdString());
-
QObjectPtrList anObjects = mySelector->selection()->selectedObjects();
// It is necessary to clear selection in order to avoid selection changed event during
// moving and negative consequences connected with processing of already moved items
if (!XGUI_Tools::canRemoveOrRename(desktop(), aFeatures))
return;
+ QString anActionId = "MOVE_CMD";
+ QString aDescription = contextMenuMgr()->action(anActionId)->text();
+ aMgr->startOperation(aDescription.toStdString());
+
// Sort features by index in document
std::list<FeaturePtr> aFList(aFeatures.begin(), aFeatures.end());
aFList.sort(compareFeature);
aCurrentFeature = anActiveDocument->currentFeature(true);
}
aMgr->finishOperation();
+ updateCommandStatus();
}
//**************************************************************
foreach(ObjectPtr anObject, theObjects) {
ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
if (aResult.get()) {
- XGUI_CustomPrs::getResultColor(aResult, aColor);
+ ModelAPI_Tools::getColor(aResult, aColor);
}
else {
// TODO: remove the obtaining a color from the AIS object
foreach(ObjectPtr anObject, theObjects) {
ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
if (aResult.get()) {
- aDeflection = XGUI_CustomPrs::getResultDeflection(aResult);
+ aDeflection = ModelAPI_Tools::getDeflection(aResult);
}
else {
// TODO: remove the obtaining a property from the AIS object
foreach(ObjectPtr anObject, theObjects) {
ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
if (aResult.get()) {
- aCurrentValue = XGUI_CustomPrs::getResultTransparency(aResult);
+ aCurrentValue = ModelAPI_Tools::getTransparency(aResult);
}
if (aCurrentValue > 0)
break;
// 2. show the dialog to change the value
XGUI_PropertyDialog* aDlg = new XGUI_PropertyDialog(desktop());
- aDlg->setWindowTitle("Transparency");
+ aDlg->setWindowTitle(tr("Transparency"));
XGUI_TransparencyWidget* aTransparencyWidget = new XGUI_TransparencyWidget(aDlg);
connect(aTransparencyWidget, SIGNAL(transparencyValueChanged()),
this, SLOT(onTransparencyValueChanged()));
myObjectBrowser->updateAllIndexes();
updateColorScaleVisibility();
+ displayer()->updateViewer();
}
//**************************************************************
// Necessary for update icons in ObjectBrowser on Linux
myObjectBrowser->updateAllIndexes();
updateColorScaleVisibility();
+ displayer()->updateViewer();
}
aDocs.append(aMgr->moduleDocument());
foreach(DocumentPtr aDoc, aDocs) {
- synchronizeGroupInViewer(aDoc, ModelAPI_ResultConstruction::group(), false);
- synchronizeGroupInViewer(aDoc, ModelAPI_ResultBody::group(), false);
- synchronizeGroupInViewer(aDoc, ModelAPI_ResultPart::group(), false);
- synchronizeGroupInViewer(aDoc, ModelAPI_ResultGroup::group(), false);
+ synchronizeGroupInViewer(aDoc, false);
}
}
//******************************************************
void XGUI_Workshop::synchronizeGroupInViewer(const DocumentPtr& theDoc,
- const std::string& theGroup,
bool theUpdateViewer)
{
- ObjectPtr aObj;
- int aSize = theDoc->size(theGroup);
+ FeaturePtr aFeature;
+ ResultPtr aRes;
+ int aSize = theDoc->numInternalFeatures();
for (int i = 0; i < aSize; i++) {
- aObj = theDoc->object(theGroup, i);
- if (aObj->isDisplayed()) {
- // Hide the presentation with an empty shape. But isDisplayed state of the object should not
- // be changed to the object becomes visible when the shape becomes not empty
- ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
- if (aRes.get() && (!aRes->shape().get() || aRes->shape()->isNull()))
- continue;
- ResultBodyPtr aResBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aObj);
- if (aResBody.get())
- synchronizeResultTree(aResBody, false);
- else
- myDisplayer->display(aObj, false);
+ aFeature = theDoc->internalFeature(i);
+ if (!aFeature.get())
+ continue;
+ const std::list<ResultPtr>& aResults = aFeature->results();
+ std::list<ResultPtr>::const_iterator aIt;
+ aFeature->setDisplayed(false);
+ for (aIt = aResults.cbegin(); aIt != aResults.cend(); aIt++) {
+ aRes = (*aIt);
+ if (aRes->isDisplayed() && !aRes->isConcealed()) {
+ // Hide the presentation with an empty shape. But isDisplayed state of the object should not
+ // be changed to the object becomes visible when the shape becomes not empty
+ if (!aRes->shape().get() || aRes->shape()->isNull())
+ continue;
+ ResultBodyPtr aResBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aRes);
+ if (aResBody.get())
+ synchronizeResultTree(aResBody, false);
+ else {
+ if (aRes->isInHistory()) {
+ if (aRes->isDisplayed())
+ myDisplayer->display(aRes, false);
+ else
+ myDisplayer->erase(aRes, false);
+ }
+ else
+ aRes->setDisplayed(false);
+ }
+ }
}
}
if (theUpdateViewer)