Fixed bugs.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2016-01-25 16:46:24 +02:00
parent 74b84740eb
commit 2069713ff6
4 changed files with 55 additions and 15 deletions

View File

@ -480,7 +480,7 @@ void VToolOptionsPropertyBrowser::AddPropertyCrossPoint(Tool *i, const QString &
{ {
VEnumProperty* itemProperty = new VEnumProperty(propertyName); VEnumProperty* itemProperty = new VEnumProperty(propertyName);
itemProperty->setLiterals(QStringList()<< tr("First point") << tr("Second point")); itemProperty->setLiterals(QStringList()<< tr("First point") << tr("Second point"));
itemProperty->setValue(static_cast<int>(i->GetCrossCirclesPoint())); itemProperty->setValue(static_cast<int>(i->GetCrossCirclesPoint())-1);
AddProperty(itemProperty, AttrCrossPoint); AddProperty(itemProperty, AttrCrossPoint);
} }
@ -490,7 +490,7 @@ void VToolOptionsPropertyBrowser::AddPropertyVCrossPoint(Tool *i, const QString
{ {
auto itemProperty = new VEnumProperty(propertyName); auto itemProperty = new VEnumProperty(propertyName);
itemProperty->setLiterals(QStringList()<< tr("Highest point") << tr("Lowest point")); itemProperty->setLiterals(QStringList()<< tr("Highest point") << tr("Lowest point"));
itemProperty->setValue(static_cast<int>(i->GetVCrossPoint())); itemProperty->setValue(static_cast<int>(i->GetVCrossPoint())-1);
AddProperty(itemProperty, AttrVCrossPoint); AddProperty(itemProperty, AttrVCrossPoint);
} }
@ -500,7 +500,7 @@ void VToolOptionsPropertyBrowser::AddPropertyHCrossPoint(Tool *i, const QString
{ {
auto itemProperty = new VEnumProperty(propertyName); auto itemProperty = new VEnumProperty(propertyName);
itemProperty->setLiterals(QStringList()<< tr("Leftmost point") << tr("Rightmost point")); itemProperty->setLiterals(QStringList()<< tr("Leftmost point") << tr("Rightmost point"));
itemProperty->setValue(static_cast<int>(i->GetHCrossPoint())); itemProperty->setValue(static_cast<int>(i->GetHCrossPoint())-1);
AddProperty(itemProperty, AttrHCrossPoint); AddProperty(itemProperty, AttrHCrossPoint);
} }
@ -629,9 +629,9 @@ Type VToolOptionsPropertyBrowser::GetCrossPoint(const QVariant &value)
{ {
switch(val) switch(val)
{ {
case 0:
case 1: case 1:
case 2: cross = static_cast<Type>(val+1);
cross = static_cast<Type>(val);
break; break;
default: default:
break; break;
@ -2037,7 +2037,7 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolPointOfIntersectionArcs()
VToolPointOfIntersectionArcs *i = qgraphicsitem_cast<VToolPointOfIntersectionArcs *>(currentItem); VToolPointOfIntersectionArcs *i = qgraphicsitem_cast<VToolPointOfIntersectionArcs *>(currentItem);
idToProperty[AttrName]->setValue(i->name()); idToProperty[AttrName]->setValue(i->name());
idToProperty[AttrCrossPoint]->setValue(static_cast<int>(i->GetCrossCirclesPoint())); idToProperty[AttrCrossPoint]->setValue(static_cast<int>(i->GetCrossCirclesPoint())-1);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -2046,7 +2046,7 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolPointOfIntersectionCircles()
VToolPointOfIntersectionCircles *i = qgraphicsitem_cast<VToolPointOfIntersectionCircles *>(currentItem); VToolPointOfIntersectionCircles *i = qgraphicsitem_cast<VToolPointOfIntersectionCircles *>(currentItem);
idToProperty[AttrName]->setValue(i->name()); idToProperty[AttrName]->setValue(i->name());
idToProperty[AttrCrossPoint]->setValue(static_cast<int>(i->GetCrossCirclesPoint())); idToProperty[AttrCrossPoint]->setValue(static_cast<int>(i->GetCrossCirclesPoint())-1);
QVariant c1Radius; QVariant c1Radius;
c1Radius.setValue(i->GetFirstCircleRadius()); c1Radius.setValue(i->GetFirstCircleRadius());
@ -2063,8 +2063,8 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolPointOfIntersectionCurves()
auto i = qgraphicsitem_cast<VToolPointOfIntersectionCurves *>(currentItem); auto i = qgraphicsitem_cast<VToolPointOfIntersectionCurves *>(currentItem);
idToProperty[AttrName]->setValue(i->name()); idToProperty[AttrName]->setValue(i->name());
idToProperty[AttrVCrossPoint]->setValue(static_cast<int>(i->GetVCrossPoint())); idToProperty[AttrVCrossPoint]->setValue(static_cast<int>(i->GetVCrossPoint())-1);
idToProperty[AttrHCrossPoint]->setValue(static_cast<int>(i->GetHCrossPoint())); idToProperty[AttrHCrossPoint]->setValue(static_cast<int>(i->GetHCrossPoint())-1);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -2073,7 +2073,7 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolPointFromCircleAndTangent()
VToolPointFromCircleAndTangent *i = qgraphicsitem_cast<VToolPointFromCircleAndTangent *>(currentItem); VToolPointFromCircleAndTangent *i = qgraphicsitem_cast<VToolPointFromCircleAndTangent *>(currentItem);
idToProperty[AttrName]->setValue(i->name()); idToProperty[AttrName]->setValue(i->name());
idToProperty[AttrCrossPoint]->setValue(static_cast<int>(i->GetCrossCirclesPoint())); idToProperty[AttrCrossPoint]->setValue(static_cast<int>(i->GetCrossCirclesPoint())-1);
QVariant cRadius; QVariant cRadius;
cRadius.setValue(i->GetCircleRadius()); cRadius.setValue(i->GetCircleRadius());
@ -2086,7 +2086,7 @@ void VToolOptionsPropertyBrowser::UpdateOptionsToolPointFromArcAndTangent()
VToolPointFromArcAndTangent *i = qgraphicsitem_cast<VToolPointFromArcAndTangent *>(currentItem); VToolPointFromArcAndTangent *i = qgraphicsitem_cast<VToolPointFromArcAndTangent *>(currentItem);
idToProperty[AttrName]->setValue(i->name()); idToProperty[AttrName]->setValue(i->name());
idToProperty[AttrCrossPoint]->setValue(static_cast<int>(i->GetCrossCirclesPoint())); idToProperty[AttrCrossPoint]->setValue(static_cast<int>(i->GetCrossCirclesPoint())-1);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -46,6 +46,7 @@ DialogPointOfIntersectionCurves::DialogPointOfIntersectionCurves(const VContaine
labelEditNamePoint = ui->labelEditNamePoint; labelEditNamePoint = ui->labelEditNamePoint;
InitOkCancelApply(ui); InitOkCancelApply(ui);
CheckState();
FillComboBoxCurves(ui->comboBoxCurve1); FillComboBoxCurves(ui->comboBoxCurve1);
FillComboBoxCurves(ui->comboBoxCurve2); FillComboBoxCurves(ui->comboBoxCurve2);
@ -53,6 +54,10 @@ DialogPointOfIntersectionCurves::DialogPointOfIntersectionCurves(const VContaine
FillComboBoxHCrossCurvesPoint(ui->comboBoxHCorrection); FillComboBoxHCrossCurvesPoint(ui->comboBoxHCorrection);
connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogPointOfIntersectionCurves::NamePointChanged); connect(ui->lineEditNamePoint, &QLineEdit::textChanged, this, &DialogPointOfIntersectionCurves::NamePointChanged);
connect(ui->comboBoxCurve1, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &DialogPointOfIntersectionCurves::CurveChanged);
connect(ui->comboBoxCurve2, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
this, &DialogPointOfIntersectionCurves::CurveChanged);
vis = new VisToolPointOfIntersectionCurves(data); vis = new VisToolPointOfIntersectionCurves(data);
} }
@ -80,7 +85,7 @@ quint32 DialogPointOfIntersectionCurves::GetFirstCurveId() const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPointOfIntersectionCurves::SetFirstCurveId(const quint32 &value) void DialogPointOfIntersectionCurves::SetFirstCurveId(const quint32 &value)
{ {
setCurrentPointId(ui->comboBoxCurve1, value); setCurrentCurveId(ui->comboBoxCurve1, value);
auto point = qobject_cast<VisToolPointOfIntersectionCurves *>(vis); auto point = qobject_cast<VisToolPointOfIntersectionCurves *>(vis);
SCASSERT(point != nullptr); SCASSERT(point != nullptr);
@ -96,7 +101,7 @@ quint32 DialogPointOfIntersectionCurves::GetSecondCurveId() const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogPointOfIntersectionCurves::SetSecondCurveId(const quint32 &value) void DialogPointOfIntersectionCurves::SetSecondCurveId(const quint32 &value)
{ {
setCurrentPointId(ui->comboBoxCurve2, value); setCurrentCurveId(ui->comboBoxCurve2, value);
auto point = qobject_cast<VisToolPointOfIntersectionCurves *>(vis); auto point = qobject_cast<VisToolPointOfIntersectionCurves *>(vis);
SCASSERT(point != nullptr); SCASSERT(point != nullptr);
@ -202,3 +207,34 @@ void DialogPointOfIntersectionCurves::SaveData()
point->setHCrossPoint(GetHCrossPoint()); point->setHCrossPoint(GetHCrossPoint());
point->RefreshGeometry(); point->RefreshGeometry();
} }
//---------------------------------------------------------------------------------------------------------------------
void DialogPointOfIntersectionCurves::CheckState()
{
SCASSERT(bOk != nullptr);
bOk->setEnabled(flagName && flagError);
// In case dialog hasn't apply button
if ( bApply != nullptr)
{
bApply->setEnabled(bOk->isEnabled());
}
}
//---------------------------------------------------------------------------------------------------------------------
void DialogPointOfIntersectionCurves::CurveChanged()
{
QColor color = okColor;
if (getCurrentObjectId(ui->comboBoxCurve1) == getCurrentObjectId(ui->comboBoxCurve2))
{
flagError = false;
color = errorColor;
}
else
{
flagError = true;
color = okColor;
}
ChangeColor(ui->labelCurve1, color);
ChangeColor(ui->labelCurve2, color);
CheckState();
}

View File

@ -67,6 +67,10 @@ protected:
* @brief SaveData Put dialog data in local variables * @brief SaveData Put dialog data in local variables
*/ */
virtual void SaveData() Q_DECL_OVERRIDE; virtual void SaveData() Q_DECL_OVERRIDE;
virtual void CheckState() Q_DECL_OVERRIDE;
private slots:
void CurveChanged();
private: private:
Q_DISABLE_COPY(DialogPointOfIntersectionCurves) Q_DISABLE_COPY(DialogPointOfIntersectionCurves)

View File

@ -24,7 +24,7 @@
<enum>QFormLayout::ExpandingFieldsGrow</enum> <enum>QFormLayout::ExpandingFieldsGrow</enum>
</property> </property>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QLabel" name="label_4"> <widget class="QLabel" name="labelCurve1">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -44,7 +44,7 @@
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="label_5"> <widget class="QLabel" name="labelCurve2">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch> <horstretch>0</horstretch>