]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Disabling all input fields of geometry creation panels
authornds <nds@opencascade.com>
Mon, 4 Jul 2016 06:04:07 +0000 (09:04 +0300)
committernds <nds@opencascade.com>
Mon, 4 Jul 2016 06:04:35 +0000 (09:04 +0300)
src/Config/Config_Keywords.h
src/ModuleBase/ModuleBase_DoubleSpinBox.cpp
src/ModuleBase/ModuleBase_DoubleSpinBox.h
src/ModuleBase/ModuleBase_ModelWidget.cpp
src/ModuleBase/ModuleBase_ModelWidget.h
src/ModuleBase/ModuleBase_WidgetDoubleValue.cpp
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_WidgetPoint2d.cpp
src/PythonAddons/macros/rectangle/widget.xml
src/SketchPlugin/plugin-Sketch.xml

index a941f30d2ed5dfbb5ef10fb1b46614a644a9985b..58252b77ecf9a33add42b4d92610dd2a9060a850 100644 (file)
@@ -88,6 +88,7 @@ const static char* DOUBLE_WDG_MAX = "max";
 const static char* DOUBLE_WDG_STEP = "step";
 const static char* DOUBLE_WDG_DEFAULT_COMPUTED = "computed";
 const static char* DOUBLE_WDG_ACCEPT_EXPRESSIONS = "accept_expressions";
+const static char* DOUBLE_WDG_ENABLE_VALUE = "enable_value";
 // WDG_TOOLBOX/WDG_SWITCH properties
 const static char* CONTAINER_PAGE_NAME = "title";
 const static char* CONTAINER_PAGE_ICON = "icon";
