diff --git a/src/app/mainwindow.cpp b/src/app/mainwindow.cpp index f547d6610..4f282b910 100644 --- a/src/app/mainwindow.cpp +++ b/src/app/mainwindow.cpp @@ -41,6 +41,7 @@ #include "widgets/vapplication.h" #include "widgets/undoevent.h" #include "undocommands/renamepp.h" +#include "vtooloptionspropertybrowser.h" #include #include @@ -112,6 +113,7 @@ MainWindow::MainWindow(QWidget *parent) ui->toolBox->setCurrentIndex(0); ReadSettings(); + PropertyBrowser(); setCurrentFile(""); } @@ -1959,6 +1961,26 @@ void MainWindow::CreateMenus() separatorAct = new QAction(this); separatorAct->setSeparator(true); ui->menuPatternPiece->insertAction(ui->actionPattern_properties, separatorAct); + AddDocks(); +} + +void MainWindow::AddDocks() +{ + ui->menuPatternPiece->insertAction(ui->actionPattern_properties, ui->dockWidgetHistory->toggleViewAction()); + ui->dockWidgetHistory->close();//Default don't show hostory + ui->menuPatternPiece->insertAction(ui->actionPattern_properties, ui->dockWidgetToolOptions->toggleViewAction()); + + separatorAct = new QAction(this); + separatorAct->setSeparator(true); + ui->menuPatternPiece->insertAction(ui->actionPattern_properties, separatorAct); +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::PropertyBrowser() +{ + toolOptions = new VToolOptionsPropertyBrowser(ui->dockWidgetToolOptions); + + connect(ui->view, &VMainGraphicsView::itemClicked, toolOptions, &VToolOptionsPropertyBrowser::itemClicked); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/mainwindow.h b/src/app/mainwindow.h index b749251a9..4c860bd2b 100644 --- a/src/app/mainwindow.h +++ b/src/app/mainwindow.h @@ -44,6 +44,8 @@ namespace Ui class MainWindow; } +class VToolOptionsPropertyBrowser; + /** * @brief The MainWindow class main windows. */ @@ -194,6 +196,8 @@ private: bool guiEnabled; QComboBox *gradationHeights; QComboBox *gradationSizes; + VToolOptionsPropertyBrowser *toolOptions; + void ToolBarOption(); void ToolBarDraws(); void ToolBarTools(); @@ -243,6 +247,9 @@ private: void UpdateSizesList(const QStringList &list); void SetDefaultHeight(int value); void SetDefaultSize(int value); + + void AddDocks(); + void PropertyBrowser(); }; #endif // MAINWINDOW_H diff --git a/src/app/options.h b/src/app/options.h index 2baec9341..e2a2a7d4d 100644 --- a/src/app/options.h +++ b/src/app/options.h @@ -42,25 +42,29 @@ class QString; #define NULL_ID 0//use this value for initialization variables that keeps id values. 0 mean uknown id value. enum class SceneObject : char { Point, Line, Spline, Arc, SplinePath, Detail, Unknown }; -enum class Tool : char +enum class Tool : unsigned char { - ArrowTool, - SinglePointTool, - EndLineTool, - LineTool, - AlongLineTool, - ShoulderPointTool, - NormalTool, - BisectorTool, - LineIntersectTool, - SplineTool, - CutSplineTool, - CutArcTool, - ArcTool, - SplinePathTool, - CutSplinePathTool, + Arrow, + Point, + LinePoint, + AbstractSpline, + Cut, + SinglePoint, + EndLine, + Line, + AlongLine, + ShoulderPoint, + Normal, + Bisector, + LineIntersect, + Spline, + CutSpline, + CutArc, + Arc, + SplinePath, + CutSplinePath, PointOfContact, - DetailTool, + Detail, NodePoint, NodeArc, NodeSpline, @@ -71,6 +75,30 @@ enum class Tool : char UnionDetails }; +enum class Vis : unsigned char +{ + ControlPointSpline, + GraphicsSimpleTextItem, + Line, + Path, + ToolAlongLine, + ToolArc, + ToolBisector, + ToolCutArc, + ToolEndLine, + ToolHeight, + ToolLine, + ToolLineIntersect, + ToolNormal, + ToolPointOfContact, + ToolPointOfIntersection, + ToolShoulderPoint, + ToolSpline, + ToolTriangle, + SimpleCurvePoint, + SimpleSplinePath +}; + enum class Source : char { FromGui, FromFile, FromTool }; enum class Draw : char { Calculation, Modeling }; enum class Unit : char { Mm, Cm, Inch }; diff --git a/src/app/widgets/vmaingraphicsview.cpp b/src/app/widgets/vmaingraphicsview.cpp index 46ad814ac..a11e3b0d9 100644 --- a/src/app/widgets/vmaingraphicsview.cpp +++ b/src/app/widgets/vmaingraphicsview.cpp @@ -220,6 +220,9 @@ void VMainGraphicsView::mousePressEvent(QMouseEvent *mousePress) case Qt::ControlModifier: QGraphicsView::setDragMode(QGraphicsView::ScrollHandDrag); break; + case Qt::NoModifier: + emit itemClicked(itemAt(mousePress->pos())); + break; default: break; } diff --git a/src/app/widgets/vmaingraphicsview.h b/src/app/widgets/vmaingraphicsview.h index e34baf781..8df21f47c 100644 --- a/src/app/widgets/vmaingraphicsview.h +++ b/src/app/widgets/vmaingraphicsview.h @@ -108,7 +108,8 @@ signals: * * Usefull when you need show dialog after working with tool visualization. */ - void MouseRelease(); + void MouseRelease(); + void itemClicked(QGraphicsItem *item); public slots: void ZoomIn(); void ZoomOut(); diff --git a/src/app/widgets/vtooloptionspropertybrowser.cpp b/src/app/widgets/vtooloptionspropertybrowser.cpp new file mode 100644 index 000000000..dbd56109e --- /dev/null +++ b/src/app/widgets/vtooloptionspropertybrowser.cpp @@ -0,0 +1,224 @@ +/************************************************************************ + ** + ** @file vtooloptionspropertybrowser.cpp + ** @author Roman Telezhynskyi + ** @date 22 8, 2014 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2014 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#include "vtooloptionspropertybrowser.h" +#include "tools/drawTools/drawtools.h" +#include "widgets/vapplication.h" +#include "widgets/vmaingraphicsview.h" +#include "visualization/vgraphicssimpletextitem.h" +#include "visualization/vcontrolpointspline.h" + +#include +#include + +using namespace VPE; + +//--------------------------------------------------------------------------------------------------------------------- +VToolOptionsPropertyBrowser::VToolOptionsPropertyBrowser(QDockWidget *parent) + :QObject(parent), + currentItem(nullptr), + propertyToId(QMap()), + idToProperty(QMap()) +{ + PropertyModel = new VPropertyModel(this); + TreeView = new VPropertyFormView(PropertyModel); + TreeView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); + + QScrollArea *scroll = new QScrollArea(); + scroll->setWidgetResizable(true); + scroll->setWidget(TreeView); + + QHBoxLayout* layout = new QHBoxLayout(); + parent->setLayout(layout); + layout->setSpacing(5); + layout->setMargin(0); + layout->addWidget(scroll); + + connect(PropertyModel, SIGNAL(onDataChangedByEditor(VProperty*)), this, SLOT(userChangedData(VProperty*))); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::itemClicked(QGraphicsItem *item) +{ + QMap::ConstIterator itProp = propertyToId.constBegin(); + while (itProp != propertyToId.constEnd()) + { + delete itProp.key(); + itProp++; + } + propertyToId.clear(); + idToProperty.clear(); + + currentItem = item; + PropertyModel->clear(); + if (currentItem == nullptr) + { + return; + } + + ShowItemOptions(currentItem); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::userChangedData(VProperty *property) +{ + if (!propertyToId.contains(property)) + { + return; + } + + if (!currentItem) + { + return; + } + + QVariant variant = property->data(VProperty::DPC_Data); + + QString id = propertyToId[property]; + switch (currentItem->type()) + { + case VToolSinglePoint::Type: + { + if (id == QLatin1String("name")) + { + if (VToolSinglePoint *i = qgraphicsitem_cast(currentItem)) + { + if (variant.toString() == i->name()) + { + return; + } + + if (variant.toString().isEmpty()) + { + idToProperty[QLatin1String("name")]->setValue(i->name()); + } + else + { + //TODO check if label name is unique + i->setName(variant.toString()); + } + } + } + else if (id == QLatin1String("posX")) + { + currentItem->setX(variant.toDouble()); + } + else if (id == QLatin1String("posY")) + { + currentItem->setY(variant.toDouble()); + } + break; + } +// case VGraphicsSimpleTextItem::Type: +// ShowItemOptions(currentItem->parentItem()); +// break; +// case VControlPointSpline::Type: +// ShowItemOptions(currentItem->parentItem()); +// break; + default: + break; + } + qApp->getSceneView()->update(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::UpdateOptions() +{ + if (currentItem == nullptr) + { + return; + } + + switch (currentItem->type()) + { + case VToolSinglePoint::Type: + { + VToolSinglePoint *i = qgraphicsitem_cast(currentItem); + idToProperty[QLatin1String("name")]->setValue(i->name()); + idToProperty[QLatin1String("posX")]->setValue(i->x()); + idToProperty[QLatin1String("posY")]->setValue(i->y()); + break; + } + case VGraphicsSimpleTextItem::Type: + ShowItemOptions(currentItem->parentItem()); + break; + case VControlPointSpline::Type: + ShowItemOptions(currentItem->parentItem()); + break; + default: + break; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::AddProperty(VProperty *property, const QString &id) +{ + propertyToId[property] = id; + idToProperty[id] = property; + PropertyModel->addProperty(property, QLatin1String("name")); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolOptionsPropertyBrowser::ShowItemOptions(QGraphicsItem *item) +{ + switch (item->type()) + { + case VToolSinglePoint::Type: + { + VToolSinglePoint *i = qgraphicsitem_cast(item); + + VProperty* itemName = new VProperty(tr("Point name")); + itemName->setValue(i->name()); + AddProperty(itemName, QLatin1String("name")); + + VDoubleProperty* positionX = new VDoubleProperty(tr("Position X")); + positionX->setValue(i->x()); + AddProperty(positionX, QLatin1String("posX")); + + VDoubleProperty* positionY = new VDoubleProperty(tr("Position Y")); + positionY->setValue(i->y()); + AddProperty(positionY, QLatin1String("posY")); + +// QtVariantProperty *position = variantManager->addProperty(QVariant::PointF, tr("Position")); +// position->setValue(i->pos()); +// AddProperty(position, QLatin1String("position")); +// mainGroup->addSubProperty(position); + break; + } + case VGraphicsSimpleTextItem::Type: + currentItem = item->parentItem(); + ShowItemOptions(currentItem); + break; + case VControlPointSpline::Type: + currentItem = item->parentItem(); + ShowItemOptions(currentItem); + break; + default: + break; + } +} diff --git a/src/app/widgets/vtooloptionspropertybrowser.h b/src/app/widgets/vtooloptionspropertybrowser.h new file mode 100644 index 000000000..16c72eeda --- /dev/null +++ b/src/app/widgets/vtooloptionspropertybrowser.h @@ -0,0 +1,75 @@ +/************************************************************************ + ** + ** @file vtooloptionspropertybrowser.h + ** @author Roman Telezhynskyi + ** @date 22 8, 2014 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2014 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef VTOOLOPTIONSPROPERTYBROWSER_H +#define VTOOLOPTIONSPROPERTYBROWSER_H + +#include +#include + +#include "../libs/vpropertyexplorer/vproperty.h" +#include "../libs/vpropertyexplorer/vpropertymodel.h" +#include "../libs/vpropertyexplorer/vpropertyformview.h" +#include "../libs/vpropertyexplorer/plugins/vnumberproperty.h" + +class QDockWidget; +class QGraphicsItem; +class QScrollArea; + +using namespace VPE; + +class VToolOptionsPropertyBrowser : public QObject +{ + Q_OBJECT +public: + VToolOptionsPropertyBrowser(QDockWidget *parent); +public slots: + void itemClicked(QGraphicsItem *item); + void userChangedData(VProperty* property); + void UpdateOptions(); +private: + Q_DISABLE_COPY(VToolOptionsPropertyBrowser) + + VPropertyModel* PropertyModel; + VPropertyFormView* TreeView; + +// class QtGroupPropertyManager *groupManager; +// class VVariantPropertyManager *variantManager; + +// QtProperty *mainGroup; + +// QtGroupBoxPropertyBrowser *propertyEditor; + QGraphicsItem *currentItem; + QMap propertyToId; + QMap idToProperty; + + void AddProperty(VProperty *property, const QString &id); + void ShowItemOptions(QGraphicsItem *item); +}; + +#endif // VTOOLOPTIONSPROPERTYBROWSER_H diff --git a/src/app/widgets/widgets.pri b/src/app/widgets/widgets.pri index 9f100cc0d..8def2ed00 100644 --- a/src/app/widgets/widgets.pri +++ b/src/app/widgets/widgets.pri @@ -7,7 +7,8 @@ HEADERS += \ widgets/doubledelegate.h \ widgets/textdelegate.h \ widgets/vtranslation.h \ - widgets/undoevent.h + widgets/undoevent.h \ + widgets/vtooloptionspropertybrowser.h SOURCES += \ widgets/vtablegraphicsview.cpp \ @@ -18,4 +19,5 @@ SOURCES += \ widgets/doubledelegate.cpp \ widgets/textdelegate.cpp \ widgets/vtranslation.cpp \ - widgets/undoevent.cpp + widgets/undoevent.cpp \ + widgets/vtooloptionspropertybrowser.cpp diff --git a/src/libs/vpropertyexplorer/vpropertyexplorer.cpp b/src/libs/vpropertyexplorer/vpropertyexplorer.cpp deleted file mode 100644 index 67bf08c0b..000000000 --- a/src/libs/vpropertyexplorer/vpropertyexplorer.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/************************************************************************ - ** - ** @file vpropertyexplorer.cpp - ** @author Roman Telezhynskyi - ** @date 26 8, 2014 - ** - ** @brief - ** @copyright - ** This source code is part of the Valentine project, a pattern making - ** program, whose allow create and modeling patterns of clothing. - ** Copyright (C) 2014 Valentina project - ** All Rights Reserved. - ** - ** Valentina is free software: you can redistribute it and/or modify - ** it under the terms of the GNU General Public License as published by - ** the Free Software Foundation, either version 3 of the License, or - ** (at your option) any later version. - ** - ** Valentina is distributed in the hope that it will be useful, - ** but WITHOUT ANY WARRANTY; without even the implied warranty of - ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ** GNU General Public License for more details. - ** - ** You should have received a copy of the GNU General Public License - ** along with Valentina. If not, see . - ** - *************************************************************************/ - -#include "vpropertyexplorer.h" - - -Vpropertyexplorer::Vpropertyexplorer() -{ -} diff --git a/src/libs/vpropertyexplorer/vpropertyexplorer.h b/src/libs/vpropertyexplorer/vpropertyexplorer.h deleted file mode 100644 index 36c1d5917..000000000 --- a/src/libs/vpropertyexplorer/vpropertyexplorer.h +++ /dev/null @@ -1,41 +0,0 @@ -/************************************************************************ - ** - ** @file vpropertyexplorer.h - ** @author Roman Telezhynskyi - ** @date 26 8, 2014 - ** - ** @brief - ** @copyright - ** This source code is part of the Valentine project, a pattern making - ** program, whose allow create and modeling patterns of clothing. - ** Copyright (C) 2014 Valentina project - ** All Rights Reserved. - ** - ** Valentina is free software: you can redistribute it and/or modify - ** it under the terms of the GNU General Public License as published by - ** the Free Software Foundation, either version 3 of the License, or - ** (at your option) any later version. - ** - ** Valentina is distributed in the hope that it will be useful, - ** but WITHOUT ANY WARRANTY; without even the implied warranty of - ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ** GNU General Public License for more details. - ** - ** You should have received a copy of the GNU General Public License - ** along with Valentina. If not, see . - ** - *************************************************************************/ - -#ifndef VPROPERTYEXPLORER_H -#define VPROPERTYEXPLORER_H - -#include "vpropertyexplorer_global.h" - -class VPROPERTYEXPLORERSHARED_EXPORT Vpropertyexplorer -{ - -public: - Vpropertyexplorer(); -}; - -#endif // VPROPERTYEXPLORER_H diff --git a/src/libs/vpropertyexplorer/vpropertyexplorer.pro b/src/libs/vpropertyexplorer/vpropertyexplorer.pro index a32c23255..ee82ff976 100644 --- a/src/libs/vpropertyexplorer/vpropertyexplorer.pro +++ b/src/libs/vpropertyexplorer/vpropertyexplorer.pro @@ -15,7 +15,7 @@ CONFIG += c++11 DEFINES += VPROPERTYEXPLORER_LIBRARY -SOURCES += vpropertyexplorer.cpp \ +SOURCES += \ vproperty.cpp \ vpropertydelegate.cpp \ vpropertyfactorymanager.cpp \ @@ -39,7 +39,7 @@ SOURCES += vpropertyexplorer.cpp \ plugins/vnumberproperty.cpp \ plugins/Vector3d/vvector3dproperty.cpp -HEADERS += vpropertyexplorer.h\ +HEADERS +=\ vpropertyexplorer_global.h \ vpropertyfactorymanager_p.h \ vpropertytreeview_p.h \