-// Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2019 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
//
// 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
+// 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>
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#include "PartSet_WidgetSketchLabel.h"
#include <ModuleBase_ViewerPrs.h>
#include <ModuleBase_Tools.h>
#include <ModuleBase_IModule.h>
+#include <ModuleBase_IPropertyPanel.h>
#include <GeomAlgoAPI_FaceBuilder.h>
#include <GeomAlgoAPI_ShapeTools.h>
ModuleBase_IWorkshop* theWorkshop,
const Config_WidgetAPI* theData,
const QMap<PartSet_Tools::ConstraintVisibleState, bool>& toShowConstraints)
-: ModuleBase_WidgetValidated(theParent, theWorkshop, theData)
+: ModuleBase_WidgetValidated(theParent, theWorkshop, theData), myOpenTransaction(false),
+myIsSelection(false)
{
QVBoxLayout* aLayout = new QVBoxLayout(this);
ModuleBase_Tools::zeroMargins(aLayout);
ModuleBase_Tools::zeroMargins(aLayout);
aLayout->addWidget(mySizeOfViewWidget);
aLayout->addWidget(aLabel);
+
+ myRemoveExternal = new QCheckBox(tr("Remove external dependencies"), aFirstWgt);
+ myRemoveExternal->setChecked(false);
+ aLayout->addWidget(myRemoveExternal);
+ myRemoveExternal->setVisible(false);
+
aLayout->addStretch(1);
myStackWidget->addWidget(aFirstWgt);
if (toShowConstraints.contains(aState))
aShowConstraints->setChecked(toShowConstraints[aState]);
}
+ myShowPoints = new QCheckBox(tr("Show free points"), this);
+ connect(myShowPoints, SIGNAL(toggled(bool)), this, SIGNAL(showFreePoints(bool)));
+ aLayout->addWidget(myShowPoints);
+
+ QPushButton* aPlaneBtn = new QPushButton(tr("Change sketch plane"), aSecondWgt);
+ connect(aPlaneBtn, SIGNAL(clicked(bool)), SLOT(onChangePlane()));
+ aLayout->addWidget(aPlaneBtn);
myStackWidget->addWidget(aSecondWgt);
//setLayout(aLayout);
else {
// it removes the processed value from the parameters list
ModuleBase_ViewerPrsPtr aValue = theValues.first();//.takeFirst();
- if (!theToValidate || isValidInFilters(aValue))
+ if (!theToValidate || isValidInFilters(aValue)) {
+ myIsSelection = true;
aDone = setSelectionCustom(aValue);
+ myIsSelection = false;
+ }
}
return aDone;
isSetSizeOfView = false;
}
}
- if (isSetSizeOfView)
- aModule->sketchMgr()->previewSketchPlane()->setSizeOfView(aSizeOfView, true);
+ aModule->sketchMgr()->previewSketchPlane()->setSizeOfView(aSizeOfView, isSetSizeOfView);
aModule->sketchMgr()->previewSketchPlane()->createSketchPlane(aSketch, myWorkshop);
- if (isSetSizeOfView)
- aModule->sketchMgr()->previewSketchPlane()->setSizeOfView(aSizeOfView, false);
}
// 2. if the planes were displayed, change the view projection
}
}
}
- if (aModule)
- aModule->onViewTransformed();
-
+ if (myOpenTransaction) {
+ SessionPtr aMgr = ModelAPI_Session::get();
+ aMgr->finishOperation();
+ myOpenTransaction = false;
+ }
// 3. Clear text in the label
myStackWidget->setCurrentIndex(1);
//myLabel->setText("");
myWorkshop->selectionActivate()->updateSelectionFilters();
myWorkshop->selectionActivate()->updateSelectionModes();
+ if (aModule)
+ aModule->onViewTransformed();
+
// 6. Update sketcher actions
XGUI_ActionsMgr* anActMgr = aWorkshop->actionsMgr();
myWorkshop->updateCommandStatus();
aWorkshop->selector()->clearSelection();
myWorkshop->viewer()->update();
+
+ myRemoveExternal->setVisible(false);
}
std::shared_ptr<GeomAPI_Pln> PartSet_WidgetSketchLabel::plane() const
bool PartSet_WidgetSketchLabel::setSelectionCustom(const ModuleBase_ViewerPrsPtr& thePrs)
{
+ if (myIsSelection && myRemoveExternal->isVisible()) {
+ if (myRemoveExternal->isChecked()) {
+ myFeature->customAction(SketchPlugin_Sketch::ACTION_REMOVE_EXTERNAL());
+ }
+ }
return fillSketchPlaneBySelection(thePrs);
}
else {
aSelAttr->setValue(aFeature, GeomShapePtr());
GeomShapePtr aShape = aSelAttr->value();
- if (!aShape.get() && aSelAttr->contextFeature()->firstResult().get()) {
+ if (!aShape.get() && aSelAttr->contextFeature().get() &&
+ aSelAttr->contextFeature()->firstResult().get()) {
aShape = aSelAttr->contextFeature()->firstResult()->shape();
}
- if (aShape.get()) {
+ if (aShape.get() && aShape->isPlanar()) {
const TopoDS_Shape& aTDShape = aShape->impl<TopoDS_Shape>();
setSketchPlane(aTDShape);
isOwnerSet = true;
}
return aResult;
}
+
+//******************************************************
+void PartSet_WidgetSketchLabel::onChangePlane()
+{
+ PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
+ if (aModule) {
+ mySizeOfViewWidget->setVisible(false);
+ myRemoveExternal->setVisible(true);
+ myStackWidget->setCurrentIndex(0);
+
+ CompositeFeaturePtr aSketch = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
+ PartSet_Tools::nullifySketchPlane(aSketch);
+
+ Handle(SelectMgr_Filter) aFilter = aModule->selectionFilter(SF_SketchPlaneFilter);
+ if (!aFilter.IsNull()) {
+ std::shared_ptr<GeomAPI_Pln> aPln;
+ Handle(ModuleBase_ShapeInPlaneFilter)::DownCast(aFilter)->setPlane(aPln);
+ }
+ XGUI_Workshop* aWorkshop = aModule->getWorkshop();
+
+ aWorkshop->selectionActivate()->updateSelectionFilters();
+ aWorkshop->selectionActivate()->updateSelectionModes();
+
+ SessionPtr aMgr = ModelAPI_Session::get();
+ aMgr->startOperation("Change Sketch plane");
+ myOpenTransaction = true;
+ }
+}
+
+void PartSet_WidgetSketchLabel::setShowPointsState(bool theState)
+{
+ bool aBlock = myShowPoints->blockSignals(true);
+ myShowPoints->setChecked(theState);
+ myShowPoints->blockSignals(aBlock);
+}