--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2015-12-17 13:13:11 +02:00
commit 949f4be2c6
7 changed files with 29 additions and 9 deletions

View File

@ -289,6 +289,7 @@ void MainWindow::InitScenes()
connect(this, &MainWindow::EnableItemMove, sceneDraw, &VMainGraphicsScene::EnableItemMove);
connect(sceneDraw, &VMainGraphicsScene::mouseMove, this, &MainWindow::mouseMove);
sceneDetails = new VMainGraphicsScene();
connect(this, &MainWindow::EnableItemMove, sceneDetails, &VMainGraphicsScene::EnableItemMove);
connect(sceneDetails, &VMainGraphicsScene::mouseMove, this, &MainWindow::mouseMove);
ui->view->setScene(currentScene);

View File

@ -1263,7 +1263,7 @@ void VPattern::ParseNodePoint(const QDomElement &domElement, const Document &par
const QSharedPointer<VPointF> point = data->GeometricObject<VPointF>(idObject );
data->UpdateGObject(id, new VPointF(point->toQPointF(), point->name(), mx, my, idObject,
Draw::Modeling));
VNodePoint::Create(this, data, id, idObject, parse, Source::FromFile, idTool);
VNodePoint::Create(this, data, sceneDetail, id, idObject, parse, Source::FromFile, idTool);
}
catch (const VExceptionBadId &e)
{

View File

@ -55,6 +55,7 @@ VNodePoint::VNodePoint(VAbstractPattern *doc, VContainer *data, quint32 id, quin
{
radius = ToPixel(DefPointRadius/*mm*/, Unit::Mm);
namePoint = new VGraphicsSimpleTextItem(this);
connect(namePoint, &VGraphicsSimpleTextItem::PointChoosed, this, &VNodePoint::PointChoosed);
lineName = new QGraphicsLineItem(this);
connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this,
&VNodePoint::NameChangePosition);
@ -78,7 +79,8 @@ VNodePoint::VNodePoint(VAbstractPattern *doc, VContainer *data, quint32 id, quin
* @param idTool tool id.
* @param parent QObject parent
*/
void VNodePoint::Create(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idPoint, const Document &parse,
void VNodePoint::Create(VAbstractPattern *doc, VContainer *data, VMainGraphicsScene *scene,
quint32 id, quint32 idPoint, const Document &parse,
const Source &typeCreation, const quint32 &idTool, QObject *parent)
{
VAbstractTool::AddRecord(id, Tool::NodePoint, doc);
@ -87,6 +89,7 @@ void VNodePoint::Create(VAbstractPattern *doc, VContainer *data, quint32 id, qui
//TODO Need create garbage collector and remove all nodes, what we don't use.
//Better check garbage before each saving file. Check only modeling tags.
VNodePoint *point = new VNodePoint(doc, data, id, idPoint, typeCreation, idTool, parent);
connect(scene, &VMainGraphicsScene::EnableToolMove, point, &VNodePoint::EnableToolMove);
doc->AddTool(id, point);
if (idTool != 0)
{
@ -133,6 +136,12 @@ QString VNodePoint::getTagName() const
return VNodePoint::TagName;
}
//---------------------------------------------------------------------------------------------------------------------
void VNodePoint::PointChoosed()
{
emit ChoosedTool(id, SceneObject::Point);
}
//---------------------------------------------------------------------------------------------------------------------
/**
* @brief FullUpdateFromFile update tool data form file.
@ -281,3 +290,10 @@ void VNodePoint::RefreshLine()
{
VAbstractTool::RefreshLine(this, namePoint, lineName, radius);
}
//---------------------------------------------------------------------------------------------------------------------
void VNodePoint::EnableToolMove(bool move)
{
this->setFlag(QGraphicsItem::ItemIsMovable, move);
namePoint->setFlag(QGraphicsItem::ItemIsMovable, move);
}

View File

@ -48,7 +48,8 @@ public:
VNodePoint(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idPoint, const Source &typeCreation,
const quint32 &idTool = 0, QObject *qoParent = nullptr, QGraphicsItem * parent = nullptr );
static void Create(VAbstractPattern *doc, VContainer *data, quint32 id, quint32 idPoint, const Document &parse,
static void Create(VAbstractPattern *doc, VContainer *data, VMainGraphicsScene *scene,
quint32 id, quint32 idPoint, const Document &parse,
const Source &typeCreation, const quint32 &idTool = 0, QObject *parent = nullptr);
static const QString TagName;
static const QString ToolType;
@ -60,6 +61,8 @@ public:
public slots:
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE;
void NameChangePosition(const QPointF &pos);
void PointChoosed();
void EnableToolMove(bool move);
protected:
/** @brief radius radius circle. */
qreal radius;

View File

@ -160,7 +160,7 @@ void VToolDetail::Create(DialogTool *dialog, VMainGraphicsScene *scene, VAbstrac
case (Tool::NodePoint):
{
id = CreateNode<VPointF>(data, nodeD.getId());
VNodePoint::Create(doc, data, id, nodeD.getId(), Document::FullParse, Source::FromGui);
VNodePoint::Create(doc, data, scene, id, nodeD.getId(), Document::FullParse, Source::FromGui);
}
break;
case (Tool::NodeArc):

View File

@ -82,7 +82,7 @@ VToolUnionDetails::VToolUnionDetails(VAbstractPattern *doc, VContainer *data, co
* @param pRotate point rotation.
* @param angle angle rotation.
*/
void VToolUnionDetails::AddToNewDetail(QObject *tool, VAbstractPattern *doc, VContainer *data, VDetail &newDetail,
void VToolUnionDetails::AddToNewDetail(QObject *tool, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, VDetail &newDetail,
const VDetail &det, const int &i, const quint32 &idTool, const qreal &dx,
const qreal &dy, const quint32 &pRotate, const qreal &angle)
{
@ -105,7 +105,7 @@ void VToolUnionDetails::AddToNewDetail(QObject *tool, VAbstractPattern *doc, VCo
VPointF *point1 = new VPointF(*point);
point1->setMode(Draw::Modeling);
id = data->AddGObject(point1);
VNodePoint::Create(doc, data, id, idObject, Document::FullParse, Source::FromGui, idTool, tool);
VNodePoint::Create(doc, data, scene, id, idObject, Document::FullParse, Source::FromGui, idTool, tool);
}
}
break;
@ -546,7 +546,7 @@ VToolUnionDetails* VToolUnionDetails::Create(const quint32 _id, const VDetail &d
VDetail newDetail;
do
{
AddToNewDetail(unionDetails, doc, data, newDetail, d1.RemoveEdge(indexD1), i, id);
AddToNewDetail(unionDetails, scene, doc, data, newDetail, d1.RemoveEdge(indexD1), i, id);
++i;
if (i > d1.indexOfNode(det1p1.getId()) && pointsD2 < countNodeD2-2)
{
@ -558,7 +558,7 @@ VToolUnionDetails* VToolUnionDetails::Create(const quint32 _id, const VDetail &d
{
j=0;
}
AddToNewDetail(unionDetails, doc, data, newDetail, d2.RemoveEdge(indexD2), j, id, dx, dy,
AddToNewDetail(unionDetails, scene, doc, data, newDetail, d2.RemoveEdge(indexD2), j, id, dx, dy,
det1p1.getId(), angle);
++pointsD2;
++j;

View File

@ -69,7 +69,7 @@ public:
static const QString AttrNodeType;
static const QString NodeTypeContour;
static const QString NodeTypeModeling;
static void AddToNewDetail(QObject *tool, VAbstractPattern *doc, VContainer *data, VDetail &newDetail,
static void AddToNewDetail(QObject *tool, VMainGraphicsScene *scene, VAbstractPattern *doc, VContainer *data, VDetail &newDetail,
const VDetail &det, const int &i, const quint32 &idTool, const qreal &dx = 0,
const qreal &dy = 0, const quint32 &pRotate = 0, const qreal &angle = 0);
static void UpdatePoints(const quint32 &idDetail, VContainer *data, const VDetail &det, const int &i,