Prepare to build.

--HG--
branch : feature
This commit is contained in:
dismine 2014-08-26 20:23:08 +03:00
parent 3ccd408718
commit 8343f20998
11 changed files with 384 additions and 97 deletions

View file

@ -41,6 +41,7 @@
#include "widgets/vapplication.h"
#include "widgets/undoevent.h"
#include "undocommands/renamepp.h"
#include "vtooloptionspropertybrowser.h"
#include <QInputDialog>
#include <QDebug>
@ -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);
}
//---------------------------------------------------------------------------------------------------------------------

View file

@ -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

View file

@ -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 };

View file

@ -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;
}

View file

@ -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();

View file

@ -0,0 +1,224 @@
/************************************************************************
**
** @file vtooloptionspropertybrowser.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @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
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#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 <QDockWidget>
#include <QHBoxLayout>
using namespace VPE;
//---------------------------------------------------------------------------------------------------------------------
VToolOptionsPropertyBrowser::VToolOptionsPropertyBrowser(QDockWidget *parent)
:QObject(parent),
currentItem(nullptr),
propertyToId(QMap<VProperty *, QString>()),
idToProperty(QMap<QString, VProperty *>())
{
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<VProperty *, QString>::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<VToolSinglePoint *>(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<VToolSinglePoint *>(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<VToolSinglePoint *>(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;
}
}

View file

@ -0,0 +1,75 @@
/************************************************************************
**
** @file vtooloptionspropertybrowser.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @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
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef VTOOLOPTIONSPROPERTYBROWSER_H
#define VTOOLOPTIONSPROPERTYBROWSER_H
#include <QObject>
#include <QMap>
#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<VProperty *, QString> propertyToId;
QMap<QString, VProperty *> idToProperty;
void AddProperty(VProperty *property, const QString &id);
void ShowItemOptions(QGraphicsItem *item);
};
#endif // VTOOLOPTIONSPROPERTYBROWSER_H

View file

@ -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

View file

@ -1,34 +0,0 @@
/************************************************************************
**
** @file vpropertyexplorer.cpp
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @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
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#include "vpropertyexplorer.h"
Vpropertyexplorer::Vpropertyexplorer()
{
}

View file

@ -1,41 +0,0 @@
/************************************************************************
**
** @file vpropertyexplorer.h
** @author Roman Telezhynskyi <dismine(at)gmail.com>
** @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
** <https://bitbucket.org/dismine/valentina> 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 <http://www.gnu.org/licenses/>.
**
*************************************************************************/
#ifndef VPROPERTYEXPLORER_H
#define VPROPERTYEXPLORER_H
#include "vpropertyexplorer_global.h"
class VPROPERTYEXPLORERSHARED_EXPORT Vpropertyexplorer
{
public:
Vpropertyexplorer();
};
#endif // VPROPERTYEXPLORER_H

View file

@ -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 \