Use static method FindPoint common for tools.
--HG-- branch : develop
This commit is contained in:
parent
54bf459e17
commit
25190e16a9
|
@ -25,30 +25,30 @@
|
|||
#include "vtoollinepoint.h"
|
||||
#include "dialogs/dialogalongline.h"
|
||||
|
||||
class VToolAlongLine : public VToolLinePoint
|
||||
{
|
||||
class VToolAlongLine : public VToolLinePoint{
|
||||
Q_OBJECT
|
||||
public:
|
||||
VToolAlongLine(VDomDocument *doc, VContainer *data, qint64 id, const QString &formula,
|
||||
const qint64 &firstPointId, const qint64 &secondPointId, const QString &typeLine,
|
||||
Tool::Sources typeCreation, QGraphicsItem * parent = 0);
|
||||
virtual void setDialog();
|
||||
static void Create(QSharedPointer<DialogAlongLine> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||
VContainer *data);
|
||||
static void Create(const qint64 _id, const QString &pointName, const QString &typeLine,
|
||||
const QString &formula, const qint64 &firstPointId, const qint64 &secondPointId,
|
||||
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||
VContainer *data, const Document::Documents &parse, Tool::Sources typeCreation);
|
||||
VToolAlongLine(VDomDocument *doc, VContainer *data, qint64 id, const QString &formula,
|
||||
const qint64 &firstPointId, const qint64 &secondPointId,
|
||||
const QString &typeLine, Tool::Sources typeCreation,
|
||||
QGraphicsItem * parent = 0);
|
||||
virtual void setDialog();
|
||||
static void Create(QSharedPointer<DialogAlongLine> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||
VContainer *data);
|
||||
static void Create(const qint64 _id, const QString &pointName, const QString &typeLine,
|
||||
const QString &formula, const qint64 &firstPointId, const qint64 &secondPointId,
|
||||
const qreal &mx, const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||
VContainer *data, const Document::Documents &parse, Tool::Sources typeCreation);
|
||||
public slots:
|
||||
virtual void FullUpdateFromFile();
|
||||
virtual void FullUpdateFromGui(int result);
|
||||
virtual void SetFactor(qreal factor);
|
||||
virtual void FullUpdateFromFile();
|
||||
virtual void FullUpdateFromGui(int result);
|
||||
virtual void SetFactor(qreal factor);
|
||||
protected:
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
||||
virtual void AddToFile();
|
||||
virtual void RemoveReferens();
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
||||
virtual void AddToFile();
|
||||
virtual void RemoveReferens();
|
||||
private:
|
||||
qint64 secondPointId;
|
||||
qint64 secondPointId;
|
||||
QSharedPointer<DialogAlongLine> dialogAlongLine;
|
||||
};
|
||||
|
||||
|
|
|
@ -27,31 +27,31 @@
|
|||
|
||||
class VToolBisector : public VToolLinePoint{
|
||||
public:
|
||||
VToolBisector(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||
const QString &typeLine, const QString &formula, const qint64 &firstPointId,
|
||||
const qint64 &secondPointId, const qint64 &thirdPointId, Tool::Sources typeCreation,
|
||||
QGraphicsItem * parent = 0);
|
||||
static QPointF FindPoint(const QPointF &firstPoint, const QPointF &secondPoint,
|
||||
VToolBisector(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||
const QString &typeLine, const QString &formula, const qint64 &firstPointId,
|
||||
const qint64 &secondPointId, const qint64 &thirdPointId,
|
||||
Tool::Sources typeCreation, QGraphicsItem * parent = 0);
|
||||
static QPointF FindPoint(const QPointF &firstPoint, const QPointF &secondPoint,
|
||||
const QPointF &thirdPoint, const qreal& length);
|
||||
virtual void setDialog();
|
||||
static void Create(QSharedPointer<DialogBisector> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||
VContainer *data);
|
||||
static void Create(const qint64 _id, const QString &formula, const qint64 &firstPointId,
|
||||
const qint64 &secondPointId, const qint64 &thirdPointId, const QString &typeLine,
|
||||
const QString &pointName, const qreal &mx, const qreal &my, VMainGraphicsScene *scene,
|
||||
VDomDocument *doc, VContainer *data, const Document::Documents &parse,
|
||||
Tool::Sources typeCreation);
|
||||
virtual void setDialog();
|
||||
static void Create(QSharedPointer<DialogBisector> &dialog, VMainGraphicsScene *scene,
|
||||
VDomDocument *doc, VContainer *data);
|
||||
static void Create(const qint64 _id, const QString &formula, const qint64 &firstPointId,
|
||||
const qint64 &secondPointId, const qint64 &thirdPointId, const QString &typeLine,
|
||||
const QString &pointName, const qreal &mx, const qreal &my,
|
||||
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
|
||||
const Document::Documents &parse, Tool::Sources typeCreation);
|
||||
public slots:
|
||||
virtual void FullUpdateFromFile();
|
||||
virtual void FullUpdateFromGui(int result);
|
||||
virtual void SetFactor(qreal factor);
|
||||
virtual void FullUpdateFromFile();
|
||||
virtual void FullUpdateFromGui(int result);
|
||||
virtual void SetFactor(qreal factor);
|
||||
protected:
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
||||
virtual void AddToFile();
|
||||
virtual void RemoveReferens();
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
||||
virtual void AddToFile();
|
||||
virtual void RemoveReferens();
|
||||
private:
|
||||
qint64 firstPointId;
|
||||
qint64 thirdPointId;
|
||||
qint64 firstPointId;
|
||||
qint64 thirdPointId;
|
||||
QSharedPointer<DialogBisector> dialogBisector;
|
||||
};
|
||||
|
||||
|
|
|
@ -28,23 +28,22 @@
|
|||
class VToolEndLine : public VToolLinePoint{
|
||||
Q_OBJECT
|
||||
public:
|
||||
VToolEndLine(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||
const QString &typeLine, const QString &formula, const qreal &angle,
|
||||
const qint64 &basePointId, Tool::Sources typeCreation,
|
||||
QGraphicsItem * parent = 0);
|
||||
VToolEndLine(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine,
|
||||
const QString &formula, const qreal &angle, const qint64 &basePointId,
|
||||
Tool::Sources typeCreation, QGraphicsItem * parent = 0);
|
||||
virtual void setDialog();
|
||||
static void Create(QSharedPointer<DialogEndLine> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||
VContainer *data);
|
||||
static void Create(const qint64 _id, const QString &pointName, const QString &typeLine,
|
||||
const QString &formula, const qreal &angle, const qint64 &basePointId, const qreal &mx, const qreal &my,
|
||||
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
|
||||
const Document::Documents &parse, Tool::Sources typeCreation);
|
||||
static void Create(QSharedPointer<DialogEndLine> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||
VContainer *data);
|
||||
static void Create(const qint64 _id, const QString &pointName, const QString &typeLine,
|
||||
const QString &formula, const qreal &angle, const qint64 &basePointId, const qreal &mx,
|
||||
const qreal &my, VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
|
||||
const Document::Documents &parse, Tool::Sources typeCreation);
|
||||
public slots:
|
||||
virtual void FullUpdateFromFile();
|
||||
virtual void FullUpdateFromGui(int result);
|
||||
virtual void FullUpdateFromFile();
|
||||
virtual void FullUpdateFromGui(int result);
|
||||
protected:
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
||||
virtual void AddToFile();
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
||||
virtual void AddToFile();
|
||||
private:
|
||||
QSharedPointer<DialogEndLine> dialogEndLine;
|
||||
};
|
||||
|
|
|
@ -29,31 +29,31 @@
|
|||
class VToolLine: public VDrawTool, public QGraphicsLineItem{
|
||||
Q_OBJECT
|
||||
public:
|
||||
VToolLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firstPoint,
|
||||
qint64 secondPoint, Tool::Sources typeCreation, QGraphicsItem * parent = 0);
|
||||
virtual void setDialog();
|
||||
static void Create(QSharedPointer<DialogLine> &dialog, VMainGraphicsScene *scene,
|
||||
VDomDocument *doc, VContainer *data);
|
||||
static void Create(const qint64 &_id, const qint64 &firstPoint, const qint64 &secondPoint,
|
||||
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
|
||||
const Document::Documents &parse, Tool::Sources typeCreation);
|
||||
VToolLine(VDomDocument *doc, VContainer *data, qint64 id, qint64 firstPoint,
|
||||
qint64 secondPoint, Tool::Sources typeCreation, QGraphicsItem * parent = 0);
|
||||
virtual void setDialog();
|
||||
static void Create(QSharedPointer<DialogLine> &dialog, VMainGraphicsScene *scene, VDomDocument *doc,
|
||||
VContainer *data);
|
||||
static void Create(const qint64 &_id, const qint64 &firstPoint, const qint64 &secondPoint,
|
||||
VMainGraphicsScene *scene, VDomDocument *doc, VContainer *data,
|
||||
const Document::Documents &parse, Tool::Sources typeCreation);
|
||||
public slots:
|
||||
virtual void FullUpdateFromFile();
|
||||
virtual void ChangedActivDraw(const QString newName);
|
||||
virtual void FullUpdateFromGui(int result);
|
||||
virtual void ShowTool(qint64 id, Qt::GlobalColor color, bool enable);
|
||||
virtual void SetFactor(qreal factor);
|
||||
virtual void FullUpdateFromFile();
|
||||
virtual void ChangedActivDraw(const QString newName);
|
||||
virtual void FullUpdateFromGui(int result);
|
||||
virtual void ShowTool(qint64 id, Qt::GlobalColor color, bool enable);
|
||||
virtual void SetFactor(qreal factor);
|
||||
protected:
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
||||
virtual void AddToFile();
|
||||
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
|
||||
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
|
||||
virtual void RemoveReferens();
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
||||
virtual void AddToFile();
|
||||
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
|
||||
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
|
||||
virtual void RemoveReferens();
|
||||
private:
|
||||
qint64 firstPoint;
|
||||
qint64 secondPoint;
|
||||
qint64 firstPoint;
|
||||
qint64 secondPoint;
|
||||
QSharedPointer<DialogLine> dialogLine;
|
||||
void RefreshGeometry();
|
||||
void RefreshGeometry();
|
||||
};
|
||||
|
||||
#endif // VTOOLLINE_H
|
||||
|
|
|
@ -25,8 +25,7 @@
|
|||
#include "vtoollinepoint.h"
|
||||
#include "dialogs/dialognormal.h"
|
||||
|
||||
class VToolNormal : public VToolLinePoint
|
||||
{
|
||||
class VToolNormal : public VToolLinePoint{
|
||||
Q_OBJECT
|
||||
public:
|
||||
VToolNormal(VDomDocument *doc, VContainer *data, const qint64 &id, const QString &typeLine,
|
||||
|
|
|
@ -25,8 +25,7 @@
|
|||
#include "vtoolpoint.h"
|
||||
#include "dialogs/dialogpointofcontact.h"
|
||||
|
||||
class VToolPointOfContact : public VToolPoint
|
||||
{
|
||||
class VToolPointOfContact : public VToolPoint{
|
||||
public:
|
||||
VToolPointOfContact(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||
const QString &radius, const qint64 ¢er,
|
||||
|
|
|
@ -25,25 +25,24 @@
|
|||
#include "dialogs/dialogsinglepoint.h"
|
||||
#include "vtoolpoint.h"
|
||||
|
||||
class VToolSinglePoint : public VToolPoint
|
||||
{
|
||||
class VToolSinglePoint : public VToolPoint{
|
||||
Q_OBJECT
|
||||
public:
|
||||
VToolSinglePoint (VDomDocument *doc, VContainer *data, qint64 id,
|
||||
Tool::Sources typeCreation, QGraphicsItem * parent = 0 );
|
||||
virtual void setDialog();
|
||||
VToolSinglePoint (VDomDocument *doc, VContainer *data, qint64 id, Tool::Sources typeCreation,
|
||||
QGraphicsItem * parent = 0 );
|
||||
virtual void setDialog();
|
||||
public slots:
|
||||
virtual void FullUpdateFromFile();
|
||||
virtual void FullUpdateFromGui(int result);
|
||||
virtual void ChangedActivDraw(const QString newName);
|
||||
virtual void SetFactor(qreal factor);
|
||||
virtual void FullUpdateFromFile();
|
||||
virtual void FullUpdateFromGui(int result);
|
||||
virtual void ChangedActivDraw(const QString newName);
|
||||
virtual void SetFactor(qreal factor);
|
||||
signals:
|
||||
void FullUpdateTree();
|
||||
void FullUpdateTree();
|
||||
protected:
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
||||
virtual void AddToFile();
|
||||
QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
|
||||
virtual void decrementReferens();
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
||||
virtual void AddToFile();
|
||||
QVariant itemChange ( GraphicsItemChange change, const QVariant &value );
|
||||
virtual void decrementReferens();
|
||||
private:
|
||||
QSharedPointer<DialogSinglePoint> dialogSinglePoint;
|
||||
};
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include "vmodelingbisector.h"
|
||||
#include <QMenu>
|
||||
#include "../drawTools/vtoolbisector.h"
|
||||
|
||||
VModelingBisector::VModelingBisector(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||
const QString &typeLine, const QString &formula, const qint64 &firstPointId,
|
||||
|
@ -36,19 +37,6 @@ VModelingBisector::VModelingBisector(VDomDocument *doc, VContainer *data, const
|
|||
}
|
||||
}
|
||||
|
||||
QPointF VModelingBisector::FindPoint(const QPointF &firstPoint, const QPointF &secondPoint,
|
||||
const QPointF &thirdPoint, const qreal &length){
|
||||
QLineF line1(secondPoint, firstPoint);
|
||||
QLineF line2(secondPoint, thirdPoint);
|
||||
qreal angle = line1.angleTo(line2);
|
||||
if(angle>180){
|
||||
angle = 360 - angle;
|
||||
}
|
||||
line1.setAngle(line1.angle()-angle/2);
|
||||
line1.setLength(length);
|
||||
return line1.p2();
|
||||
}
|
||||
|
||||
void VModelingBisector::setDialog(){
|
||||
Q_ASSERT(!dialogBisector.isNull());
|
||||
if(!dialogBisector.isNull()){
|
||||
|
@ -89,7 +77,7 @@ VModelingBisector *VModelingBisector::Create(const qint64 _id, const QString &fo
|
|||
QString errorMsg;
|
||||
qreal result = cal.eval(formula, &errorMsg);
|
||||
if(errorMsg.isEmpty()){
|
||||
QPointF fPoint = VModelingBisector::FindPoint(firstPoint.toQPointF(), secondPoint.toQPointF(),
|
||||
QPointF fPoint = VToolBisector::FindPoint(firstPoint.toQPointF(), secondPoint.toQPointF(),
|
||||
thirdPoint.toQPointF(), result*PrintDPI/25.4);
|
||||
qint64 id = _id;
|
||||
if(typeCreation == Tool::FromGui){
|
||||
|
|
|
@ -28,31 +28,29 @@
|
|||
class VModelingBisector : public VModelingLinePoint{
|
||||
Q_OBJECT
|
||||
public:
|
||||
VModelingBisector(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||
const QString &typeLine, const QString &formula,
|
||||
const qint64 &firstPointId, const qint64 &secondPointId,
|
||||
const qint64 &thirdPointId, Tool::Sources typeCreation,
|
||||
QGraphicsItem * parent = 0);
|
||||
static QPointF FindPoint(const QPointF &firstPoint, const QPointF &secondPoint,
|
||||
const QPointF &thirdPoint, const qreal& length);
|
||||
virtual void setDialog();
|
||||
static VModelingBisector* Create(QSharedPointer<DialogBisector> &dialog, VDomDocument *doc,
|
||||
VContainer *data);
|
||||
static VModelingBisector* Create(const qint64 _id, const QString &formula, const qint64 &firstPointId,
|
||||
const qint64 &secondPointId, const qint64 &thirdPointId,
|
||||
const QString &typeLine, const QString &pointName, const qreal &mx,
|
||||
const qreal &my, VDomDocument *doc, VContainer *data,
|
||||
const Document::Documents &parse, Tool::Sources typeCreation);
|
||||
VModelingBisector(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||
const QString &typeLine, const QString &formula,
|
||||
const qint64 &firstPointId, const qint64 &secondPointId,
|
||||
const qint64 &thirdPointId, Tool::Sources typeCreation,
|
||||
QGraphicsItem * parent = 0);
|
||||
virtual void setDialog();
|
||||
static VModelingBisector* Create(QSharedPointer<DialogBisector> &dialog, VDomDocument *doc,
|
||||
VContainer *data);
|
||||
static VModelingBisector* Create(const qint64 _id, const QString &formula, const qint64 &firstPointId,
|
||||
const qint64 &secondPointId, const qint64 &thirdPointId,
|
||||
const QString &typeLine, const QString &pointName, const qreal &mx,
|
||||
const qreal &my, VDomDocument *doc, VContainer *data,
|
||||
const Document::Documents &parse, Tool::Sources typeCreation);
|
||||
public slots:
|
||||
virtual void FullUpdateFromFile();
|
||||
virtual void FullUpdateFromGui(int result);
|
||||
virtual void FullUpdateFromFile();
|
||||
virtual void FullUpdateFromGui(int result);
|
||||
protected:
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
||||
virtual void AddToFile();
|
||||
virtual void RemoveReferens();
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
||||
virtual void AddToFile();
|
||||
virtual void RemoveReferens();
|
||||
private:
|
||||
qint64 firstPointId;
|
||||
qint64 thirdPointId;
|
||||
qint64 firstPointId;
|
||||
qint64 thirdPointId;
|
||||
QSharedPointer<DialogBisector> dialogBisector;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "vmodelingheight.h"
|
||||
#include "../drawTools/vtoolheight.h"
|
||||
|
||||
VModelingHeight::VModelingHeight(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||
const QString &typeLine, const qint64 &basePointId, const qint64 &p1LineId,
|
||||
|
@ -44,7 +45,8 @@ VModelingHeight *VModelingHeight::Create(const qint64 _id, const QString &pointN
|
|||
VPointF p1Line = data->GetModelingPoint(p1LineId);
|
||||
VPointF p2Line = data->GetModelingPoint(p2LineId);
|
||||
|
||||
QPointF pHeight = FindPoint(QLineF(p1Line.toQPointF(), p2Line.toQPointF()), basePoint.toQPointF());
|
||||
QPointF pHeight = VToolHeight::FindPoint(QLineF(p1Line.toQPointF(), p2Line.toQPointF()),
|
||||
basePoint.toQPointF());
|
||||
QLineF line = QLineF(basePoint.toQPointF(), pHeight);
|
||||
qint64 id = _id;
|
||||
if(typeCreation == Tool::FromGui){
|
||||
|
@ -113,18 +115,3 @@ void VModelingHeight::AddToFile(){
|
|||
|
||||
AddToModeling(domElement);
|
||||
}
|
||||
|
||||
QPointF VModelingHeight::FindPoint(const QLineF &line, const QPointF &point){
|
||||
qreal a = 0, b = 0, c = 0;
|
||||
LineCoefficients(line, &a, &b, &c);
|
||||
qreal x = point.x() - b;
|
||||
qreal y = -a + point.y();
|
||||
QLineF l (point, QPointF(x, y));
|
||||
QPointF p;
|
||||
QLineF::IntersectType intersect = line.intersect(l, &p);
|
||||
if(intersect == QLineF::UnboundedIntersection || intersect == QLineF::BoundedIntersection){
|
||||
return p;
|
||||
} else {
|
||||
return QPointF();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,14 +11,13 @@ public:
|
|||
const QString &typeLine, const qint64 &basePointId,
|
||||
const qint64 &p1LineId, const qint64 &p2LineId,
|
||||
Tool::Sources typeCreation, QGraphicsItem * parent = 0);
|
||||
virtual void setDialog();
|
||||
virtual void setDialog();
|
||||
static VModelingHeight* Create(QSharedPointer<DialogHeight> &dialog, VDomDocument *doc,
|
||||
VContainer *data);
|
||||
static VModelingHeight* Create(const qint64 _id, const QString &pointName, const QString &typeLine,
|
||||
const qint64 &basePointId, const qint64 &p1LineId, const qint64 &p2LineId,
|
||||
const qreal &mx, const qreal &my, VDomDocument *doc, VContainer *data,
|
||||
const Document::Documents &parse, Tool::Sources typeCreation);
|
||||
static QPointF FindPoint(const QLineF &line, const QPointF &point);
|
||||
public slots:
|
||||
virtual void FullUpdateFromFile();
|
||||
virtual void FullUpdateFromGui(int result);
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include "vmodelingnormal.h"
|
||||
#include "../drawTools/vtoolnormal.h"
|
||||
|
||||
VModelingNormal::VModelingNormal(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||
const QString &typeLine,
|
||||
|
@ -72,8 +73,8 @@ VModelingNormal *VModelingNormal::Create(const qint64 _id, const QString &formul
|
|||
QString errorMsg;
|
||||
qreal result = cal.eval(formula, &errorMsg);
|
||||
if(errorMsg.isEmpty()){
|
||||
QPointF fPoint = VModelingNormal::FindPoint(firstPoint.toQPointF(), secondPoint.toQPointF(),
|
||||
result*PrintDPI/25.4, angle);
|
||||
QPointF fPoint = VToolNormal::FindPoint(firstPoint.toQPointF(), secondPoint.toQPointF(),
|
||||
toPixel(result), angle);
|
||||
qint64 id = _id;
|
||||
if(typeCreation == Tool::FromGui){
|
||||
id = data->AddModelingPoint(VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
|
||||
|
@ -95,15 +96,6 @@ VModelingNormal *VModelingNormal::Create(const qint64 _id, const QString &formul
|
|||
return point;
|
||||
}
|
||||
|
||||
QPointF VModelingNormal::FindPoint(const QPointF &firstPoint, const QPointF &secondPoint, const qreal &length,
|
||||
const qreal &angle){
|
||||
QLineF line(firstPoint, secondPoint);
|
||||
QLineF normal = line.normalVector();
|
||||
normal.setAngle(normal.angle()+angle);
|
||||
normal.setLength(length);
|
||||
return normal.p2();
|
||||
}
|
||||
|
||||
void VModelingNormal::FullUpdateFromFile(){
|
||||
QDomElement domElement = doc->elementById(QString().setNum(id));
|
||||
if(domElement.isElement()){
|
||||
|
|
|
@ -28,30 +28,27 @@
|
|||
class VModelingNormal : public VModelingLinePoint{
|
||||
Q_OBJECT
|
||||
public:
|
||||
VModelingNormal(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||
const QString &typeLine, const QString &formula,
|
||||
const qreal &angle, const qint64 &firstPointId,
|
||||
const qint64 &secondPointId, Tool::Sources typeCreation,
|
||||
QGraphicsItem * parent = 0);
|
||||
virtual void setDialog();
|
||||
static VModelingNormal* Create(QSharedPointer<DialogNormal> &dialog, VDomDocument *doc,
|
||||
VContainer *data);
|
||||
static VModelingNormal* Create(const qint64 _id, const QString &formula, const qint64 &firstPointId,
|
||||
const qint64 &secondPointId, const QString typeLine,
|
||||
const QString pointName, const qreal angle, const qreal &mx,
|
||||
const qreal &my, VDomDocument *doc, VContainer *data,
|
||||
const Document::Documents &parse, Tool::Sources typeCreation);
|
||||
static QPointF FindPoint(const QPointF &firstPoint, const QPointF &secondPoint,
|
||||
const qreal &length, const qreal &angle = 0);
|
||||
VModelingNormal(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||
const QString &typeLine, const QString &formula,
|
||||
const qreal &angle, const qint64 &firstPointId,
|
||||
const qint64 &secondPointId, Tool::Sources typeCreation,
|
||||
QGraphicsItem * parent = 0);
|
||||
virtual void setDialog();
|
||||
static VModelingNormal* Create(QSharedPointer<DialogNormal> &dialog, VDomDocument *doc, VContainer *data);
|
||||
static VModelingNormal* Create(const qint64 _id, const QString &formula, const qint64 &firstPointId,
|
||||
const qint64 &secondPointId, const QString typeLine,
|
||||
const QString pointName, const qreal angle, const qreal &mx,
|
||||
const qreal &my, VDomDocument *doc, VContainer *data,
|
||||
const Document::Documents &parse, Tool::Sources typeCreation);
|
||||
public slots:
|
||||
virtual void FullUpdateFromFile();
|
||||
virtual void FullUpdateFromGui(int result);
|
||||
virtual void FullUpdateFromFile();
|
||||
virtual void FullUpdateFromGui(int result);
|
||||
protected:
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
||||
virtual void AddToFile();
|
||||
virtual void RemoveReferens();
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
||||
virtual void AddToFile();
|
||||
virtual void RemoveReferens();
|
||||
private:
|
||||
qint64 secondPointId;
|
||||
qint64 secondPointId;
|
||||
QSharedPointer<DialogNormal> dialogNormal;
|
||||
};
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
****************************************************************************/
|
||||
|
||||
#include "vmodelingpointofcontact.h"
|
||||
#include "../drawTools/vtoolpointofcontact.h"
|
||||
|
||||
VModelingPointOfContact::VModelingPointOfContact(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||
const QString &radius, const qint64 ¢er,
|
||||
|
@ -45,28 +46,6 @@ void VModelingPointOfContact::setDialog(){
|
|||
}
|
||||
}
|
||||
|
||||
QPointF VModelingPointOfContact::FindPoint(const qreal &radius, const QPointF ¢er, const QPointF &firstPoint,
|
||||
const QPointF &secondPoint){
|
||||
QPointF pArc;
|
||||
qreal s = 0.0, s_x, s_y, step = 0.01, distans;
|
||||
while( s < 1){
|
||||
s_x = secondPoint.x()-(qAbs(secondPoint.x()-firstPoint.x()))*s;
|
||||
s_y = secondPoint.y()-(qAbs(secondPoint.y()-firstPoint.y()))*s;
|
||||
distans = QLineF(center.x(), center.y(), s_x, s_y).length();
|
||||
if(ceil(distans*10) == ceil(radius*10)){
|
||||
pArc.rx() = s_x;
|
||||
pArc.ry() = s_y;
|
||||
break;
|
||||
}
|
||||
if(distans<radius){
|
||||
pArc.rx() = s_x;
|
||||
pArc.ry() = s_y;
|
||||
}
|
||||
s = s + step;
|
||||
}
|
||||
return pArc;
|
||||
}
|
||||
|
||||
VModelingPointOfContact *VModelingPointOfContact::Create(QSharedPointer<DialogPointOfContact> &dialog,
|
||||
VDomDocument *doc, VContainer *data){
|
||||
QString radius = dialog->getRadius();
|
||||
|
@ -94,8 +73,8 @@ VModelingPointOfContact *VModelingPointOfContact::Create(const qint64 _id, const
|
|||
QString errorMsg;
|
||||
qreal result = cal.eval(radius, &errorMsg);
|
||||
if(errorMsg.isEmpty()){
|
||||
QPointF fPoint = VModelingPointOfContact::FindPoint(result*PrintDPI/25.4, centerP.toQPointF(),
|
||||
firstP.toQPointF(), secondP.toQPointF());
|
||||
QPointF fPoint = VToolPointOfContact::FindPoint(toPixel(result), centerP.toQPointF(),
|
||||
firstP.toQPointF(), secondP.toQPointF());
|
||||
qint64 id = _id;
|
||||
if(typeCreation == Tool::FromGui){
|
||||
id = data->AddModelingPoint(VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
|
||||
|
|
|
@ -28,35 +28,32 @@
|
|||
class VModelingPointOfContact : public VModelingPoint{
|
||||
Q_OBJECT
|
||||
public:
|
||||
VModelingPointOfContact(VDomDocument *doc, VContainer *data,
|
||||
const qint64 &id, const QString &radius,
|
||||
const qint64 ¢er,
|
||||
const qint64 &firstPointId,
|
||||
const qint64 &secondPointId,
|
||||
Tool::Sources typeCreation,
|
||||
QGraphicsItem * parent = 0);
|
||||
virtual void setDialog();
|
||||
static QPointF FindPoint(const qreal &radius, const QPointF ¢er,
|
||||
const QPointF &firstPoint, const QPointF &secondPoint);
|
||||
static VModelingPointOfContact* Create(QSharedPointer<DialogPointOfContact> &dialog,
|
||||
VModelingPointOfContact(VDomDocument *doc, VContainer *data,
|
||||
const qint64 &id, const QString &radius,
|
||||
const qint64 ¢er, const qint64 &firstPointId,
|
||||
const qint64 &secondPointId,
|
||||
Tool::Sources typeCreation,
|
||||
QGraphicsItem * parent = 0);
|
||||
virtual void setDialog();
|
||||
static VModelingPointOfContact* Create(QSharedPointer<DialogPointOfContact> &dialog,
|
||||
VDomDocument *doc, VContainer *data);
|
||||
static VModelingPointOfContact* Create(const qint64 _id, const QString &radius, const qint64 ¢er,
|
||||
const qint64 &firstPointId, const qint64 &secondPointId,
|
||||
const QString &pointName, const qreal &mx, const qreal &my,
|
||||
VDomDocument *doc, VContainer *data,
|
||||
const Document::Documents &parse, Tool::Sources typeCreation);
|
||||
static VModelingPointOfContact* Create(const qint64 _id, const QString &radius, const qint64 ¢er,
|
||||
const qint64 &firstPointId, const qint64 &secondPointId,
|
||||
const QString &pointName, const qreal &mx, const qreal &my,
|
||||
VDomDocument *doc, VContainer *data,
|
||||
const Document::Documents &parse, Tool::Sources typeCreation);
|
||||
public slots:
|
||||
virtual void FullUpdateFromFile();
|
||||
virtual void FullUpdateFromGui(int result);
|
||||
virtual void FullUpdateFromFile();
|
||||
virtual void FullUpdateFromGui(int result);
|
||||
protected:
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
||||
virtual void AddToFile();
|
||||
virtual void RemoveReferens();
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
||||
virtual void AddToFile();
|
||||
virtual void RemoveReferens();
|
||||
private:
|
||||
QString radius;
|
||||
qint64 center;
|
||||
qint64 firstPointId;
|
||||
qint64 secondPointId;
|
||||
QString radius;
|
||||
qint64 center;
|
||||
qint64 firstPointId;
|
||||
qint64 secondPointId;
|
||||
QSharedPointer<DialogPointOfContact> dialogPointOfContact;
|
||||
};
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include "vmodelingshoulderpoint.h"
|
||||
#include <QDebug>
|
||||
#include "../drawTools/vtoolshoulderpoint.h"
|
||||
|
||||
VModelingShoulderPoint::VModelingShoulderPoint(VDomDocument *doc, VContainer *data, const qint64 &id,
|
||||
const QString &typeLine, const QString &formula, const qint64 &p1Line,
|
||||
|
@ -48,27 +49,6 @@ void VModelingShoulderPoint::setDialog(){
|
|||
}
|
||||
}
|
||||
|
||||
QPointF VModelingShoulderPoint::FindPoint(const QPointF &p1Line, const QPointF &p2Line, const QPointF &pShoulder,
|
||||
const qreal &length){
|
||||
QLineF line = QLineF(p1Line, p2Line);
|
||||
qreal dist = line.length();
|
||||
if(dist>length){
|
||||
qDebug()<<"A3П2="<<length/PrintDPI*25.4<<"А30П ="<<dist/PrintDPI*25.4;
|
||||
throw"Не можу знайти точку плеча. Довжина А3П2 < А3П.";
|
||||
}
|
||||
if(dist==length){
|
||||
return line.p2();
|
||||
}
|
||||
qreal step = 0.01;
|
||||
while(1){
|
||||
line.setLength(line.length()+step);
|
||||
QLineF line2 = QLineF(pShoulder, line.p2());
|
||||
if(line2.length()>=length){
|
||||
return line.p2();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
VModelingShoulderPoint *VModelingShoulderPoint::Create(QSharedPointer<DialogShoulderPoint> &dialog,
|
||||
VDomDocument *doc, VContainer *data){
|
||||
QString formula = dialog->getFormula();
|
||||
|
@ -97,8 +77,8 @@ VModelingShoulderPoint *VModelingShoulderPoint::Create(const qint64 _id, const Q
|
|||
QString errorMsg;
|
||||
qreal result = cal.eval(formula, &errorMsg);
|
||||
if(errorMsg.isEmpty()){
|
||||
QPointF fPoint = VModelingShoulderPoint::FindPoint(firstPoint.toQPointF(), secondPoint.toQPointF(),
|
||||
shoulderPoint.toQPointF(), result*PrintDPI/25.4);
|
||||
QPointF fPoint = VToolShoulderPoint::FindPoint(firstPoint.toQPointF(), secondPoint.toQPointF(),
|
||||
shoulderPoint.toQPointF(), toPixel(result));
|
||||
qint64 id = _id;
|
||||
if(typeCreation == Tool::FromGui){
|
||||
id = data->AddModelingPoint(VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
|
||||
|
|
|
@ -28,33 +28,30 @@
|
|||
class VModelingShoulderPoint : public VModelingLinePoint{
|
||||
Q_OBJECT
|
||||
public:
|
||||
VModelingShoulderPoint(VDomDocument *doc, VContainer *data,
|
||||
const qint64 &id, const QString &typeLine,
|
||||
const QString &formula, const qint64 &p1Line,
|
||||
const qint64 &p2Line, const qint64 &pShoulder,
|
||||
Tool::Sources typeCreation,
|
||||
QGraphicsItem * parent = 0);
|
||||
virtual void setDialog();
|
||||
static QPointF FindPoint(const QPointF &p1Line, const QPointF &p2Line,
|
||||
const QPointF &pShoulder, const qreal &length);
|
||||
static VModelingShoulderPoint* Create(QSharedPointer<DialogShoulderPoint> &dialog,
|
||||
VDomDocument *doc, VContainer *data);
|
||||
static VModelingShoulderPoint* Create(const qint64 _id, const QString &formula, const qint64 &p1Line,
|
||||
const qint64 &p2Line, const qint64 &pShoulder,
|
||||
const QString &typeLine, const QString &pointName,
|
||||
const qreal &mx, const qreal &my, VDomDocument *doc,
|
||||
VContainer *data, const Document::Documents &parse,
|
||||
const Tool::Sources &typeCreation);
|
||||
VModelingShoulderPoint(VDomDocument *doc, VContainer *data,
|
||||
const qint64 &id, const QString &typeLine,
|
||||
const QString &formula, const qint64 &p1Line,
|
||||
const qint64 &p2Line, const qint64 &pShoulder,
|
||||
Tool::Sources typeCreation,
|
||||
QGraphicsItem * parent = 0);
|
||||
virtual void setDialog();
|
||||
static VModelingShoulderPoint* Create(QSharedPointer<DialogShoulderPoint> &dialog, VDomDocument *doc,
|
||||
VContainer *data);
|
||||
static VModelingShoulderPoint* Create(const qint64 _id, const QString &formula, const qint64 &p1Line,
|
||||
const qint64 &p2Line, const qint64 &pShoulder,
|
||||
const QString &typeLine, const QString &pointName, const qreal &mx,
|
||||
const qreal &my, VDomDocument *doc, VContainer *data,
|
||||
const Document::Documents &parse, const Tool::Sources &typeCreation);
|
||||
public slots:
|
||||
virtual void FullUpdateFromFile();
|
||||
virtual void FullUpdateFromGui(int result);
|
||||
virtual void FullUpdateFromFile();
|
||||
virtual void FullUpdateFromGui(int result);
|
||||
protected:
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
||||
virtual void AddToFile();
|
||||
virtual void RemoveReferens();
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
||||
virtual void AddToFile();
|
||||
virtual void RemoveReferens();
|
||||
private:
|
||||
qint64 p2Line;
|
||||
qint64 pShoulder;
|
||||
qint64 p2Line;
|
||||
qint64 pShoulder;
|
||||
QSharedPointer<DialogShoulderPoint> dialogShoulderPoint;
|
||||
};
|
||||
|
||||
|
|
|
@ -30,40 +30,38 @@
|
|||
class VModelingSplinePath:public VModelingTool, public QGraphicsPathItem{
|
||||
Q_OBJECT
|
||||
public:
|
||||
VModelingSplinePath(VDomDocument *doc, VContainer *data, qint64 id,
|
||||
Tool::Sources typeCreation,
|
||||
QGraphicsItem * parent = 0);
|
||||
virtual void setDialog();
|
||||
static VModelingSplinePath* Create(QSharedPointer<DialogSplinePath> &dialog,
|
||||
VDomDocument *doc, VContainer *data);
|
||||
static VModelingSplinePath* Create(const qint64 _id, const VSplinePath &path, VDomDocument *doc,
|
||||
VContainer *data, const Document::Documents &parse,
|
||||
Tool::Sources typeCreation);
|
||||
VModelingSplinePath(VDomDocument *doc, VContainer *data, qint64 id,
|
||||
Tool::Sources typeCreation, QGraphicsItem * parent = 0);
|
||||
virtual void setDialog();
|
||||
static VModelingSplinePath* Create(QSharedPointer<DialogSplinePath> &dialog, VDomDocument *doc,
|
||||
VContainer *data);
|
||||
static VModelingSplinePath* Create(const qint64 _id, const VSplinePath &path, VDomDocument *doc,
|
||||
VContainer *data, const Document::Documents &parse,
|
||||
Tool::Sources typeCreation);
|
||||
signals:
|
||||
void RefreshLine(const qint32 &indexSpline, SplinePoint::Position pos,
|
||||
const QPointF &controlPoint, const QPointF &splinePoint);
|
||||
void setEnabledPoint(bool enable);
|
||||
void RefreshLine(const qint32 &indexSpline, SplinePoint::Position pos,
|
||||
const QPointF &controlPoint, const QPointF &splinePoint);
|
||||
void setEnabledPoint(bool enable);
|
||||
public slots:
|
||||
virtual void FullUpdateFromFile();
|
||||
virtual void FullUpdateFromGui(int result);
|
||||
void ControlPointChangePosition(const qint32 &indexSpline,
|
||||
SplinePoint::Position position,
|
||||
const QPointF pos);
|
||||
virtual void FullUpdateFromFile();
|
||||
virtual void FullUpdateFromGui(int result);
|
||||
void ControlPointChangePosition(const qint32 &indexSpline,
|
||||
SplinePoint::Position position, const QPointF pos);
|
||||
protected:
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
||||
virtual void AddToFile();
|
||||
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
|
||||
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
|
||||
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
|
||||
virtual void RemoveReferens();
|
||||
virtual void contextMenuEvent ( QGraphicsSceneContextMenuEvent * event );
|
||||
virtual void AddToFile();
|
||||
virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event );
|
||||
virtual void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
|
||||
virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
|
||||
virtual void RemoveReferens();
|
||||
private:
|
||||
QSharedPointer<DialogSplinePath> dialogSplinePath;
|
||||
QVector<VControlPointSpline *> controlPoints;
|
||||
void RefreshGeometry();
|
||||
void AddPathPoint(QDomElement &domElement, const VSplinePoint &splPoint);
|
||||
void UpdatePathPoint(QDomNode& node, VSplinePath &path);
|
||||
void CorectControlPoints(const VSpline &spl, VSplinePath &splPath,
|
||||
const qint32 &indexSpline);
|
||||
void RefreshGeometry();
|
||||
void AddPathPoint(QDomElement &domElement, const VSplinePoint &splPoint);
|
||||
void UpdatePathPoint(QDomNode& node, VSplinePath &path);
|
||||
void CorectControlPoints(const VSpline &spl, VSplinePath &splPath,
|
||||
const qint32 &indexSpline);
|
||||
};
|
||||
|
||||
#endif // VMODELINGSPLINEPATH_H
|
||||
|
|
|
@ -51,6 +51,11 @@ protected:
|
|||
QAction *actionRemove = 0;
|
||||
if(showRemove){
|
||||
actionRemove = menu.addAction(tr("Delete"));
|
||||
if(_referens > 1){
|
||||
actionRemove->setEnabled(false);
|
||||
} else {
|
||||
actionRemove->setEnabled(true);
|
||||
}
|
||||
}
|
||||
QAction *selectedAction = menu.exec(event->screenPos());
|
||||
if(selectedAction == actionOption){
|
||||
|
|
Loading…
Reference in New Issue
Block a user