From: nds Date: Tue, 3 Mar 2015 14:34:14 +0000 (+0300) Subject: Construction elements are auxiliary entities: X-Git-Tag: V_1.1.0~149 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4637d06f671c4748c8af8318bb50065c6f66860e;p=modules%2Fshaper.git Construction elements are auxiliary entities: a boolean flag in the sketch feature, customize sketch feature presentation by the color change. Important modification: it was decided to use non-obligatory xml constructions to set the no-focus policy for the attribute. Otherwise during a segment-line creation, it is not enough to select two points, the check box control has a focus after them. --- diff --git a/src/ModuleBase/ModuleBase_ModelWidget.cpp b/src/ModuleBase/ModuleBase_ModelWidget.cpp index a4368946b..2085e6902 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.cpp +++ b/src/ModuleBase/ModuleBase_ModelWidget.cpp @@ -31,6 +31,7 @@ ModuleBase_ModelWidget::ModuleBase_ModelWidget(QWidget* theParent, myDefaultValue = theData->getProperty(ATTR_DEFAULT); myIsComputedDefault = theData->getProperty(ATTR_DEFAULT) == DOUBLE_WDG_DEFAULT_COMPUTED; myAttributeID = theData ? theData->widgetId() : ""; + myIsObligatory = theData->getBooleanAttribute(ATTR_OBLIGATORY, true); connect(this, SIGNAL(valuesChanged()), this, SLOT(onWidgetValuesChanged())); } @@ -44,8 +45,13 @@ void ModuleBase_ModelWidget::enableFocusProcessing() { QList aMyControls = getControls(); foreach(QWidget* eachControl, aMyControls) { - eachControl->setFocusPolicy(Qt::StrongFocus); - eachControl->installEventFilter(this); + if (myIsObligatory) { + eachControl->setFocusPolicy(Qt::StrongFocus); + eachControl->installEventFilter(this); + } + else { + eachControl->setFocusPolicy(Qt::NoFocus); + } } } @@ -85,14 +91,15 @@ bool ModuleBase_ModelWidget::focusTo() { QList aControls = getControls(); QList::const_iterator anIt = aControls.begin(), aLast = aControls.end(); - for (; anIt != aLast; anIt++) { + bool isFocusAccepted = false; + for (; anIt != aLast && !isFocusAccepted; anIt++) { QWidget* aWidget = *anIt; if (aWidget && aWidget->focusPolicy() != Qt::NoFocus) { aWidget->setFocus(); - break; + isFocusAccepted = true; } } - return true; + return isFocusAccepted; } void ModuleBase_ModelWidget::activate() diff --git a/src/ModuleBase/ModuleBase_ModelWidget.h b/src/ModuleBase/ModuleBase_ModelWidget.h index 03067aa68..80b1773a3 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.h +++ b/src/ModuleBase/ModuleBase_ModelWidget.h @@ -96,8 +96,9 @@ Q_OBJECT /// FocusIn events processing virtual bool eventFilter(QObject* theObject, QEvent *theEvent); - //! \brief Enables processing of focus event on all controls by the widget - void enableFocusProcessing(); + /// \brief Enables processing of focus event on all controls by the widget + /// if this widget is not obligatory and set no-focus policy otherwise + virtual void enableFocusProcessing(); //! Switch On/Off highlighting of the widget void setHighlighted(bool isHighlighted); @@ -197,6 +198,10 @@ protected slots: /// Flag which shows that current operation is in editing mode bool myIsEditing; + /// Flag which shows whether current widget is obligatory + /// The non-obligatory widgets should not accept the focus in the property panel + bool myIsObligatory; + private: /// Value should be computed on execute, like radius for circle's constraint (can not be zero) bool myIsComputedDefault; diff --git a/src/PartSet/PartSet_WidgetSketchLabel.h b/src/PartSet/PartSet_WidgetSketchLabel.h index 8288bdf82..1189dd228 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.h +++ b/src/PartSet/PartSet_WidgetSketchLabel.h @@ -70,6 +70,9 @@ Q_OBJECT /// Returns sketcher plane std::shared_ptr plane() const; + /// This control accepts focus + virtual bool focusTo() { return true; } + signals: /// Signal on plane selection void planeSelected(const std::shared_ptr& thePln); diff --git a/src/SketchPlugin/SketchPlugin_Feature.h b/src/SketchPlugin/SketchPlugin_Feature.h index 076b1d038..9e22b9ce8 100644 --- a/src/SketchPlugin/SketchPlugin_Feature.h +++ b/src/SketchPlugin/SketchPlugin_Feature.h @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -20,6 +21,7 @@ #define SKETCH_EDGE_COLOR "#ff0000" #define SKETCH_POINT_COLOR "#ff0000" #define SKETCH_EXTERNAL_EDGE_COLOR "#00ff00" +#define SKETCH_CONSTRUCTION_COLOR "#000000" class SketchPlugin_Sketch; class GeomAPI_Pnt2d; @@ -33,6 +35,13 @@ class Handle_AIS_InteractiveObject; class SketchPlugin_Feature : public ModelAPI_Feature, public GeomAPI_ICustomPrs { public: + /// Reference to the construction type of the feature + inline static const std::string& CONSTRUCTION_ID() + { + static const std::string MY_CONSTRUCTION_ID("Construction"); + return MY_CONSTRUCTION_ID; + } + /// Reference to the external edge or vertex as a AttributeSelection inline static const std::string& EXTERNAL_ID() { @@ -74,28 +83,39 @@ class SketchPlugin_Feature : public ModelAPI_Feature, public GeomAPI_ICustomPrs virtual void customisePresentation(AISObjectPtr thePrs) { std::vector aRGB; - // if this is an edge - if (thePrs->getShapeType() == 6) { - thePrs->setWidth(3); - if (isExternal()) { - // Set color from preferences - aRGB = Config_PropManager::color("Visualization", "sketch_external_color", - SKETCH_EXTERNAL_EDGE_COLOR); + + int aShapeType = thePrs->getShapeType(); + if (aShapeType != 6/*an edge*/ && aShapeType != 7/*a vertex*/) + return; + + bool isConstruction = data()->boolean(SketchPlugin_Feature::CONSTRUCTION_ID())->value(); + if (aShapeType == 6) { // if this is an edge + if (isConstruction) { + thePrs->setWidth(1); + aRGB = Config_PropManager::color("Visualization", "sketch_construction_color", + SKETCH_CONSTRUCTION_COLOR); } else { - // Set color from preferences - aRGB = Config_PropManager::color("Visualization", "sketch_edge_color", - SKETCH_EDGE_COLOR); + thePrs->setWidth(3); + if (isExternal()) { + // Set color from preferences + aRGB = Config_PropManager::color("Visualization", "sketch_external_color", + SKETCH_EXTERNAL_EDGE_COLOR); + } + else { + // Set color from preferences + aRGB = Config_PropManager::color("Visualization", "sketch_edge_color", + SKETCH_EDGE_COLOR); + } } } - else if (thePrs->getShapeType() == 7) { // otherwise this is a vertex + else if (aShapeType == 7) { // otherwise this is a vertex + // thePrs->setPointMarker(6, 2.); // Set color from preferences aRGB = Config_PropManager::color("Visualization", "sketch_point_color", SKETCH_POINT_COLOR); } - // if this is a vertex - //else if (thePrs->getShapeType() == 7) - // thePrs->setPointMarker(6, 2.); + if (!aRGB.empty()) thePrs->setColor(aRGB[0], aRGB[1], aRGB[2]); } diff --git a/src/SketchPlugin/SketchPlugin_Line.cpp b/src/SketchPlugin/SketchPlugin_Line.cpp index 429f7e132..ee7193e72 100644 --- a/src/SketchPlugin/SketchPlugin_Line.cpp +++ b/src/SketchPlugin/SketchPlugin_Line.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -29,6 +30,7 @@ void SketchPlugin_Line::initAttributes() { data()->addAttribute(START_ID(), GeomDataAPI_Point2D::type()); data()->addAttribute(END_ID(), GeomDataAPI_Point2D::type()); + data()->addAttribute(CONSTRUCTION_ID(), ModelAPI_AttributeBoolean::type()); data()->addAttribute(EXTERNAL_ID(), ModelAPI_AttributeSelection::type()); ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), EXTERNAL_ID()); } diff --git a/src/SketchPlugin/SketchPlugin_Plugin.cpp b/src/SketchPlugin/SketchPlugin_Plugin.cpp index 20958c5e3..aeaba71c8 100644 --- a/src/SketchPlugin/SketchPlugin_Plugin.cpp +++ b/src/SketchPlugin/SketchPlugin_Plugin.cpp @@ -66,6 +66,9 @@ SketchPlugin_Plugin::SketchPlugin_Plugin() Config_PropManager::registerProp("Visualization", "sketch_external_color", "Sketch external edge color", Config_Prop::Color, SKETCH_EXTERNAL_EDGE_COLOR); + Config_PropManager::registerProp("Visualization", "sketch_construction_color", "Sketch construction color", + Config_Prop::Color, SKETCH_CONSTRUCTION_COLOR); + Config_PropManager::registerProp("Visualization", "sketch_parallel_color", "Sketch constraint color", Config_Prop::Color, SKETCH_CONSTRAINT_COLOR); Config_PropManager::registerProp("Visualization", "sketch_dimension_color", "Sketch dimension color", diff --git a/src/SketchPlugin/plugin-Sketch.xml b/src/SketchPlugin/plugin-Sketch.xml index 753b225be..ff6c30559 100644 --- a/src/SketchPlugin/plugin-Sketch.xml +++ b/src/SketchPlugin/plugin-Sketch.xml @@ -19,6 +19,7 @@ +