#include <gp_Dir.hxx>
#include <AIS_Shape.hxx>
#include <AIS_DimensionSelectionMode.hxx>
+#include <Bnd_Box.hxx>
#include <Config_WidgetAPI.h>
#include <Config_PropManager.h>
#include <QLabel>
#include <QApplication>
#include <QVBoxLayout>
+#include <QHBoxLayout>
#include <QCheckBox>
#include <QGroupBox>
#include <QPushButton>
#include <QStackedWidget>
+#include <QLineEdit>
+#include <QDoubleValidator>
+#ifndef DBL_MAX
+#define DBL_MAX 1.7976931348623158e+308
+#endif
PartSet_WidgetSketchLabel::PartSet_WidgetSketchLabel(QWidget* theParent,
ModuleBase_IWorkshop* theWorkshop,
// Define label for plane selection
QWidget* aFirstWgt = new QWidget(this);
+ // Size of the View control
+ mySizeOfViewWidget = new QWidget(aFirstWgt);
+ QHBoxLayout* aSizeLayout = new QHBoxLayout(mySizeOfViewWidget);
+ aSizeLayout->addWidget(new QLabel("Size of the view", mySizeOfViewWidget));
+ mySizeOfView = new QLineEdit(mySizeOfViewWidget);
+
+ QDoubleValidator* aValidator = new QDoubleValidator(0, DBL_MAX, 12, mySizeOfView);
+ aValidator->setLocale(ModuleBase_Tools::doubleLocale());
+ aValidator->setNotation(QDoubleValidator::StandardNotation);
+ mySizeOfView->setValidator(aValidator);
+ aSizeLayout->addWidget(mySizeOfView);
+
QString aText = QString::fromStdString(theData->getProperty("title"));
QLabel* aLabel = new QLabel(aText, aFirstWgt);
aLabel->setWordWrap(true);
aLayout = new QVBoxLayout(aFirstWgt);
ModuleBase_Tools::zeroMargins(aLayout);
+ aLayout->addWidget(mySizeOfViewWidget);
aLayout->addWidget(aLabel);
+ aLayout->addStretch(1);
myStackWidget->addWidget(aFirstWgt);
myViewInverted = new QCheckBox(tr("Reversed"), aViewBox);
aViewLayout->addWidget(myViewInverted);
- QPushButton* aSetViewBtn =
+ QPushButton* aSetViewBtn =
new QPushButton(QIcon(":icons/plane_view.png"), tr("Set plane view"), aViewBox);
connect(aSetViewBtn, SIGNAL(clicked(bool)), this, SLOT(onSetPlaneView()));
aViewLayout->addWidget(aSetViewBtn);
if (aModule)
aModule->onViewTransformed();
}
+ QString aSizeOfViewStr = mySizeOfView->text();
+ if (!aSizeOfViewStr.isEmpty()) {
+ bool isOk;
+ double aSizeOfView = aSizeOfViewStr.toDouble(&isOk);
+ if (isOk && aSizeOfView > 0) {
+ Handle(V3d_View) aView3d = myWorkshop->viewer()->activeView();
+ if (!aView3d.IsNull()) {
+ Bnd_Box aBndBox;
+ double aHalfSize = aSizeOfView/2.0;
+ aBndBox.Update(-aHalfSize, -aHalfSize, -aHalfSize, aHalfSize, aHalfSize, aHalfSize);
+ aView3d->FitAll(aBndBox, 0.01, false);
+ }
+ }
+ }
}
// 3. Clear text in the label
myStackWidget->setCurrentIndex(1);
//myLabel->setText("");
//myLabel->setToolTip("");
XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myWorkshop);
- disconnect(aWorkshop->selector(), SIGNAL(selectionChanged()),
+ disconnect(aWorkshop->selector(), SIGNAL(selectionChanged()),
this, SLOT(onSelectionChanged()));
// 4. deactivate face selection filter
activateFilters(false);
// 5. Clear selection mode and define sketching mode
- //XGUI_Displayer* aDisp = aWorkshop->displayer();
- //aDisp->closeLocalContexts();
emit planeSelected(plane());
// after the plane is selected in the sketch, the sketch selection should be activated
// it can not be performed in the sketch label widget because, we don't need to switch off
if (thePrs->object() && (theFeature != thePrs->object())) {
DataPtr aData = theFeature->data();
- AttributeSelectionPtr aSelAttr =
+ AttributeSelectionPtr aSelAttr =
std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
(aData->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID()));
if (aSelAttr) {
if (!aBodyIsVisualized) {
// We have to select a plane before any operation
myPreviewPlanes->showPreviewPlanes(myWorkshop);
+ mySizeOfViewWidget->setVisible(true);
}
+ else
+ mySizeOfViewWidget->setVisible(false);
+
activateSelection(true);
//myLabel->setText(myText);