Zooming points, line and label of points after zooming scene.

--HG--
branch : develop
This commit is contained in:
dismine 2013-10-16 12:17:34 +03:00
parent eb03e8165e
commit 2fffdecc86
38 changed files with 386 additions and 249 deletions

View File

@ -62,6 +62,7 @@ MainWindow::MainWindow(QWidget *parent) :
view = new VMainGraphicsView(); view = new VMainGraphicsView();
ui->LayoutView->addWidget(view); ui->LayoutView->addWidget(view);
view->setScene(currentScene); view->setScene(currentScene);
connect(view, &VMainGraphicsView::NewFactor, sceneDraw, &VMainGraphicsScene::SetFactor);
QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding); QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding);
policy.setHorizontalStretch(12); policy.setHorizontalStretch(12);
view->setSizePolicy(policy); view->setSizePolicy(policy);
@ -162,6 +163,7 @@ void MainWindow::ActionNewDraw(){
VToolSinglePoint *spoint = new VToolSinglePoint(doc, data, id, Tool::FromGui); VToolSinglePoint *spoint = new VToolSinglePoint(doc, data, id, Tool::FromGui);
sceneDraw->addItem(spoint); sceneDraw->addItem(spoint);
connect(spoint, &VToolPoint::ChoosedTool, sceneDraw, &VMainGraphicsScene::ChoosedItem); connect(spoint, &VToolPoint::ChoosedTool, sceneDraw, &VMainGraphicsScene::ChoosedItem);
connect(sceneDraw, &VMainGraphicsScene::NewFactor, spoint, &VToolSinglePoint::SetFactor);
QHash<qint64, VDataTool*>* tools = doc->getTools(); QHash<qint64, VDataTool*>* tools = doc->getTools();
tools->insert(id, spoint); tools->insert(id, spoint);
VDrawTool::AddRecord(id, Tool::SinglePointTool, doc); VDrawTool::AddRecord(id, Tool::SinglePointTool, doc);

View File

@ -28,7 +28,7 @@
#define PaperSize 50000 #define PaperSize 50000
#define toPixel(mm) ((mm / 25.4) * PrintDPI) #define toPixel(mm) ((mm / 25.4) * PrintDPI)
#define toMM(pix) ((pix / PrintDPI) * 25.4) #define toMM(pix) ((pix / PrintDPI) * 25.4)
#define widthMainLine toPixel(0.8) #define widthMainLine toPixel(1.2)
#define widthHairLine widthMainLine/3 #define widthHairLine widthMainLine/3
namespace Scene{ namespace Scene{

View File

@ -22,6 +22,8 @@
#include "vdrawtool.h" #include "vdrawtool.h"
#include <QDebug> #include <QDebug>
qreal VDrawTool::factor = 1;
VDrawTool::VDrawTool(VDomDocument *doc, VContainer *data, qint64 id, QObject *parent) : VDrawTool::VDrawTool(VDomDocument *doc, VContainer *data, qint64 id, QObject *parent) :
VAbstractTool(doc, data, id, parent), ignoreContextMenuEvent(false), VAbstractTool(doc, data, id, parent), ignoreContextMenuEvent(false),
nameActivDraw(doc->GetNameActivDraw()){ nameActivDraw(doc->GetNameActivDraw()){
@ -78,6 +80,12 @@ void VDrawTool::ChangedNameDraw(const QString oldName, const QString newName){
} }
} }
void VDrawTool::SetFactor(qreal factor){
if(factor <= 2 && factor >= 0.5){
this->factor = factor;
}
}
void VDrawTool::AddToCalculation(const QDomElement &domElement){ void VDrawTool::AddToCalculation(const QDomElement &domElement){
QDomElement calcElement; QDomElement calcElement;
bool ok = doc->GetActivCalculationElement(calcElement); bool ok = doc->GetActivCalculationElement(calcElement);

View File

@ -38,11 +38,13 @@ public slots:
virtual void ChangedActivDraw(const QString newName); virtual void ChangedActivDraw(const QString newName);
void ChangedNameDraw(const QString oldName, const QString newName); void ChangedNameDraw(const QString oldName, const QString newName);
virtual void FullUpdateFromGui(int result)=0; virtual void FullUpdateFromGui(int result)=0;
virtual void SetFactor(qreal factor);
signals: signals:
void RemoveTool(QGraphicsItem *tool); void RemoveTool(QGraphicsItem *tool);
protected: protected:
bool ignoreContextMenuEvent; bool ignoreContextMenuEvent;
QString nameActivDraw; QString nameActivDraw;
static qreal factor;
void AddToCalculation(const QDomElement &domElement); void AddToCalculation(const QDomElement &domElement);
template <typename Dialog, typename Tool> template <typename Dialog, typename Tool>
void ContextMenu(QSharedPointer<Dialog> &dialog, Tool *tool, QGraphicsSceneContextMenuEvent *event, void ContextMenu(QSharedPointer<Dialog> &dialog, Tool *tool, QGraphicsSceneContextMenuEvent *event,

View File

@ -63,6 +63,11 @@ void VToolAlongLine::FullUpdateFromGui(int result){
dialogAlongLine.clear(); dialogAlongLine.clear();
} }
void VToolAlongLine::SetFactor(qreal factor){
VDrawTool::SetFactor(factor);
RefreshGeometry();
}
void VToolAlongLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){ void VToolAlongLine::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
ContextMenu(dialogAlongLine, this, event); ContextMenu(dialogAlongLine, this, event);
} }
@ -145,6 +150,7 @@ void VToolAlongLine::Create(const qint64 _id, const QString &pointName, const QS
scene->addItem(point); scene->addItem(point);
connect(point, &VToolAlongLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(point, &VToolAlongLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(point, &VToolAlongLine::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); connect(point, &VToolAlongLine::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolAlongLine::SetFactor);
doc->AddTool(id, point); doc->AddTool(id, point);
doc->IncrementReferens(firstPointId); doc->IncrementReferens(firstPointId);
doc->IncrementReferens(secondPointId); doc->IncrementReferens(secondPointId);

View File

@ -42,6 +42,7 @@ public:
public slots: public slots:
virtual void FullUpdateFromFile(); virtual void FullUpdateFromFile();
virtual void FullUpdateFromGui(int result); virtual void FullUpdateFromGui(int result);
virtual void SetFactor(qreal factor);
protected: protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile(); virtual void AddToFile();

View File

@ -30,7 +30,7 @@ VToolArc::VToolArc(VDomDocument *doc, VContainer *data, qint64 id, Tool::Sources
path.addPath(arc.GetPath()); path.addPath(arc.GetPath());
path.setFillRule( Qt::WindingFill ); path.setFillRule( Qt::WindingFill );
this->setPath(path); this->setPath(path);
this->setPen(QPen(Qt::black, widthHairLine)); this->setPen(QPen(Qt::black, widthHairLine/factor));
this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setAcceptHoverEvents(true); this->setAcceptHoverEvents(true);
@ -126,14 +126,16 @@ void VToolArc::FullUpdateFromGui(int result){
void VToolArc::ChangedActivDraw(const QString newName){ void VToolArc::ChangedActivDraw(const QString newName){
if(nameActivDraw == newName){ if(nameActivDraw == newName){
this->setPen(QPen(Qt::black, widthHairLine)); this->setPen(QPen(Qt::black, widthHairLine/factor));
this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setAcceptHoverEvents(true); this->setAcceptHoverEvents(true);
currentColor = Qt::black;
VDrawTool::ChangedActivDraw(newName); VDrawTool::ChangedActivDraw(newName);
} else { } else {
this->setPen(QPen(Qt::gray, widthHairLine)); this->setPen(QPen(Qt::gray, widthHairLine/factor));
this->setFlag(QGraphicsItem::ItemIsSelectable, false); this->setFlag(QGraphicsItem::ItemIsSelectable, false);
this->setAcceptHoverEvents (false); this->setAcceptHoverEvents (false);
currentColor = Qt::gray;
VDrawTool::ChangedActivDraw(newName); VDrawTool::ChangedActivDraw(newName);
} }
} }
@ -141,15 +143,20 @@ void VToolArc::ChangedActivDraw(const QString newName){
void VToolArc::ShowTool(qint64 id, Qt::GlobalColor color, bool enable){ void VToolArc::ShowTool(qint64 id, Qt::GlobalColor color, bool enable){
if(id == this->id){ if(id == this->id){
if(enable == false){ if(enable == false){
this->setPen(QPen(baseColor, widthHairLine)); this->setPen(QPen(baseColor, widthHairLine/factor));
currentColor = baseColor; currentColor = baseColor;
} else { } else {
this->setPen(QPen(color, widthHairLine)); this->setPen(QPen(color, widthHairLine/factor));
currentColor = color; currentColor = color;
} }
} }
} }
void VToolArc::SetFactor(qreal factor){
VDrawTool::SetFactor(factor);
RefreshGeometry();
}
void VToolArc::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){ void VToolArc::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
ContextMenu(dialogArc, this, event); ContextMenu(dialogArc, this, event);
} }
@ -177,12 +184,12 @@ void VToolArc::mouseReleaseEvent(QGraphicsSceneMouseEvent *event){
void VToolArc::hoverMoveEvent(QGraphicsSceneHoverEvent *event){ void VToolArc::hoverMoveEvent(QGraphicsSceneHoverEvent *event){
Q_UNUSED(event); Q_UNUSED(event);
this->setPen(QPen(currentColor, widthMainLine)); this->setPen(QPen(currentColor, widthMainLine/factor));
} }
void VToolArc::hoverLeaveEvent(QGraphicsSceneHoverEvent *event){ void VToolArc::hoverLeaveEvent(QGraphicsSceneHoverEvent *event){
Q_UNUSED(event); Q_UNUSED(event);
this->setPen(QPen(currentColor, widthHairLine)); this->setPen(QPen(currentColor, widthHairLine/factor));
} }
void VToolArc::RemoveReferens(){ void VToolArc::RemoveReferens(){
@ -191,6 +198,7 @@ void VToolArc::RemoveReferens(){
} }
void VToolArc::RefreshGeometry(){ void VToolArc::RefreshGeometry(){
this->setPen(QPen(currentColor, widthHairLine/factor));
VArc arc = VAbstractTool::data.GetArc(id); VArc arc = VAbstractTool::data.GetArc(id);
QPainterPath path; QPainterPath path;
path.addPath(arc.GetPath()); path.addPath(arc.GetPath());

View File

@ -30,21 +30,20 @@
class VToolArc :public VDrawTool, public QGraphicsPathItem{ class VToolArc :public VDrawTool, public QGraphicsPathItem{
Q_OBJECT Q_OBJECT
public: public:
VToolArc(VDomDocument *doc, VContainer *data, qint64 id, VToolArc(VDomDocument *doc, VContainer *data, qint64 id, Tool::Sources typeCreation,
Tool::Sources typeCreation, QGraphicsItem * parent = 0); QGraphicsItem * parent = 0);
virtual void setDialog(); virtual void setDialog();
static void Create(QSharedPointer<DialogArc> &dialog, VMainGraphicsScene *scene, static void Create(QSharedPointer<DialogArc> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
VDomDocument *doc,
VContainer *data); VContainer *data);
static void Create(const qint64 _id, const qint64 &center, const QString &radius, static void Create(const qint64 _id, const qint64 &center, const QString &radius, const QString &f1,
const QString &f1, const QString &f2, VMainGraphicsScene *scene, const QString &f2, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
VDomDocument *doc, VContainer *data, const Document::Documents &parse, const Document::Documents &parse, Tool::Sources typeCreation);
Tool::Sources typeCreation);
public slots: public slots:
virtual void FullUpdateFromFile(); virtual void FullUpdateFromFile();
virtual void FullUpdateFromGui(int result); virtual void FullUpdateFromGui(int result);
virtual void ChangedActivDraw(const QString newName); virtual void ChangedActivDraw(const QString newName);
virtual void ShowTool(qint64 id, Qt::GlobalColor color, bool enable); virtual void ShowTool(qint64 id, Qt::GlobalColor color, bool enable);
virtual void SetFactor(qreal factor);
protected: protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile(); virtual void AddToFile();

View File

@ -109,6 +109,7 @@ void VToolBisector::Create(const qint64 _id, const QString &formula, const qint6
scene->addItem(point); scene->addItem(point);
connect(point, &VToolBisector::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(point, &VToolBisector::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(point, &VToolBisector::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); connect(point, &VToolBisector::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolBisector::SetFactor);
doc->AddTool(id, point); doc->AddTool(id, point);
doc->IncrementReferens(firstPointId); doc->IncrementReferens(firstPointId);
doc->IncrementReferens(secondPointId); doc->IncrementReferens(secondPointId);
@ -145,6 +146,11 @@ void VToolBisector::FullUpdateFromGui(int result){
dialogBisector.clear(); dialogBisector.clear();
} }
void VToolBisector::SetFactor(qreal factor){
VDrawTool::SetFactor(factor);
RefreshGeometry();
}
void VToolBisector::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){ void VToolBisector::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
ContextMenu(dialogBisector, this, event); ContextMenu(dialogBisector, this, event);
} }

View File

@ -44,6 +44,7 @@ public:
public slots: public slots:
virtual void FullUpdateFromFile(); virtual void FullUpdateFromFile();
virtual void FullUpdateFromGui(int result); virtual void FullUpdateFromGui(int result);
virtual void SetFactor(qreal factor);
protected: protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile(); virtual void AddToFile();

View File

@ -69,7 +69,7 @@ void VToolEndLine::Create(const qint64 _id, const QString &pointName, const QStr
QString errorMsg; QString errorMsg;
qreal result = cal.eval(formula, &errorMsg); qreal result = cal.eval(formula, &errorMsg);
if(errorMsg.isEmpty()){ if(errorMsg.isEmpty()){
line.setLength(result*PrintDPI/25.4); line.setLength(toPixel(result));
line.setAngle(angle); line.setAngle(angle);
qint64 id = _id; qint64 id = _id;
if(typeCreation == Tool::FromGui){ if(typeCreation == Tool::FromGui){
@ -89,6 +89,7 @@ void VToolEndLine::Create(const qint64 _id, const QString &pointName, const QStr
scene->addItem(point); scene->addItem(point);
connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(point, &VToolPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(point, &VToolPoint::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); connect(point, &VToolPoint::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPoint::SetFactor);
doc->AddTool(id, point); doc->AddTool(id, point);
doc->IncrementReferens(basePointId); doc->IncrementReferens(basePointId);
} }

View File

@ -33,6 +33,7 @@ VToolLine::VToolLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firs
this->setFlag(QGraphicsItem::ItemStacksBehindParent, true); this->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setAcceptHoverEvents(true); this->setAcceptHoverEvents(true);
this->setPen(QPen(Qt::black, widthHairLine/factor));
if(typeCreation == Tool::FromGui){ if(typeCreation == Tool::FromGui){
AddToFile(); AddToFile();
@ -74,6 +75,7 @@ void VToolLine::Create(const qint64 &_id, const qint64 &firstPoint, const qint64
scene->addItem(line); scene->addItem(line);
connect(line, &VToolLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(line, &VToolLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(line, &VToolLine::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); connect(line, &VToolLine::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
connect(scene, &VMainGraphicsScene::NewFactor, line, &VToolLine::SetFactor);
doc->AddTool(id, line); doc->AddTool(id, line);
doc->IncrementReferens(firstPoint); doc->IncrementReferens(firstPoint);
doc->IncrementReferens(secondPoint); doc->IncrementReferens(secondPoint);
@ -81,14 +83,7 @@ void VToolLine::Create(const qint64 &_id, const qint64 &firstPoint, const qint64
} }
void VToolLine::FullUpdateFromFile(){ void VToolLine::FullUpdateFromFile(){
QDomElement domElement = doc->elementById(QString().setNum(id)); RefreshGeometry();
if(domElement.isElement()){
firstPoint = domElement.attribute("firstPoint", "").toLongLong();
secondPoint = domElement.attribute("secondPoint", "").toLongLong();
}
VPointF first = VAbstractTool::data.GetPoint(firstPoint);
VPointF second = VAbstractTool::data.GetPoint(secondPoint);
this->setLine(QLineF(first.toQPointF(), second.toQPointF()));
} }
void VToolLine::FullUpdateFromGui(int result){ void VToolLine::FullUpdateFromGui(int result){
@ -106,23 +101,30 @@ void VToolLine::FullUpdateFromGui(int result){
void VToolLine::ShowTool(qint64 id, Qt::GlobalColor color, bool enable){ void VToolLine::ShowTool(qint64 id, Qt::GlobalColor color, bool enable){
if(id == this->id){ if(id == this->id){
if(enable == false){ if(enable == false){
this->setPen(QPen(baseColor, widthHairLine)); this->setPen(QPen(baseColor, widthHairLine/factor));
currentColor = baseColor; currentColor = baseColor;
} else { } else {
this->setPen(QPen(color, widthHairLine)); this->setPen(QPen(color, widthHairLine/factor));
currentColor = color; currentColor = color;
} }
} }
} }
void VToolLine::SetFactor(qreal factor){
VDrawTool::SetFactor(factor);
RefreshGeometry();
}
void VToolLine::ChangedActivDraw(const QString newName){ void VToolLine::ChangedActivDraw(const QString newName){
if(nameActivDraw == newName){ if(nameActivDraw == newName){
this->setPen(QPen(Qt::black, widthHairLine)); this->setPen(QPen(Qt::black, widthHairLine/factor));
this->setAcceptHoverEvents (true); this->setAcceptHoverEvents (true);
currentColor = Qt::black;
VDrawTool::ChangedActivDraw(newName); VDrawTool::ChangedActivDraw(newName);
} else { } else {
this->setPen(QPen(Qt::gray, widthHairLine)); this->setPen(QPen(Qt::gray, widthHairLine/factor));
this->setAcceptHoverEvents (false); this->setAcceptHoverEvents (false);
currentColor = Qt::gray;
VDrawTool::ChangedActivDraw(newName); VDrawTool::ChangedActivDraw(newName);
} }
} }
@ -143,12 +145,12 @@ void VToolLine::AddToFile(){
void VToolLine::hoverMoveEvent(QGraphicsSceneHoverEvent *event){ void VToolLine::hoverMoveEvent(QGraphicsSceneHoverEvent *event){
Q_UNUSED(event); Q_UNUSED(event);
this->setPen(QPen(currentColor, widthMainLine)); this->setPen(QPen(currentColor, widthMainLine/factor));
} }
void VToolLine::hoverLeaveEvent(QGraphicsSceneHoverEvent *event){ void VToolLine::hoverLeaveEvent(QGraphicsSceneHoverEvent *event){
Q_UNUSED(event); Q_UNUSED(event);
this->setPen(QPen(currentColor, widthHairLine)); this->setPen(QPen(currentColor, widthHairLine/factor));
} }
void VToolLine::RemoveReferens(){ void VToolLine::RemoveReferens(){
@ -156,3 +158,15 @@ void VToolLine::RemoveReferens(){
doc->DecrementReferens(secondPoint); doc->DecrementReferens(secondPoint);
} }
void VToolLine::RefreshGeometry(){
QDomElement domElement = doc->elementById(QString().setNum(id));
if(domElement.isElement()){
firstPoint = domElement.attribute("firstPoint", "").toLongLong();
secondPoint = domElement.attribute("secondPoint", "").toLongLong();
}
VPointF first = VAbstractTool::data.GetPoint(firstPoint);
VPointF second = VAbstractTool::data.GetPoint(secondPoint);
this->setLine(QLineF(first.toQPointF(), second.toQPointF()));
this->setPen(QPen(currentColor, widthHairLine/factor));
}

View File

@ -32,8 +32,8 @@ public:
VToolLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firstPoint, VToolLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firstPoint,
qint64 secondPoint, Tool::Sources typeCreation, QGraphicsItem * parent = 0); qint64 secondPoint, Tool::Sources typeCreation, QGraphicsItem * parent = 0);
virtual void setDialog(); virtual void setDialog();
static void Create(QSharedPointer<DialogLine> &dialog, VMainGraphicsScene *scene, VDomDocument *doc, static void Create(QSharedPointer<DialogLine> &dialog, VMainGraphicsScene *scene,
VContainer *data); VDomDocument *doc, VContainer *data);
static void Create(const qint64 &_id, const qint64 &firstPoint, const qint64 &secondPoint, static void Create(const qint64 &_id, const qint64 &firstPoint, const qint64 &secondPoint,
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
const Document::Documents &parse, Tool::Sources typeCreation); const Document::Documents &parse, Tool::Sources typeCreation);
@ -42,6 +42,7 @@ public slots:
virtual void ChangedActivDraw(const QString newName); virtual void ChangedActivDraw(const QString newName);
virtual void FullUpdateFromGui(int result); virtual void FullUpdateFromGui(int result);
virtual void ShowTool(qint64 id, Qt::GlobalColor color, bool enable); virtual void ShowTool(qint64 id, Qt::GlobalColor color, bool enable);
virtual void SetFactor(qreal factor);
protected: protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile(); virtual void AddToFile();
@ -52,6 +53,7 @@ private:
qint64 firstPoint; qint64 firstPoint;
qint64 secondPoint; qint64 secondPoint;
QSharedPointer<DialogLine> dialogLine; QSharedPointer<DialogLine> dialogLine;
void RefreshGeometry();
}; };
#endif // VTOOLLINE_H #endif // VTOOLLINE_H

View File

@ -24,7 +24,8 @@
VToolLineIntersect::VToolLineIntersect(VDomDocument *doc, VContainer *data, const qint64 &id, VToolLineIntersect::VToolLineIntersect(VDomDocument *doc, VContainer *data, const qint64 &id,
const qint64 &p1Line1, const qint64 &p2Line1, const qint64 &p1Line2, const qint64 &p1Line1, const qint64 &p2Line1, const qint64 &p1Line2,
const qint64 &p2Line2, Tool::Sources typeCreation, QGraphicsItem *parent): const qint64 &p2Line2, Tool::Sources typeCreation,
QGraphicsItem *parent):
VToolPoint(doc, data, id, parent), p1Line1(p1Line1), p2Line1(p2Line1), p1Line2(p1Line2), VToolPoint(doc, data, id, parent), p1Line1(p1Line1), p2Line1(p2Line1), p1Line2(p1Line2),
p2Line2(p2Line2), dialogLineIntersect(QSharedPointer<DialogLineIntersect>()){ p2Line2(p2Line2), dialogLineIntersect(QSharedPointer<DialogLineIntersect>()){
if(typeCreation == Tool::FromGui){ if(typeCreation == Tool::FromGui){
@ -57,8 +58,9 @@ void VToolLineIntersect::Create(QSharedPointer<DialogLineIntersect> &dialog, VMa
void VToolLineIntersect::Create(const qint64 _id, const qint64 &p1Line1Id, const qint64 &p2Line1Id, void VToolLineIntersect::Create(const qint64 _id, const qint64 &p1Line1Id, const qint64 &p2Line1Id,
const qint64 &p1Line2Id, const qint64 &p2Line2Id, const QString &pointName, const qint64 &p1Line2Id, const qint64 &p2Line2Id, const QString &pointName,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc, const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
VContainer *data, const Document::Documents &parse, Tool::Sources typeCreation){ VDomDocument *doc, VContainer *data, const Document::Documents &parse,
Tool::Sources typeCreation){
VPointF p1Line1 = data->GetPoint(p1Line1Id); VPointF p1Line1 = data->GetPoint(p1Line1Id);
VPointF p2Line1 = data->GetPoint(p2Line1Id); VPointF p2Line1 = data->GetPoint(p2Line1Id);
VPointF p1Line2 = data->GetPoint(p1Line2Id); VPointF p1Line2 = data->GetPoint(p1Line2Id);
@ -94,6 +96,7 @@ void VToolLineIntersect::Create(const qint64 _id, const qint64 &p1Line1Id, const
scene->addItem(point); scene->addItem(point);
connect(point, &VToolLineIntersect::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(point, &VToolLineIntersect::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(point, &VToolLineIntersect::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); connect(point, &VToolLineIntersect::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolLineIntersect::SetFactor);
doc->AddTool(id, point); doc->AddTool(id, point);
doc->IncrementReferens(p1Line1Id); doc->IncrementReferens(p1Line1Id);
doc->IncrementReferens(p2Line1Id); doc->IncrementReferens(p2Line1Id);
@ -129,6 +132,11 @@ void VToolLineIntersect::FullUpdateFromGui(int result){
dialogLineIntersect.clear(); dialogLineIntersect.clear();
} }
void VToolLineIntersect::SetFactor(qreal factor){
VDrawTool::SetFactor(factor);
RefreshPointGeometry(VAbstractTool::data.GetPoint(id));
}
void VToolLineIntersect::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){ void VToolLineIntersect::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
ContextMenu(dialogLineIntersect, this, event); ContextMenu(dialogLineIntersect, this, event);
} }
@ -140,8 +148,8 @@ void VToolLineIntersect::AddToFile(){
AddAttribute(domElement, "id", id); AddAttribute(domElement, "id", id);
AddAttribute(domElement, "type", "lineIntersect"); AddAttribute(domElement, "type", "lineIntersect");
AddAttribute(domElement, "name", point.name()); AddAttribute(domElement, "name", point.name());
AddAttribute(domElement, "mx", point.mx()/PrintDPI*25.4); AddAttribute(domElement, "mx", toMM(point.mx()));
AddAttribute(domElement, "my", point.my()/PrintDPI*25.4); AddAttribute(domElement, "my", toMM(point.my()));
AddAttribute(domElement, "p1Line1", p1Line1); AddAttribute(domElement, "p1Line1", p1Line1);
AddAttribute(domElement, "p2Line1", p2Line1); AddAttribute(domElement, "p2Line1", p2Line1);

View File

@ -28,25 +28,21 @@
class VToolLineIntersect:public VToolPoint{ class VToolLineIntersect:public VToolPoint{
Q_OBJECT Q_OBJECT
public: public:
VToolLineIntersect(VDomDocument *doc, VContainer *data, VToolLineIntersect(VDomDocument *doc, VContainer *data, const qint64 &id,
const qint64 &id, const qint64 &p1Line1, const qint64 &p2Line1, const qint64 &p1Line2,
const qint64 &p1Line1,
const qint64 &p2Line1, const qint64 &p1Line2,
const qint64 &p2Line2, Tool::Sources typeCreation, const qint64 &p2Line2, Tool::Sources typeCreation,
QGraphicsItem * parent = 0); QGraphicsItem * parent = 0);
virtual void setDialog(); virtual void setDialog();
static void Create(QSharedPointer<DialogLineIntersect> &dialog, static void Create(QSharedPointer<DialogLineIntersect> &dialog, VMainGraphicsScene *scene,
VMainGraphicsScene *scene, VDomDocument *doc, VDomDocument *doc, VContainer *data);
VContainer *data); static void Create(const qint64 _id, const qint64 &p1Line1Id, const qint64 &p2Line1Id,
static void Create(const qint64 _id, const qint64 &p1Line1Id, const qint64 &p1Line2Id, const qint64 &p2Line2Id, const QString &pointName,
const qint64 &p2Line1Id, const qint64 &p1Line2Id, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc,
const qint64 &p2Line2Id, const QString &pointName, VContainer *data, const Document::Documents &parse, Tool::Sources typeCreation);
const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
VDomDocument *doc, VContainer *data,
const Document::Documents &parse, Tool::Sources typeCreation);
public slots: public slots:
virtual void FullUpdateFromFile(); virtual void FullUpdateFromFile();
virtual void FullUpdateFromGui(int result); virtual void FullUpdateFromGui(int result);
virtual void SetFactor(qreal factor);
protected: protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile(); virtual void AddToFile();

View File

@ -30,7 +30,7 @@ VToolLinePoint::VToolLinePoint(VDomDocument *doc, VContainer *data, const qint64
QPointF point1 = data->GetPoint(basePointId).toQPointF(); QPointF point1 = data->GetPoint(basePointId).toQPointF();
QPointF point2 = data->GetPoint(id).toQPointF(); QPointF point2 = data->GetPoint(id).toQPointF();
mainLine = new QGraphicsLineItem(QLineF(point1 - point2, QPointF()), this); mainLine = new QGraphicsLineItem(QLineF(point1 - point2, QPointF()), this);
mainLine->setPen(QPen(Qt::black, widthHairLine)); mainLine->setPen(QPen(Qt::black, widthHairLine/factor));
mainLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true); mainLine->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
if(typeLine == "none"){ if(typeLine == "none"){
mainLine->setVisible(false); mainLine->setVisible(false);
@ -41,15 +41,18 @@ VToolLinePoint::VToolLinePoint(VDomDocument *doc, VContainer *data, const qint64
void VToolLinePoint::ChangedActivDraw(const QString newName){ void VToolLinePoint::ChangedActivDraw(const QString newName){
if(nameActivDraw == newName){ if(nameActivDraw == newName){
mainLine->setPen(QPen(Qt::black, widthHairLine)); mainLine->setPen(QPen(Qt::black, widthHairLine/factor));
currentColor = Qt::black;
VToolPoint::ChangedActivDraw(newName); VToolPoint::ChangedActivDraw(newName);
} else { } else {
mainLine->setPen(QPen(Qt::gray, widthHairLine)); mainLine->setPen(QPen(Qt::gray, widthHairLine/factor));
currentColor = Qt::gray;
VToolPoint::ChangedActivDraw(newName); VToolPoint::ChangedActivDraw(newName);
} }
} }
void VToolLinePoint::RefreshGeometry(){ void VToolLinePoint::RefreshGeometry(){
mainLine->setPen(QPen(currentColor, widthHairLine/factor));
VToolPoint::RefreshPointGeometry(VDrawTool::data.GetPoint(id)); VToolPoint::RefreshPointGeometry(VDrawTool::data.GetPoint(id));
QPointF point = VDrawTool::data.GetPoint(id).toQPointF(); QPointF point = VDrawTool::data.GetPoint(id).toQPointF();
QPointF basePoint = VDrawTool::data.GetPoint(basePointId).toQPointF(); QPointF basePoint = VDrawTool::data.GetPoint(basePointId).toQPointF();
@ -64,3 +67,8 @@ void VToolLinePoint::RefreshGeometry(){
void VToolLinePoint::RemoveReferens(){ void VToolLinePoint::RemoveReferens(){
doc->DecrementReferens(basePointId); doc->DecrementReferens(basePointId);
} }
void VToolLinePoint::SetFactor(qreal factor){
VDrawTool::SetFactor(factor);
RefreshGeometry();
}

View File

@ -32,6 +32,7 @@ public:
const qint64 &basePointId, const qreal &angle, QGraphicsItem * parent = 0); const qint64 &basePointId, const qreal &angle, QGraphicsItem * parent = 0);
public slots: public slots:
virtual void ChangedActivDraw(const QString newName); virtual void ChangedActivDraw(const QString newName);
virtual void SetFactor(qreal factor);
protected: protected:
QString typeLine; QString typeLine;
QString formula; QString formula;

View File

@ -21,8 +21,7 @@
#include "vtoolnormal.h" #include "vtoolnormal.h"
VToolNormal::VToolNormal(VDomDocument *doc, VContainer *data, const qint64 &id, VToolNormal::VToolNormal(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine,
const QString &typeLine,
const QString &formula, const qreal &angle, const qint64 &firstPointId, const QString &formula, const qreal &angle, const qint64 &firstPointId,
const qint64 &secondPointId, Tool::Sources typeCreation, QGraphicsItem *parent): const qint64 &secondPointId, Tool::Sources typeCreation, QGraphicsItem *parent):
VToolLinePoint(doc, data, id, typeLine, formula, firstPointId, angle, parent), VToolLinePoint(doc, data, id, typeLine, formula, firstPointId, angle, parent),
@ -62,7 +61,8 @@ void VToolNormal::Create(QSharedPointer<DialogNormal> &dialog, VMainGraphicsScen
void VToolNormal::Create(const qint64 _id, const QString &formula, const qint64 &firstPointId, void VToolNormal::Create(const qint64 _id, const QString &formula, const qint64 &firstPointId,
const qint64 &secondPointId, const QString typeLine, const QString pointName, const qint64 &secondPointId, const QString typeLine, const QString pointName,
const qreal angle, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, const qreal angle, const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
VDomDocument *doc, VContainer *data, const Document::Documents &parse, Tool::Sources typeCreation){ VDomDocument *doc, VContainer *data, const Document::Documents &parse,
Tool::Sources typeCreation){
VPointF firstPoint = data->GetPoint(firstPointId); VPointF firstPoint = data->GetPoint(firstPointId);
VPointF secondPoint = data->GetPoint(secondPointId); VPointF secondPoint = data->GetPoint(secondPointId);
Calculator cal(data); Calculator cal(data);
@ -70,7 +70,7 @@ void VToolNormal::Create(const qint64 _id, const QString &formula, const qint64
qreal result = cal.eval(formula, &errorMsg); qreal result = cal.eval(formula, &errorMsg);
if(errorMsg.isEmpty()){ if(errorMsg.isEmpty()){
QPointF fPoint = VToolNormal::FindPoint(firstPoint.toQPointF(), secondPoint.toQPointF(), QPointF fPoint = VToolNormal::FindPoint(firstPoint.toQPointF(), secondPoint.toQPointF(),
result*PrintDPI/25.4, angle); toPixel(result), angle);
qint64 id = _id; qint64 id = _id;
if(typeCreation == Tool::FromGui){ if(typeCreation == Tool::FromGui){
id = data->AddPoint(VPointF(fPoint.x(), fPoint.y(), pointName, mx, my)); id = data->AddPoint(VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
@ -89,6 +89,7 @@ void VToolNormal::Create(const qint64 _id, const QString &formula, const qint64
scene->addItem(point); scene->addItem(point);
connect(point, &VToolNormal::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(point, &VToolNormal::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(point, &VToolNormal::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); connect(point, &VToolNormal::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolNormal::SetFactor);
doc->AddTool(id, point); doc->AddTool(id, point);
doc->IncrementReferens(firstPointId); doc->IncrementReferens(firstPointId);
doc->IncrementReferens(secondPointId); doc->IncrementReferens(secondPointId);
@ -112,7 +113,7 @@ void VToolNormal::FullUpdateFromFile(){
formula = domElement.attribute("length", ""); formula = domElement.attribute("length", "");
basePointId = domElement.attribute("firstPoint", "").toLongLong(); basePointId = domElement.attribute("firstPoint", "").toLongLong();
secondPointId = domElement.attribute("secondPoint", "").toLongLong(); secondPointId = domElement.attribute("secondPoint", "").toLongLong();
angle = domElement.attribute("angle", "").toInt(); angle = domElement.attribute("angle", "").toDouble();
} }
RefreshGeometry(); RefreshGeometry();
} }
@ -133,6 +134,11 @@ void VToolNormal::FullUpdateFromGui(int result){
dialogNormal.clear(); dialogNormal.clear();
} }
void VToolNormal::SetFactor(qreal factor){
VDrawTool::SetFactor(factor);
RefreshGeometry();
}
void VToolNormal::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){ void VToolNormal::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
ContextMenu(dialogNormal, this, event); ContextMenu(dialogNormal, this, event);
} }
@ -144,8 +150,8 @@ void VToolNormal::AddToFile(){
AddAttribute(domElement, "id", id); AddAttribute(domElement, "id", id);
AddAttribute(domElement, "type", "normal"); AddAttribute(domElement, "type", "normal");
AddAttribute(domElement, "name", point.name()); AddAttribute(domElement, "name", point.name());
AddAttribute(domElement, "mx", point.mx()/PrintDPI*25.4); AddAttribute(domElement, "mx", toMM(point.mx()));
AddAttribute(domElement, "my", point.my()/PrintDPI*25.4); AddAttribute(domElement, "my", toMM(point.my()));
AddAttribute(domElement, "typeLine", typeLine); AddAttribute(domElement, "typeLine", typeLine);
AddAttribute(domElement, "length", formula); AddAttribute(domElement, "length", formula);

View File

@ -29,9 +29,8 @@ class VToolNormal : public VToolLinePoint
{ {
Q_OBJECT Q_OBJECT
public: public:
VToolNormal(VDomDocument *doc, VContainer *data, const qint64 &id, VToolNormal(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine,
const QString &typeLine, const QString &formula, const QString &formula, const qreal &angle, const qint64 &firstPointId,
const qreal &angle, const qint64 &firstPointId,
const qint64 &secondPointId, Tool::Sources typeCreation, const qint64 &secondPointId, Tool::Sources typeCreation,
QGraphicsItem * parent = 0); QGraphicsItem * parent = 0);
virtual void setDialog(); virtual void setDialog();
@ -40,12 +39,14 @@ public:
static void Create(const qint64 _id, const QString &formula, const qint64 &firstPointId, static void Create(const qint64 _id, const QString &formula, const qint64 &firstPointId,
const qint64 &secondPointId, const QString typeLine, const QString pointName, const qint64 &secondPointId, const QString typeLine, const QString pointName,
const qreal angle, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, const qreal angle, const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
VDomDocument *doc, VContainer *data, const Document::Documents &parse, Tool::Sources typeCreation); VDomDocument *doc, VContainer *data, const Document::Documents &parse,
static QPointF FindPoint(const QPointF &firstPoint, const QPointF &secondPoint, Tool::Sources typeCreation);
const qreal &length, const qreal &angle = 0); static QPointF FindPoint(const QPointF &firstPoint, const QPointF &secondPoint, const qreal &length,
const qreal &angle = 0);
public slots: public slots:
virtual void FullUpdateFromFile(); virtual void FullUpdateFromFile();
virtual void FullUpdateFromGui(int result); virtual void FullUpdateFromGui(int result);
virtual void SetFactor(qreal factor);
protected: protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile(); virtual void AddToFile();

View File

@ -28,12 +28,11 @@
VToolPoint::VToolPoint(VDomDocument *doc, VContainer *data, qint64 id, VToolPoint::VToolPoint(VDomDocument *doc, VContainer *data, qint64 id,
QGraphicsItem *parent):VDrawTool(doc, data, id), QGraphicsItem *parent):VDrawTool(doc, data, id),
QGraphicsEllipseItem(parent), radius(toPixel(1.5)), namePoint(0), lineName(0){ QGraphicsEllipseItem(parent), radius(toPixel(2)), namePoint(0), lineName(0){
namePoint = new VGraphicsSimpleTextItem(this); namePoint = new VGraphicsSimpleTextItem(this);
lineName = new QGraphicsLineItem(this); lineName = new QGraphicsLineItem(this);
connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this, connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this,
&VToolPoint::NameChangePosition); &VToolPoint::NameChangePosition);
this->setPen(QPen(Qt::black, widthHairLine));
this->setBrush(QBrush(Qt::NoBrush)); this->setBrush(QBrush(Qt::NoBrush));
this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setAcceptHoverEvents(true); this->setAcceptHoverEvents(true);
@ -61,7 +60,7 @@ void VToolPoint::UpdateNamePosition(qreal mx, qreal my){
void VToolPoint::ChangedActivDraw(const QString newName){ void VToolPoint::ChangedActivDraw(const QString newName){
if(nameActivDraw == newName){ if(nameActivDraw == newName){
this->setPen(QPen(Qt::black, widthHairLine)); this->setPen(QPen(Qt::black, widthHairLine/factor));
this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setAcceptHoverEvents(true); this->setAcceptHoverEvents(true);
namePoint->setFlag(QGraphicsItem::ItemIsMovable, true); namePoint->setFlag(QGraphicsItem::ItemIsMovable, true);
@ -69,10 +68,11 @@ void VToolPoint::ChangedActivDraw(const QString newName){
namePoint->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); namePoint->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
namePoint->setBrush(QBrush(Qt::black)); namePoint->setBrush(QBrush(Qt::black));
namePoint->setAcceptHoverEvents(true); namePoint->setAcceptHoverEvents(true);
lineName->setPen(QPen(Qt::black, widthHairLine)); lineName->setPen(QPen(Qt::black, widthHairLine/factor));
currentColor = Qt::black;
VDrawTool::ChangedActivDraw(newName); VDrawTool::ChangedActivDraw(newName);
} else { } else {
this->setPen(QPen(Qt::gray, widthHairLine)); this->setPen(QPen(Qt::gray, widthHairLine/factor));
this->setFlag(QGraphicsItem::ItemIsSelectable, false); this->setFlag(QGraphicsItem::ItemIsSelectable, false);
this->setAcceptHoverEvents (false); this->setAcceptHoverEvents (false);
namePoint->setFlag(QGraphicsItem::ItemIsMovable, false); namePoint->setFlag(QGraphicsItem::ItemIsMovable, false);
@ -80,7 +80,8 @@ void VToolPoint::ChangedActivDraw(const QString newName){
namePoint->setFlag(QGraphicsItem::ItemSendsGeometryChanges, false); namePoint->setFlag(QGraphicsItem::ItemSendsGeometryChanges, false);
namePoint->setBrush(QBrush(Qt::gray)); namePoint->setBrush(QBrush(Qt::gray));
namePoint->setAcceptHoverEvents(false); namePoint->setAcceptHoverEvents(false);
lineName->setPen(QPen(Qt::gray, widthHairLine)); lineName->setPen(QPen(Qt::gray, widthHairLine/factor));
currentColor = Qt::gray;
VDrawTool::ChangedActivDraw(newName); VDrawTool::ChangedActivDraw(newName);
} }
} }
@ -88,15 +89,20 @@ void VToolPoint::ChangedActivDraw(const QString newName){
void VToolPoint::ShowTool(qint64 id, Qt::GlobalColor color, bool enable){ void VToolPoint::ShowTool(qint64 id, Qt::GlobalColor color, bool enable){
if(id == this->id){ if(id == this->id){
if(enable == false){ if(enable == false){
this->setPen(QPen(baseColor, widthHairLine)); this->setPen(QPen(baseColor, widthHairLine/factor));
currentColor = baseColor; currentColor = baseColor;
} else { } else {
this->setPen(QPen(color, widthHairLine)); this->setPen(QPen(color, widthHairLine/factor));
currentColor = color; currentColor = color;
} }
} }
} }
void VToolPoint::SetFactor(qreal factor){
VDrawTool::SetFactor(factor);
RefreshPointGeometry(VAbstractTool::data.GetPoint(id));
}
void VToolPoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event){ void VToolPoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event){
if(event->button() == Qt::LeftButton){ if(event->button() == Qt::LeftButton){
emit ChoosedTool(id, Scene::Point); emit ChoosedTool(id, Scene::Point);
@ -106,21 +112,25 @@ void VToolPoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *event){
void VToolPoint::hoverMoveEvent(QGraphicsSceneHoverEvent *event){ void VToolPoint::hoverMoveEvent(QGraphicsSceneHoverEvent *event){
Q_UNUSED(event); Q_UNUSED(event);
this->setPen(QPen(currentColor, widthMainLine)); this->setPen(QPen(currentColor, widthMainLine/factor));
} }
void VToolPoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event){ void VToolPoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event){
Q_UNUSED(event); Q_UNUSED(event);
this->setPen(QPen(currentColor, widthHairLine)); this->setPen(QPen(currentColor, widthHairLine/factor));
} }
void VToolPoint::RefreshPointGeometry(const VPointF &point){ void VToolPoint::RefreshPointGeometry(const VPointF &point){
QRectF rec = QRectF(0, 0, radius*2, radius*2); this->setPen(QPen(currentColor, widthHairLine/factor));
QRectF rec = QRectF(0, 0, radius*2/factor, radius*2/factor);
rec.translate(-rec.center().x(), -rec.center().y()); rec.translate(-rec.center().x(), -rec.center().y());
this->setRect(rec); this->setRect(rec);
this->setPos(point.toQPointF()); this->setPos(point.toQPointF());
disconnect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this, disconnect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this,
&VToolPoint::NameChangePosition); &VToolPoint::NameChangePosition);
QFont font = namePoint->font();
font.setPointSize(static_cast<qint32>(namePoint->FontSize()/factor));
namePoint->setFont(font);
namePoint->setText(point.name()); namePoint->setText(point.name());
namePoint->setPos(QPointF(point.mx(), point.my())); namePoint->setPos(QPointF(point.mx(), point.my()));
connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this, connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this,
@ -131,9 +141,10 @@ void VToolPoint::RefreshPointGeometry(const VPointF &point){
void VToolPoint::RefreshLine(){ void VToolPoint::RefreshLine(){
QRectF nameRec = namePoint->sceneBoundingRect(); QRectF nameRec = namePoint->sceneBoundingRect();
QPointF p1, p2; QPointF p1, p2;
LineIntersectCircle(QPointF(), radius, QLineF(QPointF(), nameRec.center()- scenePos()), p1, p2); LineIntersectCircle(QPointF(), radius/factor, QLineF(QPointF(), nameRec.center()- scenePos()), p1, p2);
QPointF pRec = LineIntersectRect(nameRec, QLineF(scenePos(), nameRec.center())); QPointF pRec = LineIntersectRect(nameRec, QLineF(scenePos(), nameRec.center()));
lineName->setLine(QLineF(p1, pRec - scenePos())); lineName->setLine(QLineF(p1, pRec - scenePos()));
lineName->setPen(QPen(currentColor, widthHairLine/factor));
if(QLineF(p1, pRec - scenePos()).length() <= toPixel(4)){ if(QLineF(p1, pRec - scenePos()).length() <= toPixel(4)){
lineName->setVisible(false); lineName->setVisible(false);
} else { } else {

View File

@ -36,6 +36,7 @@ public slots:
virtual void ChangedActivDraw(const QString newName); virtual void ChangedActivDraw(const QString newName);
virtual void FullUpdateFromGui(int result) = 0; virtual void FullUpdateFromGui(int result) = 0;
virtual void ShowTool(qint64 id, Qt::GlobalColor color, bool enable); virtual void ShowTool(qint64 id, Qt::GlobalColor color, bool enable);
virtual void SetFactor(qreal factor);
protected: protected:
qreal radius; qreal radius;
VGraphicsSimpleTextItem *namePoint; VGraphicsSimpleTextItem *namePoint;

View File

@ -91,7 +91,7 @@ void VToolPointOfContact::Create(const qint64 _id, const QString &radius, const
QString errorMsg; QString errorMsg;
qreal result = cal.eval(radius, &errorMsg); qreal result = cal.eval(radius, &errorMsg);
if(errorMsg.isEmpty()){ if(errorMsg.isEmpty()){
QPointF fPoint = VToolPointOfContact::FindPoint(result*PrintDPI/25.4, centerP.toQPointF(), QPointF fPoint = VToolPointOfContact::FindPoint(toPixel(result), centerP.toQPointF(),
firstP.toQPointF(), secondP.toQPointF()); firstP.toQPointF(), secondP.toQPointF());
qint64 id = _id; qint64 id = _id;
if(typeCreation == Tool::FromGui){ if(typeCreation == Tool::FromGui){
@ -115,6 +115,7 @@ void VToolPointOfContact::Create(const qint64 _id, const QString &radius, const
scene->addItem(point); scene->addItem(point);
connect(point, &VToolPointOfContact::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(point, &VToolPointOfContact::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(point, &VToolPointOfContact::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); connect(point, &VToolPointOfContact::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolPointOfContact::SetFactor);
doc->AddTool(id, point); doc->AddTool(id, point);
doc->IncrementReferens(center); doc->IncrementReferens(center);
doc->IncrementReferens(firstPointId); doc->IncrementReferens(firstPointId);
@ -149,6 +150,11 @@ void VToolPointOfContact::FullUpdateFromGui(int result){
dialogPointOfContact.clear(); dialogPointOfContact.clear();
} }
void VToolPointOfContact::SetFactor(qreal factor){
VDrawTool::SetFactor(factor);
RefreshPointGeometry(VAbstractTool::data.GetPoint(id));
}
void VToolPointOfContact::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){ void VToolPointOfContact::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
ContextMenu(dialogPointOfContact, this, event); ContextMenu(dialogPointOfContact, this, event);
} }
@ -160,8 +166,8 @@ void VToolPointOfContact::AddToFile(){
AddAttribute(domElement, "id", id); AddAttribute(domElement, "id", id);
AddAttribute(domElement, "type", "pointOfContact"); AddAttribute(domElement, "type", "pointOfContact");
AddAttribute(domElement, "name", point.name()); AddAttribute(domElement, "name", point.name());
AddAttribute(domElement, "mx", point.mx()/PrintDPI*25.4); AddAttribute(domElement, "mx", toMM(point.mx()));
AddAttribute(domElement, "my", point.my()/PrintDPI*25.4); AddAttribute(domElement, "my", toMM(point.my()));
AddAttribute(domElement, "radius", radius); AddAttribute(domElement, "radius", radius);
AddAttribute(domElement, "center", center); AddAttribute(domElement, "center", center);

View File

@ -29,20 +29,22 @@ class VToolPointOfContact : public VToolPoint
{ {
public: public:
VToolPointOfContact(VDomDocument *doc, VContainer *data, const qint64 &id, VToolPointOfContact(VDomDocument *doc, VContainer *data, const qint64 &id,
const QString &radius, const qint64 &center, const qint64 &firstPointId, const QString &radius, const qint64 &center,
const qint64 &secondPointId, Tool::Sources typeCreation, QGraphicsItem * parent = 0); const qint64 &firstPointId, const qint64 &secondPointId,
Tool::Sources typeCreation, QGraphicsItem * parent = 0);
virtual void setDialog(); virtual void setDialog();
static QPointF FindPoint(const qreal &radius, const QPointF &center, const QPointF &firstPoint, static QPointF FindPoint(const qreal &radius, const QPointF &center, const QPointF &firstPoint,
const QPointF &secondPoint); const QPointF &secondPoint);
static void Create(QSharedPointer<DialogPointOfContact> &dialog, VMainGraphicsScene *scene, static void Create(QSharedPointer<DialogPointOfContact> &dialog, VMainGraphicsScene *scene,
VDomDocument *doc, VContainer *data); VDomDocument *doc, VContainer *data);
static void Create(const qint64 _id, const QString &radius, const qint64 &center, const qint64 &firstPointId, static void Create(const qint64 _id, const QString &radius, const qint64 &center,
const qint64 &secondPointId, const QString &pointName, const qint64 &firstPointId, const qint64 &secondPointId, const QString &pointName,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc, const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data, const Document::Documents &parse, Tool::Sources typeCreation); VContainer *data, const Document::Documents &parse, Tool::Sources typeCreation);
public slots: public slots:
virtual void FullUpdateFromFile(); virtual void FullUpdateFromFile();
virtual void FullUpdateFromGui(int result); virtual void FullUpdateFromGui(int result);
virtual void SetFactor(qreal factor);
protected: protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile(); virtual void AddToFile();

View File

@ -117,6 +117,7 @@ void VToolShoulderPoint::Create(const qint64 _id, const QString &formula, const
scene->addItem(point); scene->addItem(point);
connect(point, &VToolShoulderPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(point, &VToolShoulderPoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(point, &VToolShoulderPoint::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); connect(point, &VToolShoulderPoint::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
connect(scene, &VMainGraphicsScene::NewFactor, point, &VToolShoulderPoint::SetFactor);
doc->AddTool(id, point); doc->AddTool(id, point);
doc->IncrementReferens(p1Line); doc->IncrementReferens(p1Line);
doc->IncrementReferens(p2Line); doc->IncrementReferens(p2Line);
@ -153,6 +154,11 @@ void VToolShoulderPoint::FullUpdateFromGui(int result){
dialogShoulderPoint.clear(); dialogShoulderPoint.clear();
} }
void VToolShoulderPoint::SetFactor(qreal factor){
VDrawTool::SetFactor(factor);
RefreshGeometry();
}
void VToolShoulderPoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){ void VToolShoulderPoint::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
ContextMenu(dialogShoulderPoint, this, event); ContextMenu(dialogShoulderPoint, this, event);
} }
@ -164,8 +170,8 @@ void VToolShoulderPoint::AddToFile(){
AddAttribute(domElement, "id", id); AddAttribute(domElement, "id", id);
AddAttribute(domElement, "type", "shoulder"); AddAttribute(domElement, "type", "shoulder");
AddAttribute(domElement, "name", point.name()); AddAttribute(domElement, "name", point.name());
AddAttribute(domElement, "mx", point.mx()/PrintDPI*25.4); AddAttribute(domElement, "mx", toMM(point.mx()));
AddAttribute(domElement, "my", point.my()/PrintDPI*25.4); AddAttribute(domElement, "my", toMM(point.my()));
AddAttribute(domElement, "typeLine", typeLine); AddAttribute(domElement, "typeLine", typeLine);
AddAttribute(domElement, "length", formula); AddAttribute(domElement, "length", formula);

View File

@ -25,25 +25,26 @@
#include "vtoollinepoint.h" #include "vtoollinepoint.h"
#include "dialogs/dialogshoulderpoint.h" #include "dialogs/dialogshoulderpoint.h"
class VToolShoulderPoint : public VToolLinePoint class VToolShoulderPoint : public VToolLinePoint{
{
public: public:
VToolShoulderPoint(VDomDocument *doc, VContainer *data, const qint64 &id, VToolShoulderPoint(VDomDocument *doc, VContainer *data, const qint64 &id,
const QString &typeLine, const QString &formula, const qint64 &p1Line, const QString &typeLine, const QString &formula, const qint64 &p1Line,
const qint64 &p2Line, const qint64 &pShoulder, Tool::Sources typeCreation, const qint64 &p2Line, const qint64 &pShoulder,
QGraphicsItem * parent = 0); Tool::Sources typeCreation, QGraphicsItem * parent = 0);
virtual void setDialog(); virtual void setDialog();
static QPointF FindPoint(const QPointF &p1Line, const QPointF &p2Line, const QPointF &pShoulder, static QPointF FindPoint(const QPointF &p1Line, const QPointF &p2Line, const QPointF &pShoulder,
const qreal &length); const qreal &length);
static void Create(QSharedPointer<DialogShoulderPoint> &dialog, VMainGraphicsScene *scene, static void Create(QSharedPointer<DialogShoulderPoint> &dialog, VMainGraphicsScene *scene,
VDomDocument *doc, VContainer *data); VDomDocument *doc, VContainer *data);
static void Create(const qint64 _id, const QString &formula, const qint64 &p1Line, const qint64 &p2Line, static void Create(const qint64 _id, const QString &formula, const qint64 &p1Line,
const qint64 &pShoulder, const QString &typeLine, const QString &pointName, const qint64 &p2Line, const qint64 &pShoulder, const QString &typeLine,
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc, const QString &pointName, const qreal &mx, const qreal &my,
VContainer *data, const Document::Documents &parse, Tool::Sources typeCreation); VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
const Document::Documents &parse, Tool::Sources typeCreation);
public slots: public slots:
virtual void FullUpdateFromFile(); virtual void FullUpdateFromFile();
virtual void FullUpdateFromGui(int result); virtual void FullUpdateFromGui(int result);
virtual void SetFactor(qreal factor);
protected: protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile(); virtual void AddToFile();

View File

@ -124,3 +124,8 @@ void VToolSinglePoint::ChangedActivDraw(const QString newName){
VToolPoint::ChangedActivDraw(newName); VToolPoint::ChangedActivDraw(newName);
} }
} }
void VToolSinglePoint::SetFactor(qreal factor){
VDrawTool::SetFactor(factor);
RefreshPointGeometry(VAbstractTool::data.GetPoint(id));
}

View File

@ -36,6 +36,7 @@ public slots:
virtual void FullUpdateFromFile(); virtual void FullUpdateFromFile();
virtual void FullUpdateFromGui(int result); virtual void FullUpdateFromGui(int result);
virtual void ChangedActivDraw(const QString newName); virtual void ChangedActivDraw(const QString newName);
virtual void SetFactor(qreal factor);
signals: signals:
void FullUpdateTree(); void FullUpdateTree();
protected: protected:

View File

@ -34,7 +34,7 @@ VToolSpline::VToolSpline(VDomDocument *doc, VContainer *data, qint64 id,
path.addPath(spl.GetPath()); path.addPath(spl.GetPath());
path.setFillRule( Qt::WindingFill ); path.setFillRule( Qt::WindingFill );
this->setPath(path); this->setPath(path);
this->setPen(QPen(Qt::black, widthHairLine)); this->setPen(QPen(Qt::black, widthHairLine/factor));
this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setAcceptHoverEvents(true); this->setAcceptHoverEvents(true);
@ -108,6 +108,7 @@ void VToolSpline::Create(const qint64 _id, const qint64 &p1, const qint64 &p4, c
scene->addItem(spl); scene->addItem(spl);
connect(spl, &VToolSpline::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(spl, &VToolSpline::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(spl, &VToolSpline::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); connect(spl, &VToolSpline::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
connect(scene, &VMainGraphicsScene::NewFactor, spl, &VToolSpline::SetFactor);
doc->AddTool(id, spl); doc->AddTool(id, spl);
doc->IncrementReferens(p1); doc->IncrementReferens(p1);
doc->IncrementReferens(p4); doc->IncrementReferens(p4);
@ -202,12 +203,12 @@ void VToolSpline::mouseReleaseEvent(QGraphicsSceneMouseEvent *event){
void VToolSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event){ void VToolSpline::hoverMoveEvent(QGraphicsSceneHoverEvent *event){
Q_UNUSED(event); Q_UNUSED(event);
this->setPen(QPen(currentColor, widthMainLine)); this->setPen(QPen(currentColor, widthMainLine/factor));
} }
void VToolSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event){ void VToolSpline::hoverLeaveEvent(QGraphicsSceneHoverEvent *event){
Q_UNUSED(event); Q_UNUSED(event);
this->setPen(QPen(currentColor, widthHairLine)); this->setPen(QPen(currentColor, widthHairLine/factor));
} }
void VToolSpline::RemoveReferens(){ void VToolSpline::RemoveReferens(){
@ -217,6 +218,7 @@ void VToolSpline::RemoveReferens(){
} }
void VToolSpline::RefreshGeometry(){ void VToolSpline::RefreshGeometry(){
this->setPen(QPen(currentColor, widthHairLine/factor));
VSpline spl = VAbstractTool::data.GetSpline(id); VSpline spl = VAbstractTool::data.GetSpline(id);
QPainterPath path; QPainterPath path;
path.addPath(spl.GetPath()); path.addPath(spl.GetPath());
@ -244,15 +246,17 @@ void VToolSpline::RefreshGeometry(){
void VToolSpline::ChangedActivDraw(const QString newName){ void VToolSpline::ChangedActivDraw(const QString newName){
if(nameActivDraw == newName){ if(nameActivDraw == newName){
this->setPen(QPen(Qt::black, widthHairLine)); this->setPen(QPen(Qt::black, widthHairLine/factor));
this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setAcceptHoverEvents(true); this->setAcceptHoverEvents(true);
currentColor = Qt::black;
emit setEnabledPoint(true); emit setEnabledPoint(true);
VDrawTool::ChangedActivDraw(newName); VDrawTool::ChangedActivDraw(newName);
} else { } else {
this->setPen(QPen(Qt::gray, widthHairLine)); this->setPen(QPen(Qt::gray, widthHairLine/factor));
this->setFlag(QGraphicsItem::ItemIsSelectable, false); this->setFlag(QGraphicsItem::ItemIsSelectable, false);
this->setAcceptHoverEvents (false); this->setAcceptHoverEvents (false);
currentColor = Qt::gray;
emit setEnabledPoint(false); emit setEnabledPoint(false);
VDrawTool::ChangedActivDraw(newName); VDrawTool::ChangedActivDraw(newName);
} }
@ -261,11 +265,16 @@ void VToolSpline::ChangedActivDraw(const QString newName){
void VToolSpline::ShowTool(qint64 id, Qt::GlobalColor color, bool enable){ void VToolSpline::ShowTool(qint64 id, Qt::GlobalColor color, bool enable){
if(id == this->id){ if(id == this->id){
if(enable == false){ if(enable == false){
this->setPen(QPen(baseColor, widthHairLine)); this->setPen(QPen(baseColor, widthHairLine/factor));
currentColor = baseColor; currentColor = baseColor;
} else { } else {
this->setPen(QPen(color, widthHairLine)); this->setPen(QPen(color, widthHairLine/factor));
currentColor = color; currentColor = color;
} }
} }
} }
void VToolSpline::SetFactor(qreal factor){
VDrawTool::SetFactor(factor);
RefreshGeometry();
}

View File

@ -28,19 +28,18 @@
#include "widgets/vcontrolpointspline.h" #include "widgets/vcontrolpointspline.h"
#include "geometry/vsplinepath.h" #include "geometry/vsplinepath.h"
class VToolSpline:public VDrawTool, public QGraphicsPathItem class VToolSpline:public VDrawTool, public QGraphicsPathItem{
{
Q_OBJECT Q_OBJECT
public: public:
VToolSpline (VDomDocument *doc, VContainer *data, qint64 id, VToolSpline (VDomDocument *doc, VContainer *data, qint64 id, Tool::Sources typeCreation,
Tool::Sources typeCreation, QGraphicsItem * parent = 0 ); QGraphicsItem * parent = 0 );
virtual void setDialog(); virtual void setDialog();
static void Create(QSharedPointer<DialogSpline> &dialog, VMainGraphicsScene *scene, VDomDocument *doc, static void Create(QSharedPointer<DialogSpline> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
VContainer *data); VContainer *data);
static void Create(const qint64 _id, const qint64 &p1, const qint64 &p4, const qreal &kAsm1, static void Create(const qint64 _id, const qint64 &p1, const qint64 &p4, const qreal &kAsm1,
const qreal kAsm2, const qreal &angle1, const qreal &angle2, const qreal &kCurve, const qreal kAsm2, const qreal &angle1, const qreal &angle2, const qreal &kCurve,
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, const Document::Documents &parse, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
Tool::Sources typeCreation); const Document::Documents &parse, Tool::Sources typeCreation);
signals: signals:
void RefreshLine ( const qint32 &indexSpline, SplinePoint::Position position, void RefreshLine ( const qint32 &indexSpline, SplinePoint::Position position,
const QPointF &controlPoint, const QPointF &splinePoint ); const QPointF &controlPoint, const QPointF &splinePoint );
@ -48,11 +47,11 @@ signals:
public slots: public slots:
virtual void FullUpdateFromFile (); virtual void FullUpdateFromFile ();
virtual void FullUpdateFromGui ( int result ); virtual void FullUpdateFromGui ( int result );
void ControlPointChangePosition ( const qint32 &indexSpline, void ControlPointChangePosition ( const qint32 &indexSpline, SplinePoint::Position position,
SplinePoint::Position position,
const QPointF pos); const QPointF pos);
virtual void ChangedActivDraw ( const QString newName ); virtual void ChangedActivDraw ( const QString newName );
virtual void ShowTool(qint64 id, Qt::GlobalColor color, bool enable); virtual void ShowTool(qint64 id, Qt::GlobalColor color, bool enable);
virtual void SetFactor(qreal factor);
protected: protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile (); virtual void AddToFile ();

View File

@ -32,7 +32,7 @@ VToolSplinePath::VToolSplinePath(VDomDocument *doc, VContainer *data, qint64 id,
path.addPath(splPath.GetPath()); path.addPath(splPath.GetPath());
path.setFillRule( Qt::WindingFill ); path.setFillRule( Qt::WindingFill );
this->setPath(path); this->setPath(path);
this->setPen(QPen(Qt::black, widthHairLine)); this->setPen(QPen(Qt::black, widthHairLine/factor));
this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setAcceptHoverEvents(true); this->setAcceptHoverEvents(true);
@ -96,6 +96,7 @@ void VToolSplinePath::Create(const qint64 _id, const VSplinePath &path, VMainGra
scene->addItem(spl); scene->addItem(spl);
connect(spl, &VToolSplinePath::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(spl, &VToolSplinePath::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(spl, &VToolSplinePath::RemoveTool, scene, &VMainGraphicsScene::RemoveTool); connect(spl, &VToolSplinePath::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
connect(scene, &VMainGraphicsScene::NewFactor, spl, &VToolSplinePath::SetFactor);
doc->AddTool(id, spl); doc->AddTool(id, spl);
} }
} }
@ -187,15 +188,17 @@ void VToolSplinePath::UpdatePathPoint(QDomNode& node, VSplinePath &path){
void VToolSplinePath::ChangedActivDraw(const QString newName){ void VToolSplinePath::ChangedActivDraw(const QString newName){
if(nameActivDraw == newName){ if(nameActivDraw == newName){
this->setPen(QPen(Qt::black, widthHairLine)); this->setPen(QPen(Qt::black, widthHairLine/factor));
this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setAcceptHoverEvents(true); this->setAcceptHoverEvents(true);
currentColor = Qt::black;
emit setEnabledPoint(true); emit setEnabledPoint(true);
VDrawTool::ChangedActivDraw(newName); VDrawTool::ChangedActivDraw(newName);
} else { } else {
this->setPen(QPen(Qt::gray, widthHairLine)); this->setPen(QPen(Qt::gray, widthHairLine/factor));
this->setFlag(QGraphicsItem::ItemIsSelectable, false); this->setFlag(QGraphicsItem::ItemIsSelectable, false);
this->setAcceptHoverEvents (false); this->setAcceptHoverEvents (false);
currentColor = Qt::gray;
emit setEnabledPoint(false); emit setEnabledPoint(false);
VDrawTool::ChangedActivDraw(newName); VDrawTool::ChangedActivDraw(newName);
} }
@ -204,15 +207,20 @@ void VToolSplinePath::ChangedActivDraw(const QString newName){
void VToolSplinePath::ShowTool(qint64 id, Qt::GlobalColor color, bool enable){ void VToolSplinePath::ShowTool(qint64 id, Qt::GlobalColor color, bool enable){
if(id == this->id){ if(id == this->id){
if(enable == false){ if(enable == false){
this->setPen(QPen(baseColor, widthHairLine)); this->setPen(QPen(baseColor, widthHairLine/factor));
currentColor = baseColor; currentColor = baseColor;
} else { } else {
this->setPen(QPen(color, widthHairLine)); this->setPen(QPen(color, widthHairLine/factor));
currentColor = color; currentColor = color;
} }
} }
} }
void VToolSplinePath::SetFactor(qreal factor){
VDrawTool::SetFactor(factor);
RefreshGeometry();
}
void VToolSplinePath::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){ void VToolSplinePath::contextMenuEvent(QGraphicsSceneContextMenuEvent *event){
ContextMenu(dialogSplinePath, this, event); ContextMenu(dialogSplinePath, this, event);
} }
@ -252,12 +260,12 @@ void VToolSplinePath::mouseReleaseEvent(QGraphicsSceneMouseEvent *event){
void VToolSplinePath::hoverMoveEvent(QGraphicsSceneHoverEvent *event){ void VToolSplinePath::hoverMoveEvent(QGraphicsSceneHoverEvent *event){
Q_UNUSED(event); Q_UNUSED(event);
this->setPen(QPen(currentColor, widthMainLine)); this->setPen(QPen(currentColor, widthMainLine/factor));
} }
void VToolSplinePath::hoverLeaveEvent(QGraphicsSceneHoverEvent *event){ void VToolSplinePath::hoverLeaveEvent(QGraphicsSceneHoverEvent *event){
Q_UNUSED(event); Q_UNUSED(event);
this->setPen(QPen(currentColor, widthHairLine)); this->setPen(QPen(currentColor, widthHairLine/factor));
} }
void VToolSplinePath::RemoveReferens(){ void VToolSplinePath::RemoveReferens(){
@ -268,6 +276,7 @@ void VToolSplinePath::RemoveReferens(){
} }
void VToolSplinePath::RefreshGeometry(){ void VToolSplinePath::RefreshGeometry(){
this->setPen(QPen(currentColor, widthHairLine/factor));
VSplinePath splPath = VAbstractTool::data.GetSplinePath(id); VSplinePath splPath = VAbstractTool::data.GetSplinePath(id);
QPainterPath path; QPainterPath path;
path.addPath(splPath.GetPath()); path.addPath(splPath.GetPath());

View File

@ -30,15 +30,14 @@
class VToolSplinePath:public VDrawTool, public QGraphicsPathItem{ class VToolSplinePath:public VDrawTool, public QGraphicsPathItem{
Q_OBJECT Q_OBJECT
public: public:
VToolSplinePath(VDomDocument *doc, VContainer *data, qint64 id, VToolSplinePath(VDomDocument *doc, VContainer *data, qint64 id, Tool::Sources typeCreation,
Tool::Sources typeCreation,
QGraphicsItem * parent = 0); QGraphicsItem * parent = 0);
virtual void setDialog(); virtual void setDialog();
static void Create(QSharedPointer<DialogSplinePath> &dialog, static void Create(QSharedPointer<DialogSplinePath> &dialog, VMainGraphicsScene *scene,
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data); VDomDocument *doc, VContainer *data);
static void Create(const qint64 _id, const VSplinePath &path, static void Create(const qint64 _id, const VSplinePath &path, VMainGraphicsScene *scene,
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data, VDomDocument *doc, VContainer *data, const Document::Documents &parse,
const Document::Documents &parse, Tool::Sources typeCreation); Tool::Sources typeCreation);
signals: signals:
void RefreshLine(const qint32 &indexSpline, SplinePoint::Position pos, void RefreshLine(const qint32 &indexSpline, SplinePoint::Position pos,
const QPointF &controlPoint, const QPointF &splinePoint); const QPointF &controlPoint, const QPointF &splinePoint);
@ -46,11 +45,11 @@ signals:
public slots: public slots:
virtual void FullUpdateFromFile(); virtual void FullUpdateFromFile();
virtual void FullUpdateFromGui(int result); virtual void FullUpdateFromGui(int result);
void ControlPointChangePosition(const qint32 &indexSpline, void ControlPointChangePosition(const qint32 &indexSpline, SplinePoint::Position position,
SplinePoint::Position position,
const QPointF pos); const QPointF pos);
virtual void ChangedActivDraw(const QString newName); virtual void ChangedActivDraw(const QString newName);
virtual void ShowTool(qint64 id, Qt::GlobalColor color, bool enable); virtual void ShowTool(qint64 id, Qt::GlobalColor color, bool enable);
virtual void SetFactor(qreal factor);
protected: protected:
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event ); virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
virtual void AddToFile(); virtual void AddToFile();
@ -64,8 +63,7 @@ private:
void RefreshGeometry(); void RefreshGeometry();
void AddPathPoint(QDomElement &domElement, const VSplinePoint &splPoint); void AddPathPoint(QDomElement &domElement, const VSplinePoint &splPoint);
void UpdatePathPoint(QDomNode& node, VSplinePath &path); void UpdatePathPoint(QDomNode& node, VSplinePath &path);
void CorectControlPoints(const VSpline &spl, VSplinePath &splPath, void CorectControlPoints(const VSpline &spl, VSplinePath &splPath, const qint32 &indexSpline);
const qint32 &indexSpline);
}; };
#endif // VTOOLSPLINEPATH_H #endif // VTOOLSPLINEPATH_H

View File

@ -22,16 +22,22 @@
#include "vgraphicssimpletextitem.h" #include "vgraphicssimpletextitem.h"
#include <QGraphicsScene> #include <QGraphicsScene>
#include <QEvent> #include <QEvent>
#include <QDebug>
VGraphicsSimpleTextItem::VGraphicsSimpleTextItem(QGraphicsItem * parent):QGraphicsSimpleTextItem(parent){ VGraphicsSimpleTextItem::VGraphicsSimpleTextItem(QGraphicsItem * parent):QGraphicsSimpleTextItem(parent),
fontSize(0){
this->setFlag(QGraphicsItem::ItemIsMovable, true); this->setFlag(QGraphicsItem::ItemIsMovable, true);
this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
this->setAcceptHoverEvents(true); this->setAcceptHoverEvents(true);
QFont font = this->font();
font.setPointSize(font.pointSize()+3);
fontSize = font.pointSize();
this->setFont(font);
} }
VGraphicsSimpleTextItem::VGraphicsSimpleTextItem( const QString & text, QGraphicsItem * parent ) VGraphicsSimpleTextItem::VGraphicsSimpleTextItem( const QString & text, QGraphicsItem * parent )
:QGraphicsSimpleTextItem(text, parent){ :QGraphicsSimpleTextItem(text, parent), fontSize(0){
this->setFlag(QGraphicsItem::ItemIsMovable, true); this->setFlag(QGraphicsItem::ItemIsMovable, true);
this->setFlag(QGraphicsItem::ItemIsSelectable, true); this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);

View File

@ -24,18 +24,20 @@
#include <QGraphicsSimpleTextItem> #include <QGraphicsSimpleTextItem>
class VGraphicsSimpleTextItem : public QObject, public QGraphicsSimpleTextItem class VGraphicsSimpleTextItem : public QObject, public QGraphicsSimpleTextItem{
{
Q_OBJECT Q_OBJECT
public: public:
VGraphicsSimpleTextItem(QGraphicsItem * parent = 0); VGraphicsSimpleTextItem(QGraphicsItem * parent = 0);
VGraphicsSimpleTextItem( const QString & text, QGraphicsItem * parent = 0 ); VGraphicsSimpleTextItem( const QString & text, QGraphicsItem * parent = 0 );
qint32 FontSize()const {return fontSize;}
signals: signals:
void NameChangePosition(const QPointF pos); void NameChangePosition(const QPointF pos);
protected: protected:
QVariant itemChange ( GraphicsItemChange change, const QVariant &value ); QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event ); virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ); virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
private:
qint32 fontSize;
}; };
#endif // VGRAPHICSSIMPLETEXTITEM_H #endif // VGRAPHICSSIMPLETEXTITEM_H

View File

@ -25,11 +25,11 @@
#include <QScrollBar> #include <QScrollBar>
#include <QGraphicsItem> #include <QGraphicsItem>
VMainGraphicsScene::VMainGraphicsScene():QGraphicsScene(), horScrollBar(0), verScrollBar(0){ VMainGraphicsScene::VMainGraphicsScene():QGraphicsScene(), horScrollBar(0), verScrollBar(0), scaleFactor(1){
} }
VMainGraphicsScene::VMainGraphicsScene(const QRectF & sceneRect, QObject * parent): VMainGraphicsScene::VMainGraphicsScene(const QRectF & sceneRect, QObject * parent):
QGraphicsScene ( sceneRect, parent ), horScrollBar(0), verScrollBar(0){ QGraphicsScene ( sceneRect, parent ), horScrollBar(0), verScrollBar(0), scaleFactor(1){
} }
void VMainGraphicsScene::mouseMoveEvent(QGraphicsSceneMouseEvent* event){ void VMainGraphicsScene::mouseMoveEvent(QGraphicsSceneMouseEvent* event){
@ -50,6 +50,11 @@ void VMainGraphicsScene::RemoveTool(QGraphicsItem *tool){
this->removeItem(tool); this->removeItem(tool);
} }
void VMainGraphicsScene::SetFactor(qreal factor){
scaleFactor=scaleFactor*factor;
emit NewFactor(scaleFactor);
}
qint32 VMainGraphicsScene::getVerScrollBar() const{ qint32 VMainGraphicsScene::getVerScrollBar() const{
return verScrollBar; return verScrollBar;
} }

View File

@ -42,6 +42,7 @@ public:
public slots: public slots:
void ChoosedItem(qint64 id, Scene::Scenes type); void ChoosedItem(qint64 id, Scene::Scenes type);
void RemoveTool(QGraphicsItem *tool); void RemoveTool(QGraphicsItem *tool);
void SetFactor(qreal factor);
protected: protected:
void mouseMoveEvent(QGraphicsSceneMouseEvent* event); void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
void mousePressEvent(QGraphicsSceneMouseEvent *event); void mousePressEvent(QGraphicsSceneMouseEvent *event);
@ -49,9 +50,11 @@ signals:
void mouseMove(QPointF scenePos); void mouseMove(QPointF scenePos);
void mousePress(QPointF scenePos); void mousePress(QPointF scenePos);
void ChoosedObject(qint64 id, Scene::Scenes type); void ChoosedObject(qint64 id, Scene::Scenes type);
void NewFactor(qreal factor);
private: private:
qint32 horScrollBar; qint32 horScrollBar;
qint32 verScrollBar; qint32 verScrollBar;
qreal scaleFactor;
}; };
#endif // VMAINGRAPHICSSCENE_H #endif // VMAINGRAPHICSSCENE_H

View File

@ -60,6 +60,7 @@ void VMainGraphicsView::scalingTime(qreal x){
verticalScrollBar()->setValue(qRound(verticalScrollBar()->value() - factor*3.5)); verticalScrollBar()->setValue(qRound(verticalScrollBar()->value() - factor*3.5));
} }
} }
emit NewFactor(factor);
} }
void VMainGraphicsView::animFinished(){ void VMainGraphicsView::animFinished(){

View File

@ -29,6 +29,7 @@ class VMainGraphicsView : public QGraphicsView{
public: public:
explicit VMainGraphicsView(QWidget *parent = 0); explicit VMainGraphicsView(QWidget *parent = 0);
signals: signals:
void NewFactor(qreal factor);
public slots: public slots:
void scalingTime(qreal x); void scalingTime(qreal x);
void animFinished(); void animFinished();

View File

@ -584,6 +584,7 @@ void VDomDocument::ParsePointElement(VMainGraphicsScene *scene, const QDomElemen
Q_ASSERT(spoint != 0); Q_ASSERT(spoint != 0);
scene->addItem(spoint); scene->addItem(spoint);
connect(spoint, &VToolSinglePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); connect(spoint, &VToolSinglePoint::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(scene, &VMainGraphicsScene::NewFactor, spoint, &VToolSinglePoint::SetFactor);
tools[id] = spoint; tools[id] = spoint;
} }
return; return;