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";
connect(lineEdit(), SIGNAL(textChanged( const QString& )), this,
SLOT(onTextChanged( const QString& )));
+
+ myEnabledBaseColor = palette().color(QPalette::Active, QPalette::Base);
}
/*!
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);
+}
#include <QDoubleSpinBox>
#include <QValidator>
+#include <QColor>
+
class QKeyEvent;
/**
/// \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();
/// Precision value
int myPrecision;
+
+ /// Cashed color of active base palette
+ QColor myEnabledBaseColor;
};
#endif
#include <Config_Keywords.h>
#include <Config_WidgetAPI.h>
#include <Config_Translator.h>
+#include <Config_PropManager.h>
#include <Events_Loop.h>
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()));
}
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)
/// \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; }
/// 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;
aControlLay->addRow(myLabel, mySpinBox);
connect(mySpinBox, SIGNAL(valueChanged(const QString&)), this, SIGNAL(valuesModified()));
+ mySpinBox->setValueEnabled(isValueEnabled());
}
ModuleBase_WidgetDoubleValue::~ModuleBase_WidgetDoubleValue()
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()
aGroupLay->addWidget(myXSpin, 0, 1);
connect(myXSpin, SIGNAL(valueChanged(const QString&)), this, SIGNAL(valuesModified()));
+ myXSpin->setValueEnabled(isValueEnabled());
}
{
QLabel* aLabel = new QLabel(myGroupBox);
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);
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>
<!-- 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"/>