Don't show children in point combobox.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2015-06-20 21:32:35 +03:00
parent 9b49c5122c
commit 0c947f5f50
5 changed files with 72 additions and 156 deletions

View File

@ -157,7 +157,7 @@ void DialogCutArc::closeEvent(QCloseEvent *event)
*/ */
void DialogCutArc::setArcId(const quint32 &value) void DialogCutArc::setArcId(const quint32 &value)
{ {
setCurrentArcId(ui->comboBoxArc, value, ComboBoxCutArc::CutArc); setCurrentArcId(ui->comboBoxArc, value, FillComboBox::NoChildren);
VisToolCutArc *path = qobject_cast<VisToolCutArc *>(vis); VisToolCutArc *path = qobject_cast<VisToolCutArc *>(vis);
SCASSERT(path != nullptr); SCASSERT(path != nullptr);

View File

@ -114,7 +114,7 @@ void DialogCutSpline::SetFormula(const QString &value)
*/ */
void DialogCutSpline::setSplineId(const quint32 &value) void DialogCutSpline::setSplineId(const quint32 &value)
{ {
setCurrentSplineId(ui->comboBoxSpline, value, ComboBoxCutSpline::CutSpline); setCurrentSplineId(ui->comboBoxSpline, value, FillComboBox::NoChildren);
VisToolCutSpline *path = qobject_cast<VisToolCutSpline *>(vis); VisToolCutSpline *path = qobject_cast<VisToolCutSpline *>(vis);
SCASSERT(path != nullptr); SCASSERT(path != nullptr);

View File

@ -114,7 +114,7 @@ void DialogCutSplinePath::SetFormula(const QString &value)
*/ */
void DialogCutSplinePath::setSplinePathId(const quint32 &value) void DialogCutSplinePath::setSplinePathId(const quint32 &value)
{ {
setCurrentSplinePathId(ui->comboBoxSplinePath, value, ComboBoxCutSpline::CutSpline); setCurrentSplinePathId(ui->comboBoxSplinePath, value, FillComboBox::NoChildren);
VisToolCutSplinePath *path = qobject_cast<VisToolCutSplinePath *>(vis); VisToolCutSplinePath *path = qobject_cast<VisToolCutSplinePath *>(vis);
SCASSERT(path != nullptr); SCASSERT(path != nullptr);

View File

@ -115,146 +115,27 @@ void DialogTool::showEvent(QShowEvent *event)
* @brief FillComboBoxPoints fill comboBox list of points * @brief FillComboBoxPoints fill comboBox list of points
* @param box comboBox * @param box comboBox
*/ */
void DialogTool::FillComboBoxPoints(QComboBox *box) const void DialogTool::FillComboBoxPoints(QComboBox *box, FillComboBox rule) const
{ {
SCASSERT(box != nullptr); FillCombo<VPointF>(box, GOType::Point, rule);
const QHash<quint32, QSharedPointer<VGObject> > *objs = data->DataGObjects();
QMap<QString, quint32> list;
QHash<quint32, QSharedPointer<VGObject> >::const_iterator i;
for (i = objs->constBegin(); i != objs->constEnd(); ++i)
{
if (i.key() != toolId)
{
QSharedPointer<VGObject> obj = i.value();
if (obj->getType() == GOType::Point && obj->getMode() == Draw::Calculation)
{
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(i.key());
list[point->name()] = i.key();
}
}
}
FillList(box, list);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogTool::FillComboBoxArcs(QComboBox *box, ComboBoxCutArc cut) const void DialogTool::FillComboBoxArcs(QComboBox *box, FillComboBox rule) const
{ {
SCASSERT(box != nullptr); FillCombo<VArc>(box, GOType::Arc, rule);
const QHash<quint32, QSharedPointer<VGObject> > *objs = data->DataGObjects();
QHash<quint32, QSharedPointer<VGObject> >::const_iterator i;
QMap<QString, quint32> list;
for (i = objs->constBegin(); i != objs->constEnd(); ++i)
{
if (cut == ComboBoxCutArc::CutArc)
{
if (i.key() != toolId + 1 && i.key() != toolId + 2)
{
QSharedPointer<VGObject> obj = i.value();
if (obj->getType() == GOType::Arc && obj->getMode() == Draw::Calculation)
{
const QSharedPointer<VArc> arc = data->GeometricObject<VArc>(i.key());
list[arc->name()] = i.key();
}
}
}
else
{
if (i.key() != toolId)
{
QSharedPointer<VGObject> obj = i.value();
if (obj->getType() == GOType::Arc && obj->getMode() == Draw::Calculation)
{
const QSharedPointer<VArc> arc = data->GeometricObject<VArc>(i.key());
list[arc->name()] = i.key();
}
}
}
}
FillList(box, list);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** void DialogTool::FillComboBoxSplines(QComboBox *box, FillComboBox rule) const
* @brief FillComboBoxSplines fill comboBox list of splines
* @param box comboBox
* @param cut if set to ComboMode::CutSpline don't show id+1 and id+2
*/
void DialogTool::FillComboBoxSplines(QComboBox *box, ComboBoxCutSpline cut) const
{ {
SCASSERT(box != nullptr); FillCombo<VSpline>(box, GOType::Spline, rule);
const QHash<quint32, QSharedPointer<VGObject> > *objs = data->DataGObjects();
QHash<quint32, QSharedPointer<VGObject> >::const_iterator i;
QMap<QString, quint32> list;
for (i = objs->constBegin(); i != objs->constEnd(); ++i)
{
if (cut == ComboBoxCutSpline::CutSpline)
{
if (i.key() != toolId + 1 && i.key() != toolId + 2)
{
QSharedPointer<VGObject> obj = i.value();
if (obj->getType() == GOType::Spline && obj->getMode() == Draw::Calculation)
{
const QSharedPointer<VSpline> spl = data->GeometricObject<VSpline>(i.key());
list[spl->name()] = i.key();
}
}
}
else
{
if (i.key() != toolId)
{
QSharedPointer<VGObject> obj = i.value();
if (obj->getType() == GOType::Spline && obj->getMode() == Draw::Calculation)
{
const QSharedPointer<VSpline> spl = data->GeometricObject<VSpline>(i.key());
list[spl->name()] = i.key();
}
}
}
}
FillList(box, list);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** void DialogTool::FillComboBoxSplinesPath(QComboBox *box, FillComboBox rule) const
* @brief FillComboBoxSplinesPath
* @param box comboBox
* @param cut if set to ComboMode::CutSpline don't show id+1 and id+2
*/
void DialogTool::FillComboBoxSplinesPath(QComboBox *box, ComboBoxCutSpline cut) const
{ {
SCASSERT(box != nullptr); FillCombo<VSplinePath>(box, GOType::SplinePath, rule);
const QHash<quint32, QSharedPointer<VGObject> > *objs = data->DataGObjects();
QMap<QString, quint32> list;
QHash<quint32, QSharedPointer<VGObject> >::const_iterator i;
for (i = objs->constBegin(); i != objs->constEnd(); ++i)
{
if (cut == ComboBoxCutSpline::CutSpline)
{
if (i.key() != toolId + 1 && i.key() != toolId + 2)
{
QSharedPointer<VGObject> obj = i.value();
if (obj->getType() == GOType::SplinePath && obj->getMode() == Draw::Calculation)
{
const QSharedPointer<VSplinePath> splPath = data->GeometricObject<VSplinePath>(i.key());
list[splPath->name()] = i.key();
}
}
}
else
{
if (i.key() != toolId)
{
QSharedPointer<VGObject> obj = i.value();
if (obj->getType() == GOType::SplinePath && obj->getMode() == Draw::Calculation)
{
const QSharedPointer<VSplinePath> splPath = data->GeometricObject<VSplinePath>(i.key());
list[splPath->name()] = i.key();
}
}
}
}
FillList(box, list);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
@ -505,13 +386,13 @@ qreal DialogTool::Eval(const QString &text, bool &flag, QLabel *label, const QSt
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
void DialogTool::setCurrentPointId(QComboBox *box, const quint32 &value) const void DialogTool::setCurrentPointId(QComboBox *box, const quint32 &value, FillComboBox rule) const
{ {
SCASSERT(box != nullptr); SCASSERT(box != nullptr);
box->blockSignals(true); box->blockSignals(true);
FillComboBoxPoints(box); FillComboBoxPoints(box, rule);
ChangeCurrentData(box, value); ChangeCurrentData(box, value);
box->blockSignals(false); box->blockSignals(false);
@ -520,28 +401,22 @@ void DialogTool::setCurrentPointId(QComboBox *box, const quint32 &value) const
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief setCurrentSplineId set current spline id in combobox * @brief setCurrentSplineId set current spline id in combobox
* @param box combobox
* @param value spline id
* @param cut if set to ComboMode::CutSpline don't show id+1 and id+2
*/ */
void DialogTool::setCurrentSplineId(QComboBox *box, const quint32 &value, ComboBoxCutSpline cut) const void DialogTool::setCurrentSplineId(QComboBox *box, const quint32 &value, FillComboBox rule) const
{ {
SCASSERT(box != nullptr); SCASSERT(box != nullptr);
FillComboBoxSplines(box, cut); FillComboBoxSplines(box, rule);
ChangeCurrentData(box, value); ChangeCurrentData(box, value);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
/** /**
* @brief setCurrentArcId * @brief setCurrentArcId
* @param box combobox
* @param value arc id
* @param cut if set to ComboMode::CutArc don't show id+1 and id+2
*/ */
void DialogTool::setCurrentArcId(QComboBox *box, const quint32 &value, ComboBoxCutArc cut) const void DialogTool::setCurrentArcId(QComboBox *box, const quint32 &value, FillComboBox rule) const
{ {
SCASSERT(box != nullptr); SCASSERT(box != nullptr);
FillComboBoxArcs(box, cut); FillComboBoxArcs(box, rule);
ChangeCurrentData(box, value); ChangeCurrentData(box, value);
} }
@ -552,10 +427,10 @@ void DialogTool::setCurrentArcId(QComboBox *box, const quint32 &value, ComboBoxC
* @param value splinePath id * @param value splinePath id
* @param cut if set to ComboMode::CutSpline don't show id+1 and id+2 * @param cut if set to ComboMode::CutSpline don't show id+1 and id+2
*/ */
void DialogTool::setCurrentSplinePathId(QComboBox *box, const quint32 &value, ComboBoxCutSpline cut) const void DialogTool::setCurrentSplinePathId(QComboBox *box, const quint32 &value, FillComboBox rule) const
{ {
SCASSERT(box != nullptr); SCASSERT(box != nullptr);
FillComboBoxSplinesPath(box, cut); FillComboBoxSplinesPath(box, rule);
ChangeCurrentData(box, value); ChangeCurrentData(box, value);
} }
@ -922,3 +797,41 @@ void DialogTool::SetAssociatedTool(VAbstractTool *tool)
this->associatedTool=tool; this->associatedTool=tool;
SetToolId(tool->getId()); SetToolId(tool->getId());
} }
//---------------------------------------------------------------------------------------------------------------------
template <typename GObject>
void DialogTool::FillCombo(QComboBox *box, GOType gType, FillComboBox rule) const
{
SCASSERT(box != nullptr);
const QHash<quint32, QSharedPointer<VGObject> > *objs = data->DataGObjects();
QHash<quint32, QSharedPointer<VGObject> >::const_iterator i;
QMap<QString, quint32> list;
for (i = objs->constBegin(); i != objs->constEnd(); ++i)
{
if (rule == FillComboBox::NoChildren)
{
if (i.key() != toolId + 1 && i.key() != toolId + 2)
{
QSharedPointer<VGObject> obj = i.value();
if (obj->getType() == gType && obj->getMode() == Draw::Calculation)
{
const QSharedPointer<GObject> arc = data->GeometricObject<GObject>(i.key());
list[arc->name()] = i.key();
}
}
}
else
{
if (i.key() != toolId)
{
QSharedPointer<VGObject> obj = i.value();
if (obj->getType() == gType && obj->getMode() == Draw::Calculation)
{
const QSharedPointer<GObject> arc = data->GeometricObject<GObject>(i.key());
list[arc->name()] = i.key();
}
}
}
}
FillList(box, list);
}

View File

@ -53,8 +53,7 @@ class VContainer;
class QPlainTextEdit; class QPlainTextEdit;
class VAbstractTool; class VAbstractTool;
enum class ComboBoxCutSpline : char { CutSpline, NoCutSpline }; enum class FillComboBox : char { Whole, NoChildren};
enum class ComboBoxCutArc : char { CutArc, NoCutArc};
/** /**
* @brief The DialogTool class parent for all dialog of tools. * @brief The DialogTool class parent for all dialog of tools.
@ -185,11 +184,10 @@ protected:
virtual void closeEvent ( QCloseEvent * event ); virtual void closeEvent ( QCloseEvent * event );
virtual void showEvent( QShowEvent *event ); virtual void showEvent( QShowEvent *event );
void FillComboBoxPoints(QComboBox *box)const; void FillComboBoxPoints(QComboBox *box, FillComboBox rule = FillComboBox::Whole)const;
void FillComboBoxArcs(QComboBox *box, ComboBoxCutArc cut = ComboBoxCutArc::NoCutArc)const; void FillComboBoxArcs(QComboBox *box, FillComboBox rule = FillComboBox::Whole)const;
void FillComboBoxSplines(QComboBox *box, ComboBoxCutSpline cut = ComboBoxCutSpline::NoCutSpline)const; void FillComboBoxSplines(QComboBox *box, FillComboBox rule = FillComboBox::Whole)const;
void FillComboBoxSplinesPath(QComboBox *box, void FillComboBoxSplinesPath(QComboBox *box, FillComboBox rule = FillComboBox::Whole)const;
ComboBoxCutSpline cut = ComboBoxCutSpline::NoCutSpline)const;
void FillComboBoxCurves(QComboBox *box)const; void FillComboBoxCurves(QComboBox *box)const;
void FillComboBoxTypeLine(QComboBox *box, const QMap<QString, QIcon> &stylesPics) const; void FillComboBoxTypeLine(QComboBox *box, const QMap<QString, QIcon> &stylesPics) const;
void FillComboBoxLineColors(QComboBox *box)const; void FillComboBoxLineColors(QComboBox *box)const;
@ -202,13 +200,15 @@ protected:
void ValFormulaChanged(bool &flag, QPlainTextEdit *edit, QTimer * timer); void ValFormulaChanged(bool &flag, QPlainTextEdit *edit, QTimer * timer);
qreal Eval(const QString &text, bool &flag, QLabel *label, const QString &postfix, qreal Eval(const QString &text, bool &flag, QLabel *label, const QString &postfix,
bool checkZero = true); bool checkZero = true);
void setCurrentPointId(QComboBox *box, const quint32 &value) const;
void setCurrentPointId(QComboBox *box, const quint32 &value,
FillComboBox rule = FillComboBox::NoChildren) const;
void setCurrentSplineId(QComboBox *box, const quint32 &value, void setCurrentSplineId(QComboBox *box, const quint32 &value,
ComboBoxCutSpline cut = ComboBoxCutSpline::NoCutSpline) const; FillComboBox rule = FillComboBox::NoChildren) const;
void setCurrentArcId(QComboBox *box, const quint32 &value, void setCurrentArcId(QComboBox *box, const quint32 &value,
ComboBoxCutArc cut = ComboBoxCutArc::NoCutArc) const; FillComboBox rule = FillComboBox::NoChildren) const;
void setCurrentSplinePathId(QComboBox *box, const quint32 &value, void setCurrentSplinePathId(QComboBox *box, const quint32 &value,
ComboBoxCutSpline cut = ComboBoxCutSpline::NoCutSpline) const; FillComboBox rule = FillComboBox::NoChildren) const;
void setCurrentCurveId(QComboBox *box, const quint32 &value) const; void setCurrentCurveId(QComboBox *box, const quint32 &value) const;
quint32 getCurrentObjectId(QComboBox *box) const; quint32 getCurrentObjectId(QComboBox *box) const;
@ -309,6 +309,9 @@ protected:
bool eventFilter(QObject *object, QEvent *event); bool eventFilter(QObject *object, QEvent *event);
private: private:
void FillList(QComboBox *box, const QMap<QString, quint32> &list)const; void FillList(QComboBox *box, const QMap<QString, quint32> &list)const;
template <typename GObject>
void FillCombo(QComboBox *box, GOType gType, FillComboBox rule = FillComboBox::Whole) const;
}; };
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------