myCombo->blockSignals(isBlocked);
} else {
bool isBlocked = myButtons->blockSignals(true);
- myButtons->button(aIntAttr->value())->setChecked(true);
+ if (aIntAttr->isInitialized())
+ myButtons->button(aIntAttr->value())->setChecked(true);
+ else {
+ bool aHasDefaultValue;
+ int aDefaultVal = QString::fromStdString(getDefaultValue()).toInt(&aHasDefaultValue);
+ myButtons->button(aHasDefaultValue ? aDefaultVal : 0)->setChecked(true);
+ }
myButtons->blockSignals(isBlocked);
emit itemSelected(this, aIntAttr->value());
}
compositeFeature()->addFeature(SketchPlugin_ConstraintAngle::ID());
fillAttribute(SketcherPrs_Tools::ANGLE_DIRECT,
aFeature->integer(SketchPlugin_ConstraintAngle::TYPE_ID()));
- fillAttribute(SketcherPrs_Tools::LOCATION_AUTOMATIC,
- aFeature->integer(SketchPlugin_ConstraintAngle::LOCATION_TYPE_ID()));
// fill the value before llines to avoid calculation of angle value by the Angle feature
fillAttribute(theValue, aFeature->real(SketchPlugin_ConstraintAngle::ANGLE_VALUE_ID()));
fillAttribute(theLine1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
compositeFeature()->addFeature(SketchPlugin_ConstraintAngle::ID());
fillAttribute(SketcherPrs_Tools::ANGLE_COMPLEMENTARY,
aFeature->integer(SketchPlugin_ConstraintAngle::TYPE_ID()));
- fillAttribute(SketcherPrs_Tools::LOCATION_AUTOMATIC,
- aFeature->integer(SketchPlugin_ConstraintAngle::LOCATION_TYPE_ID()));
fillAttribute(theValue, aFeature->real(SketchPlugin_ConstraintAngle::ANGLE_VALUE_ID()));
fillAttribute(theLine1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
fillAttribute(theLine2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
compositeFeature()->addFeature(SketchPlugin_ConstraintAngle::ID());
fillAttribute(SketcherPrs_Tools::ANGLE_BACKWARD,
aFeature->integer(SketchPlugin_ConstraintAngle::TYPE_ID()));
- fillAttribute(SketcherPrs_Tools::LOCATION_AUTOMATIC,
- aFeature->integer(SketchPlugin_ConstraintAngle::LOCATION_TYPE_ID()));
fillAttribute(theValue, aFeature->real(SketchPlugin_ConstraintAngle::ANGLE_VALUE_ID()));
fillAttribute(theLine1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
fillAttribute(theLine2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
{
std::shared_ptr<ModelAPI_Feature> aFeature =
compositeFeature()->addFeature(SketchPlugin_ConstraintDistance::ID());
- fillAttribute(SketcherPrs_Tools::LOCATION_AUTOMATIC,
- aFeature->integer(SketchPlugin_ConstraintDistance::LOCATION_TYPE_ID()));
fillAttribute(thePoint, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
fillAttribute(thePointOrLine, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE()));
{
std::shared_ptr<ModelAPI_Feature> aFeature =
compositeFeature()->addFeature(SketchPlugin_ConstraintDistanceHorizontal::ID());
- fillAttribute(SketcherPrs_Tools::LOCATION_AUTOMATIC,
- aFeature->integer(SketchPlugin_ConstraintDistanceHorizontal::LOCATION_TYPE_ID()));
fillAttribute(thePoint1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
fillAttribute(thePoint2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE()));
{
std::shared_ptr<ModelAPI_Feature> aFeature =
compositeFeature()->addFeature(SketchPlugin_ConstraintDistanceVertical::ID());
- fillAttribute(SketcherPrs_Tools::LOCATION_AUTOMATIC,
- aFeature->integer(SketchPlugin_ConstraintDistanceVertical::LOCATION_TYPE_ID()));
fillAttribute(thePoint1, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
fillAttribute(thePoint2, aFeature->refattr(SketchPlugin_Constraint::ENTITY_B()));
fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE()));
{
std::shared_ptr<ModelAPI_Feature> aFeature =
compositeFeature()->addFeature(SketchPlugin_ConstraintLength::ID());
- fillAttribute(SketcherPrs_Tools::LOCATION_AUTOMATIC,
- aFeature->integer(SketchPlugin_ConstraintLength::LOCATION_TYPE_ID()));
fillAttribute(theLine, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE()));
aFeature->execute();
{
std::shared_ptr<ModelAPI_Feature> aFeature =
compositeFeature()->addFeature(SketchPlugin_ConstraintRadius::ID());
- fillAttribute(SketcherPrs_Tools::LOCATION_AUTOMATIC,
- aFeature->integer(SketchPlugin_ConstraintRadius::LOCATION_TYPE_ID()));
fillAttribute(theCircleOrArc, aFeature->refattr(SketchPlugin_Constraint::ENTITY_A()));
fillAttribute(theValue, aFeature->real(SketchPlugin_Constraint::VALUE()));
aFeature->execute();
double aTextSize = 0.0;
GetValueString(aTextSize);
- AttributeIntegerPtr aLocationTypeAttr = std::dynamic_pointer_cast<ModelAPI_AttributeInteger>
+ AttributeIntegerPtr aLocAttr = std::dynamic_pointer_cast<ModelAPI_AttributeInteger>
(myConstraint->data()->attribute(SketchPlugin_ConstraintAngle::LOCATION_TYPE_ID()));
- updateArrows(myAspect, GetValue(), aTextSize,
- (SketcherPrs_Tools::LocationType)(aLocationTypeAttr->value()));
+ SketcherPrs_Tools::LocationType aLocationType = aLocAttr->isInitialized() ?
+ (SketcherPrs_Tools::LocationType)(aLocAttr->value()) : SketcherPrs_Tools::LOCATION_AUTOMATIC;
+ updateArrows(myAspect, GetValue(), aTextSize, aLocationType);
AIS_AngleDimension::Compute(thePresentationManager, thePresentation, theMode);
else if (aConstraintKind == SketchPlugin_ConstraintDistanceVertical::ID())
aLocationAttribute = SketchPlugin_ConstraintDistanceVertical::LOCATION_TYPE_ID();
- std::shared_ptr<ModelAPI_AttributeInteger> aLocationTypeAttr = std::dynamic_pointer_cast<
- ModelAPI_AttributeInteger>(myConstraint->data()->attribute(aLocationAttribute));
- updateArrows(DimensionAspect(), GetValue(), aTextSize,
- (SketcherPrs_Tools::LocationType)(aLocationTypeAttr->value()));
+ AttributeIntegerPtr aLocAttr = std::dynamic_pointer_cast<ModelAPI_AttributeInteger>
+ (myConstraint->data()->attribute(aLocationAttribute));
+ SketcherPrs_Tools::LocationType aLocationType = aLocAttr->isInitialized() ?
+ (SketcherPrs_Tools::LocationType)(aLocAttr->value()) : SketcherPrs_Tools::LOCATION_AUTOMATIC;
+ updateArrows(DimensionAspect(), GetValue(), aTextSize, aLocationType);
// Update text visualization: parameter value or parameter text
myStyleListener->updateDimensions(this, myValue);
// Update variable aspect parameters (depending on viewer scale)
double aTextSize = 0.0;
GetValueString(aTextSize);
- AttributeIntegerPtr aLocationTypeAttr = std::dynamic_pointer_cast<ModelAPI_AttributeInteger>
+
+ AttributeIntegerPtr aLocAttr = std::dynamic_pointer_cast<ModelAPI_AttributeInteger>
(myConstraint->data()->attribute(SketchPlugin_ConstraintRadius::LOCATION_TYPE_ID()));
- updateArrows(DimensionAspect(), GetValue(), aTextSize,
- (SketcherPrs_Tools::LocationType)(aLocationTypeAttr->value()));
+ SketcherPrs_Tools::LocationType aLocationType = aLocAttr->isInitialized() ?
+ (SketcherPrs_Tools::LocationType)(aLocAttr->value()) : SketcherPrs_Tools::LOCATION_AUTOMATIC;
+ updateArrows(DimensionAspect(), GetValue(), aTextSize, aLocationType);
AIS_RadiusDimension::Compute(thePresentationManager, thePresentation, theMode);
}
else if (theMessageKind == XGUI_InformationMessage) {
QString aMessage = tr("Please validate all your active operations before saving.");
- QMessageBox::question(qApp->activeWindow(),
- tr("Validate operation"),
- aMessage,
- QMessageBox::Ok,
- QMessageBox::Ok);
+ myActiveMessageBox = createInformationBox(aMessage);
+ myActiveMessageBox->exec();
+ myActiveMessageBox = 0;
aResult = false; // do not perform abort
}
while(aResult && hasOperation()) {
if (theMessageKind == XGUI_AbortOperationMessage) {
QString aMessage = tr("%1 operation will be aborted.").arg(theOperation->id());
myActiveMessageBox = createMessageBox(aMessage);
- int anAnswer = myActiveMessageBox->exec() == QMessageBox::Ok;
+ bool aResult = myActiveMessageBox->exec() == QMessageBox::Ok;
myActiveMessageBox = 0;
- return anAnswer == QMessageBox::Ok;
+ return aResult;
}
else if (theMessageKind == XGUI_InformationMessage) {
QString aMessage = tr("Please validate your %1 before saving.").arg(theOperation->id());
- QMessageBox::question(qApp->activeWindow(),
- tr("Validate operation"),
- aMessage,
- QMessageBox::Ok,
- QMessageBox::Ok);
+ myActiveMessageBox = createInformationBox(aMessage);
+ myActiveMessageBox->exec();
+ myActiveMessageBox = 0;
return false;
}
}
aMessageBox->setEscapeButton(QMessageBox::No); // operation manager should process Esc key
return aMessageBox;
-}
\ No newline at end of file
+}
+
+QMessageBox* XGUI_OperationMgr::createInformationBox(const QString& theMessage)
+{
+ QMessageBox * aMessageBox = new QMessageBox(QMessageBox::Question,
+ QObject::tr("Validate operation"), theMessage, QMessageBox::Ok,
+ qApp->activeWindow());
+ aMessageBox->setDefaultButton(QMessageBox::Ok);
+ aMessageBox->setEscapeButton(QMessageBox::No); // operation manager should process Esc key
+
+ return aMessageBox;
+}
/// \return message box
static QMessageBox* createMessageBox(const QString& theMessage);
+ /// Creates information message box with OK button,
+ /// Escape is Null button
+ /// \param theMessage text of the message
+ /// \return message box
+ static QMessageBox* createInformationBox(const QString& theMessage);
+
private:
typedef QList<ModuleBase_Operation*> Operations; ///< definition for a list of operations
Operations myOperations; ///< a stack of started operations. The active operation is on top,