-->
<source>
+ <namevalue id="name"
+ label="Name"
+ placeholder="Please input the group name">
+ </namevalue>
<multi_selector id="group_list"
tooltip="Select a set of objects"
type_choice="Vertices Edges Faces Solids"
const static char* WDG_INTEGERVALUE = "integervalue";
const static char* WDG_BOOLVALUE = "boolvalue";
const static char* WDG_STRINGVALUE = "stringvalue";
+const static char* WDG_NAMEVALUE = "namevalue";
const static char* WDG_MULTISELECTOR = "multi_selector";
const static char* WDG_SHAPE_SELECTOR = "shape_selector";
const static char* WDG_FEATURE_SELECTOR = "feature_selector";
ModuleBase_Dialog.h
ModuleBase_ModelDialogWidget.h
ModuleBase_ChoiceCtrl.h
+ ModuleBase_WidgetNameEdit.h
)
SET(PROJECT_MOC_HEADERS
ModuleBase_WidgetToolbox.h
ModuleBase_WidgetValidated.h
ModuleBase_ChoiceCtrl.h
+ ModuleBase_WidgetNameEdit.h
)
SET(PROJECT_SOURCES
ModuleBase_SelectionValidator.cpp
ModuleBase_Dialog.cpp
ModuleBase_ChoiceCtrl.cpp
+ ModuleBase_WidgetNameEdit.cpp
)
SET(PROJECT_LIBRARIES
/// \return a model widget or NULL
static ModuleBase_ModelWidget* findModelWidget(ModuleBase_IPropertyPanel* theProp,
QWidget* theWidget);
+
+ /// Returns True if the widget uses feature attribute.
+ /// If not then it means that the widget do not need attribute at all.
+ virtual bool usesAttribute() const { return true; }
+
signals:
/// The signal about widget values are to be changed
void beforeValuesChanged();
#include <ModuleBase_IModule.h>
#include <ModuleBase_Tools.h>
#include <ModuleBase_WidgetLineEdit.h>
+#include <ModuleBase_WidgetNameEdit.h>
#include <ModuleBase_WidgetMultiSelector.h>
#include <ModuleBase_WidgetConcealedObjects.h>
#include <ModuleBase_WidgetLabel.h>
} else if (theType == WDG_STRINGVALUE) {
std::string aPlaceHolder = myWidgetApi->getProperty( WDG_PLACE_HOLDER );
result = new ModuleBase_WidgetLineEdit( theParent, myWidgetApi, aPlaceHolder );
+ } else if (theType == WDG_NAMEVALUE) {
+ std::string aPlaceHolder = myWidgetApi->getProperty( WDG_PLACE_HOLDER );
+ result = new ModuleBase_WidgetNameEdit( theParent, myWidgetApi, aPlaceHolder );
} else if (theType == WDG_EXPR_EDITOR) {
std::string aPlaceHolder = myWidgetApi->getProperty( WDG_PLACE_HOLDER );
result = new ModuleBase_WidgetExprEditor( theParent, myWidgetApi, aPlaceHolder );
/// Redefinition of virtual method
virtual bool restoreValueCustom();
-private:
/// A line edit control
QLineEdit* myLineEdit;
};
#include <ModuleBase_WidgetShapeSelector.h>
#include <ModuleBase_ISelection.h>
#include <ModuleBase_IWorkshop.h>
+#include <ModuleBase_IPropertyPanel.h>
#include <ModuleBase_IViewer.h>
#include <ModuleBase_Tools.h>
#include <ModuleBase_Definitions.h>
QGridLayout* aMainLay = new QGridLayout(this);
ModuleBase_Tools::adjustMargins(aMainLay);
- //QLabel* aTypeLabel = new QLabel(tr("Type"), this);
- //aMainLay->addWidget(aTypeLabel, 0, 0);
-
- //myTypeCombo = new QComboBox(this);
QStringList aIconsList = getIconsList(myShapeTypes);
myTypeCtrl = new ModuleBase_ChoiceCtrl(this, myShapeTypes, aIconsList);
myTypeCtrl->setLabel(tr("Type"));
myTypeCtrl->setValue(0);
+ aMainLay->addWidget(myTypeCtrl, 0, 0, 1, 2);
// There is no sense to parameterize list of types while we can not parameterize selection mode
- //if (!aShapeTypes.empty())
- // myTypeCombo->addItems(aShapeTypes);
- aMainLay->addWidget(myTypeCtrl, 0, 0, 1, 2);
// if the xml definition contains one type, the controls to select a type should not be shown
if (myShapeTypes.size() <= 1 || !myIsUseChoice) {
myTypeCtrl->setVisible(false);
std::string aType = anAttribute->attributeType();
if (aType == ModelAPI_AttributeSelectionList::typeId()) {
AttributeSelectionListPtr aSelectionListAttr = myFeature->data()->selectionList(attributeID());
- //aSelectionListAttr->setSelectionType(myTypeCombo->currentText().toStdString());
aSelectionListAttr->setSelectionType(myTypeCtrl->textValue().toStdString());
}
return true;
QList<QWidget*> ModuleBase_WidgetMultiSelector::getControls() const
{
QList<QWidget*> result;
- //result << myTypeCombo;
result << myListControl;
return result;
}
true); /// hope that something is redisplayed by object updated
// clear history should follow after set selected to do not increase history by setSelected
clearSelectedHistory();
+
+ if (myWorkshop->propertyPanel()->activeWidget() != this)
+ myWorkshop->propertyPanel()->activateWidget(this);
}
//********************************************************************
{
QString aShapeTypeName;
- //for (int idx = 0; idx < myTypeCombo->count(); ++idx) {
- // aShapeTypeName = myTypeCombo->itemText(idx);
int idx = 0;
foreach (QString aShapeTypeName, myShapeTypes) {
int aRefType = ModuleBase_Tools::shapeType(aShapeTypeName);
/// A container of selected objects
QList<QList<std::shared_ptr<ModuleBase_ViewerPrs> > > mySelectedHistoryValues;
+
/// Position in a container of selected values
int myCurrentHistoryIndex;
};
--- /dev/null
+// Copyright (C) 2014-2017 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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// 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
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#include <ModuleBase_WidgetNameEdit.h>
+
+#include <QLineEdit>
+
+bool ModuleBase_WidgetNameEdit::storeValueCustom()
+{
+ if(!myFeature)
+ return false;
+
+ QString aValue = myLineEdit->text();
+ myFeature->data()->setName(aValue.toStdString());
+ updateObject(myFeature);
+ return true;
+}
+
+bool ModuleBase_WidgetNameEdit::restoreValueCustom()
+{
+ if(!myFeature)
+ return false;
+
+ bool isBlocked = myLineEdit->blockSignals(true);
+ myLineEdit->setText(QString::fromStdString(myFeature->data()->name()));
+ myLineEdit->blockSignals(isBlocked);
+
+ return true;
+}
\ No newline at end of file
--- /dev/null
+// Copyright (C) 2014-2017 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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// 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
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
+
+#ifndef MODULEBASE_WIDGETNAMEEDIT_H_
+#define MODULEBASE_WIDGETNAMEEDIT_H_
+
+#include <ModuleBase.h>
+#include <ModuleBase_WidgetLineEdit.h>
+
+class ModuleBase_WidgetNameEdit : public ModuleBase_WidgetLineEdit
+{
+ Q_OBJECT
+public:
+ ModuleBase_WidgetNameEdit( QWidget* theParent,
+ const Config_WidgetAPI* theData,
+ const std::string& thePlaceHolder )
+ : ModuleBase_WidgetLineEdit(theParent, theData, thePlaceHolder) {}
+
+ /// Returns True if the widget uses feature attribute.
+ /// If not then it means that the widget do not need attribute at all.
+ virtual bool usesAttribute() const { return false; }
+
+protected:
+ /// Saves the internal parameters to the given feature
+ /// \return True in success
+ virtual bool storeValueCustom();
+
+ /// Redefinition of virtual method
+ virtual bool restoreValueCustom();
+};
+
+#endif
\ No newline at end of file
FeaturePtr aFeature = aFOperation->feature();
std::string aFeatureKind = aFeature->getKind();
foreach (ModuleBase_ModelWidget* aWidget, aWidgets) {
- if (!aWidget->attributeID().empty() && !aFeature->attribute(aWidget->attributeID()).get()) {
- std::string anErrorMsg = "The feature '%1' has no attribute '%2' used by widget '%3'.";
- Events_InfoMessage("XGUI_Workshop", anErrorMsg)
- .arg(aFeatureKind).arg(aWidget->attributeID())
- .arg(aWidget->metaObject()->className()).send();
- myPropertyPanel->cleanContent();
- return;
+ if (aWidget->usesAttribute()) {
+ if (!aWidget->attributeID().empty() && !aFeature->attribute(aWidget->attributeID()).get()) {
+ std::string anErrorMsg = "The feature '%1' has no attribute '%2' used by widget '%3'.";
+ Events_InfoMessage("XGUI_Workshop", anErrorMsg)
+ .arg(aFeatureKind).arg(aWidget->attributeID())
+ .arg(aWidget->metaObject()->className()).send();
+ myPropertyPanel->cleanContent();
+ return;
+ }
}
}
// for performance purpose, flush should be done after all controls are filled