-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+// Copyright (C) 2014-2017 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, or (at your option) any later version.
+//
+// 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<mailto:webmaster.salome@opencascade.com>
+//
#include "PartSet_Module.h"
#include "PartSet_WidgetSketchLabel.h"
#include "PartSet_WidgetPoint2DFlyout.h"
#include "PartSet_WidgetShapeSelector.h"
#include "PartSet_WidgetMultiSelector.h"
-#include "PartSet_WidgetSubShapeSelector.h"
#include "PartSet_WidgetFeaturePointSelector.h"
#include "PartSet_WidgetEditor.h"
#include "PartSet_WidgetFileSelector.h"
#include "PartSet_MenuMgr.h"
#include "PartSet_CustomPrs.h"
#include "PartSet_IconFactory.h"
-#include "PartSet_WidgetChoice.h"
#include "PartSet_OverconstraintListener.h"
#include "PartSet_Filters.h"
#include <ModuleBase_IViewer.h>
#include <ModuleBase_IViewWindow.h>
#include <ModuleBase_IPropertyPanel.h>
+#include <ModuleBase_WidgetChoice.h>
#include <ModuleBase_WidgetEditor.h>
#include <ModuleBase_WidgetValidated.h>
#include <ModuleBase_Tools.h>
Config_PropManager::registerProp("Visualization", "operation_remove_feature_color",
"Color of removed feature in operation", Config_Prop::Color,
PartSet_CustomPrs::OPERATION_REMOVE_FEATURE_COLOR());
+ Config_PropManager::registerProp("Visualization", "sketch_preview_plane",
+ "Color of sketch plane", Config_Prop::Color,
+ PartSet_CustomPrs::OPERATION_SKETCH_PLANE());
}
PartSet_Module::~PartSet_Module()
void PartSet_Module::storeSelection()
{
- sketchMgr()->storeSelection();
+ // cash is used only to restore selection, so it should be filled in storeSelection and
+ // after applying immediatelly cleared in restoreSelection
+ myCurrentSelection.clear();
+ sketchMgr()->storeSelection(PartSet_SketcherMgr::ST_SelectType, myCurrentSelection);
}
void PartSet_Module::restoreSelection()
{
- sketchMgr()->restoreSelection();
+ // cash is used only to restore selection, so it should be filled in storeSelection and
+ // after applying immediatelly cleared in restoreSelection
+ sketchMgr()->restoreSelection(myCurrentSelection);
+ myCurrentSelection.clear();
}
void PartSet_Module::registerValidators()
aFactory->registerValidator("PartSet_CollinearSelection", new PartSet_CollinearSelection);
aFactory->registerValidator("PartSet_MiddlePointSelection", new PartSet_MiddlePointSelection);
aFactory->registerValidator("PartSet_DifferentObjects", new PartSet_DifferentObjectsValidator);
+ aFactory->registerValidator("PartSet_DifferentPoints", new PartSet_DifferentPointsValidator);
aFactory->registerValidator("PartSet_CoincidentAttr", new PartSet_CoincidentAttr);
aFactory->registerValidator("PartSet_MultyTranslationSelection",
new PartSet_MultyTranslationSelection);
if (sketchMgr()->isNestedSketchOperation(theOperation)) {
mySketchMgr->commitNestedSketch(theOperation);
}
+ /// deactivate of overconstraint listener should be performed after Sketch commit (#2176)
+ if (PartSet_SketcherMgr::isSketchOperation(theOperation))
+ overconstraintListener()->setActive(false);
/// Restart sketcher operations automatically
if (!mySketchReentrantMgr->operationCommitted(theOperation)) {
{
/// Restart sketcher operations automatically
mySketchReentrantMgr->operationAborted(theOperation);
+ /// deactivate of overconstraint listener should be performed after Sketch abort (#2176)
+ if (PartSet_SketcherMgr::isSketchOperation(theOperation))
+ overconstraintListener()->setActive(false);
}
void PartSet_Module::operationStarted(ModuleBase_Operation* theOperation)
return mySketchMgr->canDisplayObject(theObject);
}
+bool PartSet_Module::canUsePreselection(const QString& thePreviousOperationKind,
+ const QString& theStartedOperationKind)
+{
+ if (ModuleBase_IModule::canUsePreselection(thePreviousOperationKind, theStartedOperationKind))
+ return true;
+
+ return mySketchMgr->isNestedSketchFeature(theStartedOperationKind);
+}
+
/*void PartSet_Module::processHiddenObject(const std::list<ObjectPtr>& theObjects)
{
mySketchMgr->processHiddenObject(theObjects);
aShapeSelectorWgt->setSketcher(mySketchMgr->activeSketch());
aWgt = aShapeSelectorWgt;
}
- else if (theType == "sketch_sub_shape_selector") {
- PartSet_WidgetSubShapeSelector* aSubShapeSelectorWgt =
- new PartSet_WidgetSubShapeSelector(theParent, aWorkshop, theWidgetApi);
- aSubShapeSelectorWgt->setSketcher(mySketchMgr->activeSketch());
- aWgt = aSubShapeSelectorWgt;
- }
else if (theType == "sketch_feature_point_selector") {
PartSet_WidgetFeaturePointSelector* aPointSelectorWgt =
new PartSet_WidgetFeaturePointSelector(theParent, aWorkshop, theWidgetApi);
} else if (theType == "sketch_launcher") {
aWgt = new PartSet_WidgetSketchCreator(theParent, this, theWidgetApi);
} else if (theType == "module_choice") {
- aWgt = new PartSet_WidgetChoice(theParent, theWidgetApi);
+ aWgt = new ModuleBase_WidgetChoice(theParent, theWidgetApi);
connect(aWgt, SIGNAL(itemSelected(ModuleBase_ModelWidget*, int)),
this, SLOT(onChoiceChanged(ModuleBase_ModelWidget*, int)));
}
// the active nested sketch operation should be aborted unconditionally
// the Delete action should be additionally granted for the Sketch operation
// in order to do not abort/commit it
- if (!anOpMgr->canStartOperation(anOpAction->id()))
+ bool isCommitted;
+ if (!anOpMgr->canStartOperation(anOpAction->id(), isCommitted))
return true; // the objects are processed but can not be deleted
anOpMgr->startOperation(anOpAction);
return isProcessed;
}
-void PartSet_Module::onFeatureTriggered()
-{
- // is commented for imp: Unpressing the button of the current action must behave like
- // a validation if the entity can be created (instead of Cancel, as currently)
- /*QAction* aCmd = dynamic_cast<QAction*>(sender());
- if (aCmd->isCheckable() && aCmd->isChecked()) {
- // 1. check whether the delete should be processed in the module
- ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
- bool isNestedOp = myModule->sketchMgr()->isNestedCreateOperation(anOperation);
- if (isNestedOp) {
- // in case if in the viewer nothing is displayed, the create operation should not be
- // comitted even if all values of the feature are initialized
- if (!mySketchMgr->canDisplayCurrentCreatedFeature()) {
- // the action information should be saved before the operation is aborted
- // because this abort leads to update command status, which unchecks this action
- anOperation->abort();
- launchOperation(aCmd->data().toString());
- }
- }
- }*/
- ModuleBase_IModule::onFeatureTriggered();
-}
-
void PartSet_Module::editFeature(FeaturePtr theFeature)
{
storeConstraintsState(theFeature->getKind());
return true;
}
-void PartSet_Module::launchOperation(const QString& theCmdId)
+void PartSet_Module::launchOperation(const QString& theCmdId, const bool& isStartAfterCommitOnly)
{
myIsOperationIsLaunched = true;
storeConstraintsState(theCmdId.toStdString());
updateConstraintsState(theCmdId.toStdString());
- ModuleBase_IModule::launchOperation(theCmdId);
+ ModuleBase_IModule::launchOperation(theCmdId, isStartAfterCommitOnly);
myIsOperationIsLaunched = false;
}
}
if (aView.IsNull())
return;
- double aLen = aView->Convert(SketcherPrs_Tools::getDefaultArrowSize());
+ double aLen = aView->Convert(SketcherPrs_Tools::getConfigArrowSize());
double aPrevLen = SketcherPrs_Tools::getArrowSize();
SketcherPrs_Tools::setArrowSize(aLen);
- const double aPrevScale = aViewer->Scale(aViewer->activeView());
const double aCurScale = aViewer->activeView()->Camera()->Scale();
aViewer->SetScale(aViewer->activeView(), aCurScale);
- SketcherPrs_Tools::setTextHeight (aCurScale / aPrevScale * SketcherPrs_Tools::getTextHeight());
+ double aTextHeight = SketcherPrs_Tools::getConfigTextHeight();
+ SketcherPrs_Tools::setTextHeight (aTextHeight);
bool isModified = false;
QList<AISObjectPtr> aPrsList = aDisplayer->displayedPresentations();
foreach (AISObjectPtr aAIS, aPrsList) {
Handle(AIS_Dimension) aDim = Handle(AIS_Dimension)::DownCast(aAisObj);
if (!aDim.IsNull()) {
aDim->DimensionAspect()->ArrowAspect()->SetLength(aLen);
+ aDim->DimensionAspect()->TextAspect()->SetHeight(aTextHeight);
aContext->Redisplay(aDim, false);
isModified = true;
}
bool hasFeature = false;
bool hasParameter = false;
bool hasCompositeOwner = false;
+ bool hasResultInHistory = false;
ModuleBase_Tools::checkObjects(aObjects, hasResult, hasFeature, hasParameter,
- hasCompositeOwner);
+ hasCompositeOwner, hasResultInHistory);
ModuleBase_Operation* aCurrentOp = myWorkshop->currentOperation();
if (aSelected == 1) {
DocumentPtr aActiveDoc = aMgr->activeDocument();
if (myActivePartIndex.isValid())
aTreeView->setExpanded(myActivePartIndex, false);
+
XGUI_DataModel* aDataModel = aWorkshop->objectBrowser()->dataModel();
- myActivePartIndex = aDataModel->documentRootIndex(aActiveDoc);
- if (myActivePartIndex.isValid())
- aTreeView->setExpanded(myActivePartIndex, true);
+ myActivePartIndex = aDataModel->documentRootIndex(aActiveDoc, 0);
+ bool needUpdate = false;
+ if (myActivePartIndex.isValid()) {
+ needUpdate = aTreeView->isExpanded(myActivePartIndex);
+ if (!needUpdate)
+ aTreeView->setExpanded(myActivePartIndex, true);
+ }
aLabel->setPalette(aPalet);
aWorkshop->updateCommandStatus();
aDisplayer->redisplay(aObj, false);
}
aDisplayer->updateViewer();
+ // Update tree items if they are expanded
+ if (needUpdate) {
+ aTreeView->viewport()->repaint(aTreeView->viewport()->rect());
+ }
} else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_CREATED)) {
std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
//aMgr->setActiveDocument(aMgr->moduleDocument());
return;
}
- if (theIndex.column() != 0) // Use only first column
+ if (theIndex.column() != 1) // Use only first column
return;
XGUI_Workshop* aWorkshop = getWorkshop();
void PartSet_Module::onChoiceChanged(ModuleBase_ModelWidget* theWidget,
int theIndex)
{
- PartSet_WidgetChoice* aChoiceWidget = dynamic_cast<PartSet_WidgetChoice*>(theWidget);
+ ModuleBase_WidgetChoice* aChoiceWidget = dynamic_cast<ModuleBase_WidgetChoice*>(theWidget);
if (!aChoiceWidget)
return;