#include "PartSet_Tools.h"
#include "PartSet_Module.h"
#include "PartSet_PreviewPlanes.h"
+#include "PartSet_SketcherReentrantMgr.h"
#include "SketchPlugin_SketchEntity.h"
#include <ModelAPI_ResultBody.h>
#include <ModelAPI_Tools.h>
+#include <ModelAPI_AttributeString.h>
+#include <ModelAPI_Events.h>
#include <ModuleBase_Operation.h>
#include <ModuleBase_ViewerPrs.h>
// Size of the View control
mySizeOfViewWidget = new QWidget(aFirstWgt);
QHBoxLayout* aSizeLayout = new QHBoxLayout(mySizeOfViewWidget);
- aSizeLayout->addWidget(new QLabel("Size of the view", mySizeOfViewWidget));
+ aSizeLayout->addWidget(new QLabel(tr("Size of the view"), mySizeOfViewWidget));
mySizeOfView = new QLineEdit(mySizeOfViewWidget);
QDoubleValidator* aValidator = new QDoubleValidator(0, DBL_MAX, 12, mySizeOfView);
mySizeOfView->setValidator(aValidator);
aSizeLayout->addWidget(mySizeOfView);
- QString aText = QString::fromStdString(theData->getProperty("title"));
+ QString aText = translate(theData->getProperty("title"));
QLabel* aLabel = new QLabel(aText, aFirstWgt);
aLabel->setWordWrap(true);
- QString aTooltip = QString::fromStdString(theData->getProperty("tooltip"));
+ QString aTooltip = translate(theData->getProperty("tooltip"));
aLabel->setToolTip(aTooltip);
aLabel->setIndent(5);
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);
+ myAutoConstraints = new QCheckBox(tr("Automatic constraints"), this);
+ myAutoConstraints->setToolTip(tr("Automatic vertical and horizontal constraints"));
+ connect(myAutoConstraints, SIGNAL(toggled(bool)), this, SIGNAL(autoConstraints(bool)));
+ aLayout->addWidget(myAutoConstraints);
QPushButton* aPlaneBtn = new QPushButton(tr("Change sketch plane"), aSecondWgt);
connect(aPlaneBtn, SIGNAL(clicked(bool)), SLOT(onChangePlane()));
aLayout->addWidget(aPlaneBtn);
+ aLayout->addSpacing(15);
+
+ myDoFLabel = new QLabel("", aSecondWgt);
+ aLayout->addWidget(myDoFLabel);
+
+ myShowDOFBtn = new QPushButton(tr("Show remaining DoFs"), aSecondWgt);
+ aLayout->addWidget(myShowDOFBtn);
+ myShowDOFBtn->hide();
+ connect(myShowDOFBtn, SIGNAL(clicked(bool)), SLOT(onShowDOF()));
+
myStackWidget->addWidget(aSecondWgt);
//setLayout(aLayout);
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
void PartSet_WidgetSketchLabel::activateCustom()
{
+ PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
+ if (aModule) {
+ bool isBlocked = myAutoConstraints->blockSignals(true);
+ myAutoConstraints->setChecked(aModule->sketchReentranceMgr()->isAutoConstraints());
+ myAutoConstraints->blockSignals(isBlocked);
+ }
+
std::shared_ptr<GeomAPI_Pln> aPlane = plane();
if (aPlane.get()) {
myStackWidget->setCurrentIndex(1);
if (aHidePreview)
myWorkshop->viewer()->update();
+
+ if (myOpenTransaction) {
+ SessionPtr aMgr = ModelAPI_Session::get();
+ aMgr->finishOperation();
+ myOpenTransaction = false;
+ }
}
void PartSet_WidgetSketchLabel::selectionModes(int& theModuleSelectionModes, QIntList& theModes)
myRemoveExternal->setVisible(true);
myStackWidget->setCurrentIndex(0);
+ bool aBodyIsVisualized = myPreviewPlanes->hasVisualizedBodies(myWorkshop);
+
+ if (!aBodyIsVisualized) {
+ // We have to select a plane before any operation
+ myPreviewPlanes->showPreviewPlanes(myWorkshop);
+ }
+
CompositeFeaturePtr aSketch = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
PartSet_Tools::nullifySketchPlane(aSketch);
aWorkshop->selectionActivate()->updateSelectionModes();
SessionPtr aMgr = ModelAPI_Session::get();
- aMgr->startOperation();
+ aMgr->startOperation("Change Sketch plane");
myOpenTransaction = true;
}
-}
\ No newline at end of file
+}
+
+void PartSet_WidgetSketchLabel::setShowPointsState(bool theState)
+{
+ bool aBlock = myShowPoints->blockSignals(true);
+ myShowPoints->setChecked(theState);
+ myShowPoints->blockSignals(aBlock);
+}
+
+bool PartSet_WidgetSketchLabel::restoreValueCustom()
+{
+ if (myFeature.get()) {
+ CompositeFeaturePtr aSketch = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
+ if (aSketch.get() && (aSketch->numberOfSubs() > 0)) {
+ AttributeStringPtr aDOFStr = aSketch->string("SolverDOF");
+ if (aDOFStr.get()) {
+ QString aVal(aDOFStr->value().c_str());
+ if (aVal.contains('=')) {
+ // to support old data
+ aVal = aVal.right(aVal.length() - aVal.lastIndexOf('='));
+ }
+ int aDoF = aVal.toInt();
+ if (aDoF == 0) {
+ myDoFLabel->setText(tr("Sketch is fully fixed (DoF = 0)"));
+ myShowDOFBtn->hide();
+ } else {
+ myDoFLabel->setText(tr("DoF (degrees of freedom) = ") + aVal);
+ CompositeFeaturePtr aCompFeature = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
+ if (aCompFeature.get() && aCompFeature->numberOfSubs() > 1)
+ myShowDOFBtn->show();
+ }
+ }
+ }
+ else {
+ myDoFLabel->setText("");
+ myShowDOFBtn->hide();
+ }
+ }
+ return true;
+}
+
+
+void PartSet_WidgetSketchLabel::onShowDOF()
+{
+ CompositeFeaturePtr aCompFeature = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
+ if (aCompFeature.get() && aCompFeature->numberOfSubs() > 1) {
+ static const Events_ID anEvent = Events_Loop::eventByName(EVENT_GET_DOF_OBJECTS);
+ ModelAPI_EventCreator::get()->sendUpdated(aCompFeature->subFeature(0), anEvent);
+ Events_Loop::loop()->flush(anEvent);
+ }
+}