index dba8c5d0f22aec40deef9ddff35ad64c8fd30f56..856c5d1937188755d8ee1070c2859c6f82278465 100644 (file)
@@ -77,6 +77,8 @@ ModuleBase_DoubleSpinBox::ModuleBase_DoubleSpinBox(QWidget* theParent, int thePr
 
   connect(lineEdit(), SIGNAL(textChanged( const QString& )), this,
           SLOT(onTextChanged( const QString& )));
+
+  myEnabledBaseColor = palette().color(QPalette::Active, QPalette::Base);
 }
 
 /*!
@@ -353,3 +355,13 @@ bool ModuleBase_DoubleSpinBox::enableKeyPressEvent(const bool& theEnable)
 
   return aPreviousValue;
 }
+
+void ModuleBase_DoubleSpinBox::setValueEnabled(const bool& theEnable)
+{
+  setReadOnly(!theEnable);
+  
+  QPalette aPal = palette();
+  aPal.setColor(QPalette::All, QPalette::Base,
+                theEnable? myEnabledBaseColor : aPal.color(QPalette::Disabled, QPalette::Base));
+  setPalette(aPal);
+}
index 8c60c6d2d36261cb59145653aea1fe0c3b915051..c26d17f038ecc4627ca46c3f128ea8bb5c9a93f6 100644 (file)
@@ -11,6 +11,8 @@
 #include <QDoubleSpinBox>
 #include <QValidator>
 
+#include <QColor>
+
 class QKeyEvent;
 
 /**
@@ -54,6 +56,10 @@ Q_OBJECT
   /// \return the previous value
   bool enableKeyPressEvent(const bool& theEnable);
 
+  /// Imitation of disable control value. If theEnable is false, the control becomes
+  /// read only and base color is disabled. 
+  void setValueEnabled(const bool& theEnable);
+
 signals:
   /// The signal about key release on the control, that corresponds to the attribute
   void enterReleased();
@@ -80,6 +86,9 @@ signals:
 
   /// Precision value
   int myPrecision;
+
+  /// Cashed color of active base palette
+  QColor myEnabledBaseColor;
 };
 
 #endif
index 69cd60c463ba29b321ad6d99cf508fe7c15fb82a..b172e101e9ed7518e2a8bf99ec22fd4656808b7f 100644 (file)
@@ -20,6 +20,7 @@
 #include <Config_Keywords.h>
 #include <Config_WidgetAPI.h>
 #include <Config_Translator.h>
+#include <Config_PropManager.h>
 
 #include <Events_Loop.h>
 
@@ -53,6 +54,8 @@ ModuleBase_ModelWidget::ModuleBase_ModelWidget(QWidget* theParent,
   myAttributeID = theData ? theData->widgetId() : "";
   myIsObligatory = theData->getBooleanAttribute(ATTR_OBLIGATORY, true);
 
+  myIsValueEnabled = theData->getBooleanAttribute(DOUBLE_WDG_ENABLE_VALUE, true);
+
   connect(this, SIGNAL(valuesChanged()), this, SLOT(onWidgetValuesChanged()));
   connect(this, SIGNAL(valuesModified()), this, SLOT(onWidgetValuesModified()));
 }
@@ -78,6 +81,15 @@ bool ModuleBase_ModelWidget::isInitialized(ObjectPtr theObject) const
   return theObject->data()->attribute(attributeID())->isInitialized();
 }
 
+bool ModuleBase_ModelWidget::isValueEnabled() const
+{
+  bool anEnabled = true;
+  bool aCanDisable = Config_PropManager::boolean("Sketch planes", "disable_input_fields", "true");
+  if (aCanDisable)
+    anEnabled = myIsValueEnabled;
+  return anEnabled;
+}
+
 void ModuleBase_ModelWidget::processValueState()
 {
   if (myState == ModifiedInPP || myState == ModifiedInViewer)
index 997c6bca2b43e71bdb7f22df3ff6377ee19867a7..cc3438680f3fa8e5d4c3cba89469bb639b1ec95a 100644 (file)
@@ -75,6 +75,11 @@ Q_OBJECT
   /// \return the boolean result
   bool isObligatory() const { return myIsObligatory; }
 
+  /// Returns true, if the widget value is enabled and might be modified manualy. It returns false if
+  /// the application preferences allow having disabled value and the internal state tells to disable
+  /// \return the boolean result
+  virtual bool isValueEnabled() const;
+
   /// Returns this parameter value in the xml file
   /// \return the boolean result
   bool isUseReset() const { return myUseReset; }
@@ -310,6 +315,9 @@ protected slots:
   /// The non-obligatory widgets should not accept the focus in the property panel
   bool myIsObligatory;
 
+  /// Flag about value of the control is enabled (can be modified)
+  bool myIsValueEnabled;
+
   /// The widget value state
   ValueState myState;
 
index e6408e212f2ecb61e774237c7e63b783f01b0f20..296f0e0caaeb1d1b90399c10a9fe6b0d3b8f27cf 100644 (file)
@@ -92,6 +92,7 @@ ModuleBase_WidgetDoubleValue::ModuleBase_WidgetDoubleValue(QWidget* theParent,
 
   aControlLay->addRow(myLabel, mySpinBox);
   connect(mySpinBox, SIGNAL(valueChanged(const QString&)), this, SIGNAL(valuesModified()));
+  mySpinBox->setValueEnabled(isValueEnabled());
 }
 
 ModuleBase_WidgetDoubleValue::~ModuleBase_WidgetDoubleValue()
index 5b858673cbed399d24e3f3808355b5945fca8769..f357f254162cccbe0d87c71a30b9736396d081b6 100755 (executable)
@@ -162,6 +162,10 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
   Config_PropManager::registerProp("Visualization", "operation_highlight_color",
                           "Multi selector item color in operation", Config_Prop::Color,
                           PartSet_CustomPrs::OPERATION_HIGHLIGHT_COLOR());
+
+
+  Config_PropManager::registerProp("Sketch planes", "disable_input_fields", "Disable input fields",
+                          Config_Prop::Boolean, "true");
 }
 
 PartSet_Module::~PartSet_Module()
index 6b77f8535f2e5ee63b02678667b992afbd49dcc9..4cfede1e2ad6482a0d45742304ebdf88b88d9e63 100644 (file)
@@ -101,6 +101,7 @@ PartSet_WidgetPoint2D::PartSet_WidgetPoint2D(QWidget* theParent,
     aGroupLay->addWidget(myXSpin, 0, 1);
 
     connect(myXSpin, SIGNAL(valueChanged(const QString&)), this, SIGNAL(valuesModified()));
+    myXSpin->setValueEnabled(isValueEnabled());
   }
   {
     QLabel* aLabel = new QLabel(myGroupBox);
@@ -115,6 +116,7 @@ PartSet_WidgetPoint2D::PartSet_WidgetPoint2D(QWidget* theParent,
     aGroupLay->addWidget(myYSpin, 1, 1);
 
     connect(myYSpin, SIGNAL(valueChanged(const QString&)), this, SIGNAL(valuesModified()));
+    myYSpin->setValueEnabled(isValueEnabled());
   }
   QVBoxLayout* aLayout = new QVBoxLayout(this);
   ModuleBase_Tools::zeroMargins(aLayout);
index e21dbda1b6139c7f44923382bb1925f60ee2162d..890e3e55ddcd58730055ae70892bbc6e5e48e741 100644 (file)
@@ -8,8 +8,10 @@
         title="Rectangle"
         tooltip="Create rectangle"
         icon="icons/Addons/rectangle.png">
-        <sketch-2dpoint_selector id="RectStartPoint" accept_expressions="0" title="Start point" tooltip="Start point coordinates"/>
-        <sketch-2dpoint_selector id="RectEndPoint" accept_expressions="0" title="End point" tooltip="End point coordinates"/>
+        <sketch-2dpoint_selector id="RectStartPoint" accept_expressions="0" title="Start point" tooltip="Start point coordinates"
+                                 enable_value="false"/>
+        <sketch-2dpoint_selector id="RectEndPoint" accept_expressions="0" title="End point" tooltip="End point coordinates"
+                                 enable_value="false"/>
         <boolvalue id="Auxiliary" label="Auxiliary" default="false" tooltip="Construction element" obligatory="0"/>
         <validator id="GeomValidators_Different" parameters="RectStartPoint,RectEndPoint"/>
       </feature>
index a618c51cd7be250f04489ca866441ef82a546a05..89b6754ae5e2f305f54c5c73cdcb06ca0b021b70 100644 (file)
 
       <!-- SketchPoint -->
       <feature id="SketchPoint" title="Point" tooltip="Create point" icon="icons/Sketch/point.png">
-        <sketch-2dpoint_selector id="PointCoordindates" accept_expressions="0" title="Point" tooltip="Point coordinates"/>
+        <sketch-2dpoint_selector id="PointCoordindates" accept_expressions="0" title="Point" tooltip="Point coordinates"
+                                 enable_value="false"/>
         <boolvalue id="Auxiliary" label="Auxiliary" default="false" tooltip="Construction element" obligatory="0"/>
       </feature>
       
       <!-- SketchLine -->
       <feature id="SketchLine" title="Line" tooltip="Create line" icon="icons/Sketch/line.png">
-        <sketch-2dpoint_selector id="StartPoint" accept_expressions="0" title="Start point" tooltip="Start point coordinates"/>
-        <sketch-2dpoint_selector id="EndPoint" accept_expressions="0" title="End point" tooltip="End point coordinates"/>
+        <sketch-2dpoint_selector id="StartPoint" accept_expressions="0" title="Start point" tooltip="Start point coordinates"
+                                 enable_value="false"/>
+        <sketch-2dpoint_selector id="EndPoint" accept_expressions="0" title="End point" tooltip="End point coordinates"
+                                 enable_value="false"/>
         <boolvalue id="Auxiliary" label="Auxiliary" default="false" tooltip="Construction element" obligatory="0"/>
         <validator id="GeomValidators_Different" parameters="StartPoint,EndPoint"/>
       </feature>
         icon="icons/Sketch/circle.png">
         <toolbox id="CircleType">
           <box id="CenterRadius" title="Center and radius" icon="icons/Sketch/circle_pt_rad_32x32.png">
-            <sketch-2dpoint_selector id="CircleCenter" accept_expressions="0" title="Center" tooltip="Center coordinates"/>
-            <point2ddistance id="CircleRadius" accept_expressions="0" first_point="CircleCenter" label="Radius:" min="0" step="1.0" default="0" icon="icons/Sketch/radius.png" tooltip="Set radius">
+            <sketch-2dpoint_selector id="CircleCenter" accept_expressions="0" title="Center" tooltip="Center coordinates"
+                                     enable_value="false"/>
+            <point2ddistance id="CircleRadius" accept_expressions="0" first_point="CircleCenter" label="Radius:" min="0" step="1.0"
+                             default="0" icon="icons/Sketch/radius.png" tooltip="Set radius"
+                             enable_value="false">
               <validator id="GeomValidators_Positive"/>
             </point2ddistance>
           </box>
           <box id="ThreePoints" title="Three points" icon="icons/Sketch/circle_3pt_32x32.png">
-            <sketch-2dpoint_selector id="FirstPoint" accept_expressions="0" title="First point" tooltip="First point"/>
-            <sketch-2dpoint_selector id="SecondPoint" accept_expressions="0" title="Second point" tooltip="Second point"/>
-            <sketch-2dpoint_selector id="ThirdPoint" accept_expressions="0" title="Third point" tooltip="Third point"/>
+            <sketch-2dpoint_selector id="FirstPoint" accept_expressions="0" title="First point" tooltip="First point"
+                                     enable_value="false"/>
+            <sketch-2dpoint_selector id="SecondPoint" accept_expressions="0" title="Second point" tooltip="Second point"
+                                     enable_value="false"/>
+            <sketch-2dpoint_selector id="ThirdPoint" accept_expressions="0" title="Third point" tooltip="Third point"
+                                     enable_value="false"/>
           </box>
         </toolbox>
         <boolvalue id="Auxiliary" label="Auxiliary" default="false" tooltip="Construction element" obligatory="0"/>
         icon="icons/Sketch/arc.png">
         <toolbox id="ArcType">
           <box id="CenterStartEnd" title="Center and two points" icon="icons/Sketch/arc_base_32x32.png">
-            <sketch-2dpoint_selector id="ArcCenter" accept_expressions="0" title="Center" tooltip="Center of a circle"/>
-            <sketch-2dpoint_selector id="ArcStartPoint" accept_expressions="0" title="Start point" tooltip="Start point"/>
-            <sketch-2dpoint_selector id="ArcEndPoint" accept_expressions="0" title="End point" tooltip="End point"/>
+            <sketch-2dpoint_selector id="ArcCenter" accept_expressions="0" title="Center" tooltip="Center of a circle"
+                                     enable_value="false"/>
+            <sketch-2dpoint_selector id="ArcStartPoint" accept_expressions="0" title="Start point" tooltip="Start point"
+                                     enable_value="false"/>
+            <sketch-2dpoint_selector id="ArcEndPoint" accept_expressions="0" title="End point" tooltip="End point"
+                                     enable_value="false"/>
             <validator id="GeomValidators_Different" parameters="ArcCenter,ArcStartPoint,ArcEndPoint"/>
           </box>
           <box id="ThreePoints" title="Three points on arc" icon="icons/Sketch/arc_3pt_32x32.png">
-            <sketch-2dpoint_selector id="ArcStartPoint" accept_expressions="0" title="Start point" tooltip="Start point"/>
-            <sketch-2dpoint_selector id="ArcEndPoint" accept_expressions="0" title="End point" tooltip="End point"/>
-            <sketch-2dpoint_selector id="ArcPassedPoint" accept_expressions="0" title="Passed point" tooltip="Passed point"/>
+            <sketch-2dpoint_selector id="ArcStartPoint" accept_expressions="0" title="Start point" tooltip="Start point"
+                                     enable_value="false"/>
+            <sketch-2dpoint_selector id="ArcEndPoint" accept_expressions="0" title="End point" tooltip="End point"
+                                     enable_value="false"/>
+            <sketch-2dpoint_selector id="ArcPassedPoint" accept_expressions="0" title="Passed point" tooltip="Passed point"
+                                     enable_value="false"/>
             <validator id="GeomValidators_Different" parameters="ArcStartPoint,ArcEndPoint,ArcPassedPoint"/>
           </box>
           <box id="Tangent" title="Tangent with edge" icon="icons/Sketch/arc_tang_32x32.png">
             <sketch_shape_selector id="ArcTangentPoint" label="Tangent point" tooltip="Select point on line" shape_types="vertex">
               <validator id="SketchPlugin_ArcTangentPoint" parameters="" />
             </sketch_shape_selector>
-            <sketch-2dpoint_selector id="ArcEndPoint" accept_expressions="0" title="End point" tooltip="End point"/>
+            <sketch-2dpoint_selector id="ArcEndPoint" accept_expressions="0" title="End point" tooltip="End point"
+                                     enable_value="false"/>
           </box>
         </toolbox>
-        <doublevalue id="ArcRadius" accept_expressions="0" label="Radius:" default="computed" icon="icons/Sketch/radius.png" tooltip="Set radius" obligatory="0">
+        <doublevalue id="ArcRadius" accept_expressions="0" label="Radius:" default="computed" icon="icons/Sketch/radius.png"
+                     tooltip="Set radius" obligatory="0" enable_value="false">
           <validator id="GeomValidators_Positive"/>
         </doublevalue>
-        <doublevalue id="ArcAngle" label="Angle:" icon="icons/Sketch/angle.png" tooltip="Set angle" default="90" use_reset="false" obligatory="0"/>
-        <boolvalue id="Auxiliary" label="Auxiliary" default="false" tooltip="Construction element" obligatory="0"/>
+        <doublevalue id="ArcAngle" label="Angle:" icon="icons/Sketch/angle.png" tooltip="Set angle" default="90" use_reset="false" obligatory="0"
+                     enable_value="false"/>
+        <boolvalue id="Auxiliary" label="Auxiliary" default="false" tooltip="Construction element" obligatory="0"
+                   enable_value="false"/>
       </feature>
 
       <!--  SketchConstraintFillet  -->
             clear_in_neutral_point="false">
           <validator id="SketchPlugin_FilletVertexValidator"/>
         </sketch_multi_selector>
-        <doublevalue label="Radius" tooltip="Fillet arc radius" id="ConstraintValue" accept_expressions="0" min="0" use_reset="false">
+        <doublevalue label="Radius" tooltip="Fillet arc radius" id="ConstraintValue" accept_expressions="0" min="0" use_reset="false"
+                     enable_value="false">
           <validator id="GeomValidators_Positive"/>
         </doublevalue>
         <validator id="PartSet_FilletSelection"/>