aMessage->setAttributeId(anAttributeID);
aMessage->setObligatory(getBooleanAttribute(theNode, ATTR_OBLIGATORY, true));
aMessage->setConcealment(getBooleanAttribute(theNode, ATTR_CONCEALMENT, false));
+ //aMessage->setCaseId
Events_Loop::loop()->send(aMessage);
}
}
<!-- Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
<source>
- <shape_selector id="firstPoint"
- label="First point"
- icon=":icons/point.png"
- tooltip="Select a first point"
- shape_types="vertex">
- <selection_filter id="NoConstructionSubShapesFilter"/>
- </shape_selector>
- <shape_selector id="secondPoint"
- label="Second point"
- icon=":icons/point.png"
- tooltip="Select a second point"
- shape_types="vertex">
- <selection_filter id="NoConstructionSubShapesFilter"/>
- <validator id="PartSet_DifferentShapes"/>
- </shape_selector>
+ <toolbox>
+ <box id="AxisByPointsCase" title="By two points">
+ <shape_selector id="firstPoint"
+ label="First point"
+ icon=":icons/point.png"
+ tooltip="Select a first point"
+ shape_types="vertex">
+ <selection_filter id="NoConstructionSubShapesFilter"/>
+ </shape_selector>
+ <shape_selector id="secondPoint"
+ label="Second point"
+ icon=":icons/point.png"
+ tooltip="Select a second point"
+ shape_types="vertex">
+ <selection_filter id="NoConstructionSubShapesFilter"/>
+ <validator id="PartSet_DifferentShapes"/>
+ </shape_selector>
+ </box>
+ <box id="AxisByCylindricalFaceCase" title="As axis of cylindrical face">
+ <shape_selector id="main_object"
+ label="Main object"
+ icon=":icons/circle.png"
+ tooltip="Select a cylindrical object"
+ shape_types="face solid shell">
+ </shape_selector>
+ </box>
+ </toolbox>
+
</source>
#include <Events_Loop.h>
#include <QEvent>
-#include <QWidget>
#include <QGraphicsDropShadowEffect>
#include <QColor>
#include <QLabel>
-ModuleBase_ModelWidget::ModuleBase_ModelWidget(QWidget* theParent, const Config_WidgetAPI* theData,
+ModuleBase_ModelWidget::ModuleBase_ModelWidget(QWidget* theParent,
+ const Config_WidgetAPI* theData,
const std::string& theParentId)
- : QObject(theParent),
- myParentId(theParentId)
+ : QWidget(theParent),
+ myParentId(theParentId),
+ myIsEditing(false)
{
myDefaultValue = theData->getProperty(ATTR_DEFAULT);
myIsComputedDefault = theData->getProperty(ATTR_DEFAULT) == DOUBLE_WDG_DEFAULT_COMPUTED;
#include <ModelAPI_Feature.h>
-#include <QObject>
+#include <QWidget>
#include <memory>
* Every widget are able to save/restore data from the model and/or to contain other widgets.
*
*/
-class MODULEBASE_EXPORT ModuleBase_ModelWidget : public QObject
+class MODULEBASE_EXPORT ModuleBase_ModelWidget : public QWidget
{
Q_OBJECT
public:
/// The methiod called when widget is deactivated
virtual void deactivate() {}
- /// Returns the internal parent wiget control, that can be shown anywhere
- /// \returns the widget
- virtual QWidget* getControl() const = 0;
-
/// Returns list of widget controls
/// \return a control list
virtual QList<QWidget*> getControls() const = 0;
{
if(!theLayout)
return;
- theLayout->setContentsMargins(2, 5, 5, 2);
+ theLayout->setContentsMargins(2, 5, 2, 5);
theLayout->setSpacing(4);
}
{
}
-QWidget* ModuleBase_WidgetBoolValue::getControl() const
-{
- return myCheckBox;
-}
-
bool ModuleBase_WidgetBoolValue::storeValue() const
{
DataPtr aData = myFeature->data();
virtual QList<QWidget*> getControls() const;
- QWidget* getControl() const;
-
protected:
/// Saves the internal parameters to the given feature
/// \return True in success
const std::string& theParentId)
: ModuleBase_ModelWidget(theParent, theData, theParentId)
{
- myContainer = new QWidget(theParent);
- QHBoxLayout* aLayout = new QHBoxLayout(myContainer);
+ QHBoxLayout* aLayout = new QHBoxLayout(this);
ModuleBase_Tools::adjustMargins(aLayout);
QString aLabelText = QString::fromStdString(theData->widgetLabel());
QString aLabelIcon = QString::fromStdString(theData->widgetIcon());
- myLabel = new QLabel(aLabelText, myContainer);
+ myLabel = new QLabel(aLabelText, this);
if (!aLabelIcon.isEmpty())
myLabel->setPixmap(QPixmap(aLabelIcon));
aLayout->addWidget(myLabel);
- myCombo = new QComboBox(myContainer);
+ myCombo = new QComboBox(this);
aLayout->addWidget(myCombo, 1);
std::string aTypes = theData->getProperty("string_list");
virtual bool focusTo();
- /// Returns the internal parent wiget control, that can be shown anywhere
- /// \returns the widget
- QWidget* getControl() const
- {
- return myContainer;
- }
-
/// Returns list of widget controls
/// \return a controls list
virtual QList<QWidget*> getControls() const;
void onCurrentIndexChanged(int theIndex);
private:
- /// Container widget
- QWidget* myContainer;
-
/// The label
QLabel* myLabel;
#include <ModelAPI_Events.h>
#include <QWidget>
-#include <QLayout>
+#include <QFormLayout>
#include <QLabel>
#include <QEvent>
#include <QTimer>
const std::string& theParentId)
: ModuleBase_ModelWidget(theParent, theData, theParentId)
{
- myContainer = new QWidget(theParent);
- QHBoxLayout* aControlLay = new QHBoxLayout(myContainer);
+ QFormLayout* aControlLay = new QFormLayout(this);
ModuleBase_Tools::adjustMargins(aControlLay);
QString aLabelText = QString::fromStdString(theData->widgetLabel());
QString aLabelIcon = QString::fromStdString(theData->widgetIcon());
- myLabel = new QLabel(aLabelText, myContainer);
+ myLabel = new QLabel(aLabelText, this);
if (!aLabelIcon.isEmpty())
myLabel->setPixmap(QPixmap(aLabelIcon));
- aControlLay->addWidget(myLabel);
- mySpinBox = new ModuleBase_DoubleSpinBox(myContainer);
+ mySpinBox = new ModuleBase_DoubleSpinBox(this);
QString anObjName = QString::fromStdString(attributeID());
mySpinBox->setObjectName(anObjName);
QString aTTip = QString::fromStdString(theData->widgetTooltip());
mySpinBox->setToolTip(aTTip);
- aControlLay->addWidget(mySpinBox);
- aControlLay->setStretch(1, 1);
-
+ aControlLay->addRow(myLabel, mySpinBox);
connect(mySpinBox, SIGNAL(valueChanged(double)), this, SIGNAL(valuesChanged()));
}
/// \return a control list
virtual QList<QWidget*> getControls() const;
- /// Returns the internal parent wiget control, that can be shown anywhere
- /// \returns the widget
- QWidget* getControl() const
- {
- return myContainer;
- }
-
public slots:
// Delayed value chnged: when user starts typing something,
// it gives him a 0,5 second to finish typing, when sends valueChnaged() signal
virtual bool storeValue() const;
protected:
- /// Container for thw widget controls
- QWidget* myContainer;
-
/// Label of the widget
QLabel* myLabel;
return;
QVBoxLayout* aWidgetLay = new QVBoxLayout(theParent);
+ bool isStretchLayout = false;
do { //Iterate over each node
std::string aWdgType = myWidgetApi->widgetType();
//Create a widget (doublevalue, groupbox, toolbox, etc.
do {
QString aPageName = qs(myWidgetApi->getProperty(CONTAINER_PAGE_NAME));
QWidget* aPage = new QWidget(aWidget);
- ModuleBase_Tools::adjustMargins(aPage);
createWidget(aPage);
+ ModuleBase_Tools::adjustMargins(aPage);
if (aWdgType == WDG_SWITCH) {
ModuleBase_WidgetSwitch* aSwitch = qobject_cast<ModuleBase_WidgetSwitch*>(aWidget);
aSwitch->addPage(aPage, aPageName);
QToolBox* aToolbox = qobject_cast<QToolBox*>(aWidget);
aToolbox->addItem(aPage, aPageName);
}
+
} while (myWidgetApi->toNextWidget());
}
+ if (aWidget && !isStretchLayout) {
+ isStretchLayout = !hasExpandingControls(aWidget);
+ }
} while (myWidgetApi->toNextWidget());
+ if (isStretchLayout) {
+ aWidgetLay->addStretch(1);
+ }
theParent->setLayout(aWidgetLay);
}
-
-QWidget* ModuleBase_WidgetFactory::labelControl(QWidget* theParent)
+bool ModuleBase_WidgetFactory::hasExpandingControls(QWidget* theParent)
{
- ModuleBase_WidgetLabel* aWgt =
- new ModuleBase_WidgetLabel(theParent, myWidgetApi, myParentId);
- myModelWidgets.append(aWgt);
- return aWgt->getControl();
+ bool result = false;
+ QList<QWidget *> aListToCheck;
+ aListToCheck << theParent;
+ ModuleBase_ModelWidget* aModelWidget = qobject_cast<ModuleBase_ModelWidget*>(theParent);
+ if(aModelWidget) {
+ aListToCheck << aModelWidget->getControls();
+ }
+ foreach(QWidget* eachWidget, aListToCheck) {
+ QSizePolicy::Policy aVPolicy = eachWidget->sizePolicy().verticalPolicy();
+ if(aVPolicy & QSizePolicy::ExpandFlag) {
+ result = true;
+ }
+ }
+ return result;
}
-
QWidget* ModuleBase_WidgetFactory::createWidgetByType(const std::string& theType,
QWidget* theParent)
{
} else if (theType == WDG_BOOLVALUE) {
result = booleanControl(theParent);
- //} else if (theType == WDG_FEATURE_SELECTOR) {
- // result = featureSelectorControl(theParent);
-
- //} else if (theType == WDG_FEATURE_OR_ATTRIBUTE_SELECTOR) {
- // result = featureOrAttributeSelectorControl(theParent);
-
} else if (theType == WDG_DOUBLEVALUE_EDITOR) {
result = doubleValueEditor(theParent);
result = aGroupBox;
} else if (theType == WDG_TOOLBOX) {
result = new QToolBox(theParent);
+ // Dark-grey rounded tabs with button-like border #and bold font
+ QString css = "QToolBox::tab{background-color:#c8c8c8;"
+ "border-radius:5px;"
+ "border:1px inset;"
+ //"font-weight:700;"
+ "border-color:#fff #505050 #505050 #fff;}";
+ result->setStyleSheet(css);
+ // default vertical size policy is preferred
+ QSizePolicy aSizePolicy = result->sizePolicy();
+ aSizePolicy.setVerticalPolicy(QSizePolicy::MinimumExpanding);
+ result->setSizePolicy(aSizePolicy);
} else if (theType == WDG_SWITCH) {
result = new ModuleBase_WidgetSwitch(theParent);
} else if (theType == WDG_TOOLBOX_BOX || theType == WDG_SWITCH_CASE) {
+ // Do nothing for "box" and "case"
result = NULL;
}
#ifdef _DEBUG
return result;
}
+QWidget* ModuleBase_WidgetFactory::labelControl(QWidget* theParent)
+{
+ ModuleBase_WidgetLabel* aWgt =
+ new ModuleBase_WidgetLabel(theParent, myWidgetApi, myParentId);
+ myModelWidgets.append(aWgt);
+ return aWgt;
+}
+
QWidget* ModuleBase_WidgetFactory::doubleSpinBoxControl(QWidget* theParent)
{
ModuleBase_WidgetDoubleValue* aDblWgt =
new ModuleBase_WidgetDoubleValue(theParent, myWidgetApi, myParentId);
myModelWidgets.append(aDblWgt);
- return aDblWgt->getControl();
+ return aDblWgt;
}
QWidget* ModuleBase_WidgetFactory::doubleValueEditor(QWidget* theParent)
ModuleBase_WidgetEditor* aWidget =
new ModuleBase_WidgetEditor(theParent, myWidgetApi, myParentId);
myModelWidgets.append(aWidget);
- return aWidget->getControl();
+ return aWidget;
}
QWidget* ModuleBase_WidgetFactory::shapeSelectorControl(QWidget* theParent)
ModuleBase_WidgetShapeSelector* aSelector =
new ModuleBase_WidgetShapeSelector(theParent, myWorkshop, myWidgetApi, myParentId);
myModelWidgets.append(aSelector);
- return aSelector->getControl();
+ return aSelector;
}
QWidget* ModuleBase_WidgetFactory::booleanControl(QWidget* theParent)
ModuleBase_WidgetBoolValue* aBoolWgt =
new ModuleBase_WidgetBoolValue(theParent, myWidgetApi, myParentId);
myModelWidgets.append(aBoolWgt);
- return aBoolWgt->getControl();
+ return aBoolWgt;
}
QWidget* ModuleBase_WidgetFactory::fileSelectorControl(QWidget* theParent)
ModuleBase_WidgetFileSelector* aFileSelectorWgt =
new ModuleBase_WidgetFileSelector(theParent, myWidgetApi, myParentId);
myModelWidgets.append(aFileSelectorWgt);
- return aFileSelectorWgt->getControl();
+ return aFileSelectorWgt;
}
QWidget* ModuleBase_WidgetFactory::choiceControl(QWidget* theParent)
ModuleBase_WidgetChoice* aChoiceWgt =
new ModuleBase_WidgetChoice(theParent, myWidgetApi,myParentId);
myModelWidgets.append(aChoiceWgt);
- return aChoiceWgt->getControl();
+ return aChoiceWgt;
}
QWidget* ModuleBase_WidgetFactory::lineEditControl(QWidget* theParent)
ModuleBase_WidgetLineEdit* aLineEditWgt =
new ModuleBase_WidgetLineEdit(theParent, myWidgetApi,myParentId);
myModelWidgets.append(aLineEditWgt);
- return aLineEditWgt->getControl();
+ return aLineEditWgt;
}
QWidget* ModuleBase_WidgetFactory::multiSelectorControl(QWidget* theParent)
ModuleBase_WidgetMultiSelector* aMultiselectorWgt =
new ModuleBase_WidgetMultiSelector(theParent, myWorkshop, myWidgetApi,myParentId);
myModelWidgets.append(aMultiselectorWgt);
- return aMultiselectorWgt->getControl();
+ return aMultiselectorWgt;
}
QString ModuleBase_WidgetFactory::qs(const std::string& theStdString)
/// \param theParent a parent widget
void createWidget(QWidget* theParent);
+
/// Returns list of model widgets
QList<ModuleBase_ModelWidget*> getModelWidgets() const
{
}
protected:
+ /// check if ModuleBase_Widget has expandable widgets in getControls
+ bool hasExpandingControls(QWidget* theParent);
/// Create widget by its type
/// \param theType a type
/// \param theParent a parent widget
myTitle = QString::fromStdString(theData->getProperty("title"));
myDefaultPath = QString::fromStdString(theData->getProperty("path"));
- myMainWidget = new QWidget(theParent);
- QGridLayout* aMainLay = new QGridLayout(myMainWidget);
+ QGridLayout* aMainLay = new QGridLayout(this);
ModuleBase_Tools::adjustMargins(aMainLay);
- QLabel* aTitleLabel = new QLabel(myTitle, myMainWidget);
+ QLabel* aTitleLabel = new QLabel(myTitle, this);
aTitleLabel->setIndent(1);
aMainLay->addWidget(aTitleLabel, 0, 0);
- myPathField = new QLineEdit(myMainWidget);
+ myPathField = new QLineEdit(this);
aMainLay->addWidget(myPathField, 1, 0);
- QPushButton* aSelectPathBtn = new QPushButton("...", myMainWidget);
+ QPushButton* aSelectPathBtn = new QPushButton("...", this);
aSelectPathBtn->setToolTip(tr("Select file..."));
aSelectPathBtn->setMaximumWidth(20);
aSelectPathBtn->setMaximumHeight(20);
aMainLay->setColumnStretch(0, 1);
myPathField->setMinimumHeight(20);
aMainLay->setHorizontalSpacing(1);
- myMainWidget->setLayout(aMainLay);
+ this->setLayout(aMainLay);
connect(myPathField, SIGNAL(textChanged(const QString&)),
this, SLOT(onPathChanged()));
return true;
}
-QWidget* ModuleBase_WidgetFileSelector::getControl() const
-{
- return myMainWidget;
-}
-
QList<QWidget*> ModuleBase_WidgetFileSelector::getControls() const
{
QList<QWidget*> result;
- //QPushButton * aButton = myMainWidget->findChild<QPushButton *>();
+ //QPushButton * aButton = this->findChild<QPushButton *>();
//result << aButton;
result << myPathField;
return result;
void ModuleBase_WidgetFileSelector::onPathSelectionBtn()
{
QString aFilter = formatsString();
- QString aFileName = QFileDialog::getOpenFileName(myMainWidget, myTitle, myDefaultPath, aFilter);
+ QString aFileName = QFileDialog::getOpenFileName(this, myTitle, myDefaultPath, aFilter);
if (!aFileName.isEmpty()) {
myPathField->setText(aFileName);
}
virtual bool restoreValue();
- QWidget* getControl() const;
-
virtual QList<QWidget*> getControls() const;
/// Returns true if a file on the current path in the line edit
/// A control for path input
QLineEdit* myPathField;
- /// Container
- QWidget* myMainWidget;
-
/// A title of open file dialog box
QString myTitle;
#include "ModuleBase_WidgetLabel.h"
#include <Config_WidgetAPI.h>
+#include <ModuleBase_Tools.h>
#include <QLabel>
+#include <QVBoxLayout>
ModuleBase_WidgetLabel::ModuleBase_WidgetLabel(QWidget* theParent,
- const Config_WidgetAPI* theData,
- const std::string& theParentId)
+ const Config_WidgetAPI* theData,
+ const std::string& theParentId)
: ModuleBase_ModelWidget(theParent, theData, theParentId)
{
QString aText = QString::fromStdString(theData->getProperty("title"));
myLabel = new QLabel(aText, theParent);
myLabel->setWordWrap(true);
myLabel->setIndent(5);
+ myLabel->setAlignment(Qt::AlignLeft | Qt::AlignTop);
+ QVBoxLayout* aLayout = new QVBoxLayout(this);
+ ModuleBase_Tools::zeroMargins(aLayout);
+ aLayout->addWidget(myLabel);
+ setLayout(aLayout);
}
ModuleBase_WidgetLabel::~ModuleBase_WidgetLabel()
return QList<QWidget*>();
}
-QWidget* ModuleBase_WidgetLabel::getControl() const
-{
- return myLabel;
-}
virtual QList<QWidget*> getControls() const;
- QWidget* getControl() const;
-
/// This control doesn't accept focus
virtual bool focusTo() { return false; }
QLabel* myLabel;
};
-#endif
\ No newline at end of file
+#endif
#include <Config_WidgetAPI.h>
-#include <QHBoxLayout>
+#include <QFormLayout>
#include <QLabel>
#include <QLineEdit>
#include <QObject>
const std::string& theParentId)
: ModuleBase_ModelWidget(theParent, theData, theParentId)
{
- myMainWidget = new QWidget(theParent);
- QHBoxLayout* aMainLay = new QHBoxLayout(myMainWidget);
+ QFormLayout* aMainLay = new QFormLayout(this);
ModuleBase_Tools::adjustMargins(aMainLay);
QString aTitle = QString::fromStdString(theData->widgetLabel());
- QLabel* aTitleLabel = new QLabel(aTitle, myMainWidget);
- aMainLay->addWidget(aTitleLabel);
- myLineEdit = new QLineEdit(myMainWidget);
- aMainLay->addWidget(myLineEdit);
+ myLineEdit = new QLineEdit(this);
myLineEdit->setMinimumHeight(20);
- myMainWidget->setLayout(aMainLay);
+ aMainLay->addRow(aTitle, myLineEdit);
+ this->setLayout(aMainLay);
connect(myLineEdit, SIGNAL(textChanged(const QString&)), this, SLOT(onTextChanged()));
}
return true;
}
-QWidget* ModuleBase_WidgetLineEdit::getControl() const
-{
- return myMainWidget;
-}
-
QList<QWidget*> ModuleBase_WidgetLineEdit::getControls() const
{
QList<QWidget*> result;
virtual bool restoreValue();
- QWidget* getControl() const;
-
virtual QList<QWidget*> getControls() const;
public slots:
private:
/// A line edit control
QLineEdit* myLineEdit;
-
- /// A container widget
- QWidget* myMainWidget;
};
#endif /* MODULEBASE_WIDGETFILESELECTOR_H_ */
: ModuleBase_ModelWidget(theParent, theData, theParentId),
myWorkshop(theWorkshop), myIsActive(false)
{
- myMainWidget = new QWidget(theParent);
- QGridLayout* aMainLay = new QGridLayout(myMainWidget);
+ QGridLayout* aMainLay = new QGridLayout(this);
ModuleBase_Tools::adjustMargins(aMainLay);
- QLabel* aTypeLabel = new QLabel(tr("Type"), myMainWidget);
+ QLabel* aTypeLabel = new QLabel(tr("Type"), this);
aMainLay->addWidget(aTypeLabel, 0, 0);
- myTypeCombo = new QComboBox(myMainWidget);
+ myTypeCombo = new QComboBox(this);
// There is no sence to paramerize list of types while we can not parametrize selection mode
QString aTypesStr("Vertices Edges Faces Solids");
QStringList aShapeTypes = aTypesStr.split(' ');
myTypeCombo->addItems(aShapeTypes);
aMainLay->addWidget(myTypeCombo, 0, 1);
- QLabel* aListLabel = new QLabel(tr("Selected objects:"), myMainWidget);
+ QLabel* aListLabel = new QLabel(tr("Selected objects:"), this);
aMainLay->addWidget(aListLabel, 1, 0, 1, -1);
- myListControl = new QListWidget(myMainWidget);
+ myListControl = new QListWidget(this);
aMainLay->addWidget(myListControl, 2, 0, 2, -1);
aMainLay->setRowStretch(2, 1);
- aMainLay->addWidget(new QLabel(myMainWidget));
+ aMainLay->addWidget(new QLabel(this)); //FIXME(sbh)???
aMainLay->setRowMinimumHeight(3, 20);
- myMainWidget->setLayout(aMainLay);
+ this->setLayout(aMainLay);
connect(myTypeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(onSelectionTypeChanged()));
myCopyAction = new QAction(QIcon(":pictures/copy.png"), tr("Copy"), this);
return false;
}
-//********************************************************************
-QWidget* ModuleBase_WidgetMultiSelector::getControl() const
-{
- return myMainWidget;
-}
-
//********************************************************************
QList<QWidget*> ModuleBase_WidgetMultiSelector::getControls() const
{
virtual bool restoreValue();
- /// Returns the internal parent wiget control, that can be shown anywhere
- /// \returns the widget
- QWidget* getControl() const;
-
/// Returns list of widget controls
/// \return a control list
virtual QList<QWidget*> getControls() const;
/// Combobox of types
QComboBox* myTypeCombo;
- /// Container
- QWidget* myMainWidget;
-
//TODO: Move into the base of selectors
ModuleBase_IWorkshop* myWorkshop;
#include <QEvent>
#include <QDockWidget>
#include <QApplication>
+#include <QFormLayout>
#include <TopExp_Explorer.hxx>
#include <TopoDS_Shape.hxx>
: ModuleBase_ModelWidget(theParent, theData, theParentId),
myWorkshop(theWorkshop), myIsActive(false)
{
- myContainer = new QWidget(theParent);
- QHBoxLayout* aLayout = new QHBoxLayout(myContainer);
+ QFormLayout* aLayout = new QFormLayout(this);
ModuleBase_Tools::adjustMargins(aLayout);
QString aLabelText = QString::fromStdString(theData->widgetLabel());
QString aLabelIcon = QString::fromStdString(theData->widgetIcon());
- myLabel = new QLabel(aLabelText, myContainer);
+ myLabel = new QLabel(aLabelText, this);
if (!aLabelIcon.isEmpty())
myLabel->setPixmap(QPixmap(aLabelIcon));
- aLayout->addWidget(myLabel);
QString aToolTip = QString::fromStdString(theData->widgetTooltip());
- myTextLine = new QLineEdit(myContainer);
+ myTextLine = new QLineEdit(this);
myTextLine->setReadOnly(true);
myTextLine->setToolTip(aToolTip);
myTextLine->installEventFilter(this);
- aLayout->addWidget(myTextLine, 1);
+ aLayout->addRow(myLabel, myTextLine);
std::string aTypes = theData->getProperty("shape_types");
myShapeTypes = QString(aTypes.c_str()).split(' ', QString::SkipEmptyParts);
//********************************************************************
void ModuleBase_WidgetShapeSelector::raisePanel() const
{
- QWidget* aParent = myContainer->parentWidget();
+ QWidget* aParent = this->parentWidget();
QWidget* aLastPanel = 0;
while (!aParent->inherits("QDockWidget")) {
aLastPanel = aParent;
}
}
return true;
-}
\ No newline at end of file
+}
/// Defines if it is supposed that the widget should interact with the viewer.
virtual bool isViewerSelector() { return true; }
- /// Returns the internal parent wiget control, that can be shown anywhere
- /// \returns the widget
- QWidget* getControl() const
- {
- return myContainer;
- }
-
/// Returns list of widget controls
/// \return a control list
virtual QList<QWidget*> getControls() const;
//----------- Class members -------------
protected:
-
- /// Container of the widget's control
- QWidget* myContainer;
-
/// Label of the widget
QLabel* myLabel;
{
XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
XGUI_Workshop* aWorkshop = aConnector->workshop();
+ ModuleBase_ModelWidget* aWgt = NULL;
if (theType == "sketch-start-label") {
- PartSet_WidgetSketchLabel* aWgt = new PartSet_WidgetSketchLabel(theParent, theWidgetApi, theParentId);
- aWgt->setWorkshop(aWorkshop);
- connect(aWgt, SIGNAL(planeSelected(const std::shared_ptr<GeomAPI_Pln>&)),
+ PartSet_WidgetSketchLabel* aLabelWgt = new PartSet_WidgetSketchLabel(theParent, theWidgetApi, theParentId);
+ aLabelWgt->setWorkshop(aWorkshop);
+ connect(aLabelWgt, SIGNAL(planeSelected(const std::shared_ptr<GeomAPI_Pln>&)),
mySketchMgr, SLOT(onPlaneSelected(const std::shared_ptr<GeomAPI_Pln>&)));
- theModelWidgets.append(aWgt);
- return aWgt->getControl();
-
+ aWgt = aLabelWgt;
} else if (theType == "sketch-2dpoint_selector") {
- PartSet_WidgetPoint2D* aWgt = new PartSet_WidgetPoint2D(theParent, theWidgetApi, theParentId);
- aWgt->setWorkshop(aWorkshop);
- aWgt->setSketch(mySketchMgr->activeSketch());
-
- connect(aWgt, SIGNAL(vertexSelected()), this, SLOT(onVertexSelected()));
-
- theModelWidgets.append(aWgt);
- return aWgt->getControl();
-
+ PartSet_WidgetPoint2D* aPointWgt = new PartSet_WidgetPoint2D(theParent, theWidgetApi, theParentId);
+ aPointWgt->setWorkshop(aWorkshop);
+ aPointWgt->setSketch(mySketchMgr->activeSketch());
+ connect(aPointWgt, SIGNAL(vertexSelected()), this, SLOT(onVertexSelected()));
+ aWgt = aPointWgt;
} if (theType == "point2ddistance") {
- PartSet_WidgetPoint2dDistance* aWgt = new PartSet_WidgetPoint2dDistance(theParent, theWidgetApi, theParentId);
- aWgt->setWorkshop(aWorkshop);
- aWgt->setSketch(mySketchMgr->activeSketch());
-
- theModelWidgets.append(aWgt);
- return aWgt->getControl();
-
+ PartSet_WidgetPoint2dDistance* aDistanceWgt = new PartSet_WidgetPoint2dDistance(theParent, theWidgetApi, theParentId);
+ aDistanceWgt->setWorkshop(aWorkshop);
+ aDistanceWgt->setSketch(mySketchMgr->activeSketch());
+ aWgt = aDistanceWgt;
} if (theType == "sketch_shape_selector") {
- PartSet_WidgetShapeSelector* aWgt =
+ PartSet_WidgetShapeSelector* aShapeSelectorWgt =
new PartSet_WidgetShapeSelector(theParent, workshop(), theWidgetApi, theParentId);
- aWgt->setSketcher(mySketchMgr->activeSketch());
-
- theModelWidgets.append(aWgt);
- return aWgt->getControl();
-
+ aShapeSelectorWgt->setSketcher(mySketchMgr->activeSketch());
+ aWgt = aShapeSelectorWgt;
} if (theType == "sketch_constraint_shape_selector") {
- PartSet_WidgetConstraintShapeSelector* aWgt =
+ PartSet_WidgetConstraintShapeSelector* aConstraintShapeSelectorWgt =
new PartSet_WidgetConstraintShapeSelector(theParent, workshop(), theWidgetApi, theParentId);
- aWgt->setSketcher(mySketchMgr->activeSketch());
-
+ aConstraintShapeSelectorWgt->setSketcher(mySketchMgr->activeSketch());
+ aWgt = aConstraintShapeSelectorWgt;
+ }
+ if(aWgt)
theModelWidgets.append(aWgt);
- return aWgt->getControl();
-
- } else
- return 0;
+ return aWgt;
}
bool PartSet_Module::isSketchFeatureOperationActive() const
connect(myYSpin, SIGNAL(valueChanged(double)), this, SLOT(onValuesChanged()));
}
+ QVBoxLayout* aLayout = new QVBoxLayout(this);
+ ModuleBase_Tools::zeroMargins(aLayout);
+ aLayout->addWidget(myGroupBox);
+ setLayout(aLayout);
}
void PartSet_WidgetPoint2D::reset()
return true;
}
-QWidget* PartSet_WidgetPoint2D::getControl() const
-{
- return myGroupBox;
-}
-
QList<QWidget*> PartSet_WidgetPoint2D::getControls() const
{
QList<QWidget*> aControls;
virtual bool restoreValue();
- /// Returns the internal parent wiget control, that can be shown anywhere
- /// \returns the widget
- QWidget* getControl() const;
-
/// Returns list of widget controls
/// \return a control list
virtual QList<QWidget*> getControls() const;
#include <ModuleBase_Operation.h>
#include <ModuleBase_ViewerPrs.h>
+#include <ModuleBase_Tools.h>
#include <GeomAlgoAPI_FaceBuilder.h>
#include <GeomDataAPI_Point.h>
#include <QLabel>
#include <QTimer>
#include <QApplication>
+#include <QVBoxLayout>
PartSet_WidgetSketchLabel::PartSet_WidgetSketchLabel(QWidget* theParent,
const Config_WidgetAPI* theData,
const std::string& theParentId)
- : ModuleBase_ModelWidget(theParent, theData, theParentId), myPreviewDisplayed(false)
+ : ModuleBase_ModelWidget(theParent, theData, theParentId),
+ myPreviewDisplayed(false),
+ myWorkshop(NULL)
{
myText = QString::fromStdString(theData->getProperty("title"));
myLabel = new QLabel("", theParent);
mySelectionTimer = new QTimer(this);
connect(mySelectionTimer, SIGNAL(timeout()), SLOT(setSketchingMode()));
mySelectionTimer->setSingleShot(true);
+
+ QVBoxLayout* aLayout = new QVBoxLayout(this);
+ ModuleBase_Tools::zeroMargins(aLayout);
+ aLayout->addWidget(myLabel);
+ setLayout(aLayout);
}
PartSet_WidgetSketchLabel::~PartSet_WidgetSketchLabel()
return QList<QWidget*>();
}
-QWidget* PartSet_WidgetSketchLabel::getControl() const
-{
- return myLabel;
-}
-
void PartSet_WidgetSketchLabel::onPlaneSelected()
{
XGUI_Selection* aSelection = myWorkshop->selector()->selection();
/// \return a control list
virtual QList<QWidget*> getControls() const;
- QWidget* getControl() const;
-
/// The methiod called when widget is deactivated
virtual void deactivate();
foreach(QString aId, nestedCommands(aFeatureId)) {
std::list<ModelAPI_Validator*> aValidators;
std::list<std::list<std::string> > anArguments;
- if (!anArguments.empty()) {
- std::list<std::string> firstArg = anArguments.front();
- }
aFactory->validators(aId.toStdString(), aValidators, anArguments);
std::list<ModelAPI_Validator*>::iterator aValidator = aValidators.begin();
std::list<std::list<std::string> >::iterator aValidatorArgs = anArguments.begin();
#include <ModelAPI_Document.h>
#include <ModelAPI_Object.h>
+#include <ModuleBase_Tools.h>
+
#include <QLayout>
#include <QLabel>
#include <QLineEdit>
: QWidget(theParent)
{
QVBoxLayout* aLayout = new QVBoxLayout(this);
- aLayout->setContentsMargins(0, 0, 0, 0);
+ ModuleBase_Tools::zeroMargins(aLayout);
aLayout->setSpacing(0);
QFrame* aLabelWgt = new QFrame(this);
aLayout->addWidget(aLabelWgt);
QHBoxLayout* aLabelLay = new QHBoxLayout(aLabelWgt);
- aLabelLay->setContentsMargins(0, 0, 0, 0);
+ ModuleBase_Tools::zeroMargins(aLabelLay);
aLabelLay->setSpacing(0);
QLabel* aLbl = new QLabel(aLabelWgt);
#include <XGUI_ActionsMgr.h>
//#include <AppElements_Constants.h>
#include <ModuleBase_WidgetMultiSelector.h>
+#include <ModuleBase_Tools.h>
#include <QEvent>
#include <QFrame>
#include <QLayoutItem>
#include <QToolButton>
#include <QVBoxLayout>
-#include <QVBoxLayout>
+#include <QGridLayout>
#include <QWidget>
#include <QToolButton>
#include <QAction>
setStyleSheet("::title { position: relative; padding-left: 5px; text-align: left center }");
QWidget* aContent = new QWidget(this);
- myMainLayout = new QVBoxLayout(aContent);
+ myMainLayout = new QGridLayout(aContent);
+ const int kPanelColumn = 0;
+ int aPanelRow = 0;
myMainLayout->setContentsMargins(3, 3, 3, 3);
this->setWidget(aContent);
QFrame* aFrm = new QFrame(aContent);
- aFrm->setFrameStyle(QFrame::Sunken);
+ aFrm->setFrameStyle(QFrame::Raised);
aFrm->setFrameShape(QFrame::Panel);
QHBoxLayout* aBtnLay = new QHBoxLayout(aFrm);
- aBtnLay->setContentsMargins(0, 0, 0, 0);
- myMainLayout->addWidget(aFrm);
+ ModuleBase_Tools::zeroMargins(aBtnLay);
+ myMainLayout->addWidget(aFrm, aPanelRow++, kPanelColumn);
QStringList aBtnNames;
aBtnNames << QString(PROP_PANEL_HELP)
aBtnLay->addWidget(aBtn);
}
aBtnLay->insertStretch(1, 1);
- // aBtn->setShortcut(QKeySequence(Qt::Key_Escape));
myCustomWidget = new QWidget(aContent);
- myMainLayout->addWidget(myCustomWidget);
+ myCustomWidget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
+ myMainLayout->addWidget(myCustomWidget, aPanelRow, kPanelColumn);
setStretchEnabled(true);
}
{
myWidgets = theWidgets;
if (theWidgets.empty()) return;
- bool isEnableStretch = true;
- QList<ModuleBase_ModelWidget*>::const_iterator anIt = theWidgets.begin(), aLast =
- theWidgets.end();
- for (; anIt != aLast; anIt++) {
+ QList<ModuleBase_ModelWidget*>::const_iterator anIt = theWidgets.begin();
+ for (; anIt != theWidgets.end(); anIt++) {
connect(*anIt, SIGNAL(keyReleased(QKeyEvent*)), this, SIGNAL(keyReleased(QKeyEvent*)));
connect(*anIt, SIGNAL(focusOutWidget(ModuleBase_ModelWidget*)),
this, SLOT(activateNextWidget(ModuleBase_ModelWidget*)));
connect(*anIt, SIGNAL(focusInWidget(ModuleBase_ModelWidget*)),
this, SLOT(activateWidget(ModuleBase_ModelWidget*)));
-
- //ModuleBase_WidgetPoint2D* aPointWidget = dynamic_cast<ModuleBase_WidgetPoint2D*>(*anIt);
- //if (aPointWidget)
- // connect(aPointWidget, SIGNAL(storedPoint2D(ObjectPtr, const std::string&)), this,
- // SIGNAL(storedPoint2D(ObjectPtr, const std::string&)))
- //}
-
- if (!isEnableStretch) continue;
- foreach(QWidget* eachWidget, (*anIt)->getControls()) {
- QSizePolicy::Policy aVPolicy = eachWidget->sizePolicy().verticalPolicy();
- if(aVPolicy == QSizePolicy::Expanding ||
- aVPolicy == QSizePolicy::MinimumExpanding) {
- isEnableStretch = false;
- }
- }
}
- setStretchEnabled(isEnableStretch);
ModuleBase_ModelWidget* aLastWidget = theWidgets.last();
if (aLastWidget) {
QList<QWidget*> aControls = aLastWidget->getControls();
void XGUI_PropertyPanel::setStretchEnabled(bool isEnabled)
{
- if (myMainLayout->count() == 0)
+ int aStretchIdx = myMainLayout->rowCount() - 1;
+ if (aStretchIdx < 0)
return;
- int aStretchIdx = myMainLayout->count() - 1;
- bool hasStretch = myMainLayout->itemAt(aStretchIdx)->spacerItem() != NULL;
- QLayoutItem* aChild;
- if (isEnabled) {
- if (!hasStretch) myMainLayout->addStretch(1);
- } else if (hasStretch) {
- aChild = myMainLayout->takeAt(aStretchIdx);
- delete aChild;
- }
+ myMainLayout->setRowStretch(aStretchIdx, isEnabled ? 1 : 0);
}
void XGUI_PropertyPanel::activateNextWidget()
class XGUI_ActionsMgr;
class QKeyEvent;
-class QVBoxLayout;
+class QGridLayout;
/// Internal name of property panel widget
const static char* PROP_PANEL = "property_panel_dock";
private:
QWidget* myCustomWidget;
QList<ModuleBase_ModelWidget*> myWidgets;
- QVBoxLayout* myMainLayout;
+ QGridLayout* myMainLayout;
/// Currently active widget
ModuleBase_ModelWidget* myActiveWidget;