// Author: Sergey TELKOV
//
#include "ModuleBase_DoubleSpinBox.h"
+#include "ModuleBase_Tools.h"
#include <QLineEdit>
#include <QDoubleValidator>
myCleared(false),
myIsEmitKeyPressEvent(false)
{
- // VSR 01/07/2010: Disable thousands separator for spin box
- // (to avoid inconsistency of double-2-string and string-2-double conversion)
- QLocale loc;
- loc.setNumberOptions(loc.numberOptions() |
- QLocale::OmitGroupSeparator |
- QLocale::RejectGroupSeparator);
- setLocale(loc);
+ setLocale(ModuleBase_Tools::doubleLocale());
// MPV 15/09/2014: this must be set before setDecimals;
// otherwise in release mode setDecimals may crash
#include <ModuleBase_LabelValue.h>
#include <ModuleBase_IconFactory.h>
+#include <ModuleBase_Tools.h>
#include <QHBoxLayout>
#include <QLabel>
myLabelValue = new QLabel("", this);
aLayout->addWidget(myLabelValue, 1);
- // VSR 01/07/2010: Disable thousands separator for spin box
- // (to avoid inconsistency of double-2-string and string-2-double conversion)
- QLocale loc;
- loc.setNumberOptions(loc.numberOptions() |
- QLocale::OmitGroupSeparator |
- QLocale::RejectGroupSeparator);
- setLocale(loc);
-
+ setLocale(ModuleBase_Tools::doubleLocale());
aLayout->addStretch(1);
}
QString aStrValue = locale().toString(theValue, myPrecision >= 0 ? 'f' : 'g', qAbs(myPrecision));
myLabelValue->setText(aStrValue);
- myLabelValue->setToolTip(QString::number(theValue));
+ myLabelValue->setToolTip(aStrValue);
}
return aResult;
}
+//**************************************************************
+QLocale doubleLocale()
+{
+ // VSR 01/07/2010: Disable thousands separator for spin box
+ // (to avoid inconsistency of double-2-string and string-2-double conversion)
+ QLocale aLocale;
+ aLocale.setNumberOptions(aLocale.numberOptions() |
+ QLocale::OmitGroupSeparator |
+ QLocale::RejectGroupSeparator);
+ return aLocale;
+}
+
//**************************************************************
void refsToFeatureInFeatureDocument(const ObjectPtr& theObject,
std::set<FeaturePtr>& theRefFeatures)
#include <QIcon>
#include <QPixmap>
+#include <QLocale>
#include <map>
MODULEBASE_EXPORT QString wrapTextByWords(const QString& theValue, QWidget* theWidget,
int theMaxLineInPixels = 150);
+/// Generates a locale to disable thousands separator for spin box
+/// (to avoid inconsistency of double-2-string and string-2-double conversion)
+/// \return locale
+MODULEBASE_EXPORT QLocale doubleLocale();
+
/// Returns a container of referenced feature to the current object in the object document.
/// \param theObject an object, which will be casted to a feature type
/// \param theRefFeatures an output container
#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", aFirstWgt));
+ mySizeOfView = new QLineEdit(aFirstWgt);
+
+ 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);
myStackWidget->addWidget(aFirstWgt);
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);
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);
class XGUI_Workshop;
class QCheckBox;
class QStackedWidget;
+class QLineEdit;
/**
* \ingroup Modules
QMap<PartSet_Tools::ConstraintVisibleState, QCheckBox*> myShowConstraints;
+ QWidget* mySizeOfViewWidget;
QStackedWidget* myStackWidget;
+ QLineEdit* mySizeOfView;
};
#endif
#include <AppElements_Viewer.h>
#endif
-#ifdef VINSPECTOR\r
-#include <VInspectorAPI_PluginMgr.h>\r
-#include <VInspectorAPI_Communicator.h>\r
+#ifdef VINSPECTOR
+#include <VInspectorAPI_PluginMgr.h>
+#include <VInspectorAPI_Communicator.h>
-static bool FirstCall = true;\r
+static bool FirstCall = true;
#endif
aContext = myWorkshop->mainWindow()->viewer()->AISContext();
#endif
-#ifdef VINSPECTOR\r
- if (FirstCall) {\r
+#ifdef VINSPECTOR
+ if (FirstCall) {
VInspectorAPI_PluginMgr::activateVInspector("VInspector.dll", aContext);
FirstCall = false;
}