Refactoring.
--HG-- branch : develop
This commit is contained in:
parent
8f76443160
commit
f9f724fcab
|
@ -26,8 +26,8 @@ DialogSinglePoint::DialogSinglePoint(const VContainer *data, QWidget *parent) :
|
||||||
DialogTool(data, Draw::Calculation, parent), ui(new Ui::DialogSinglePoint), name(QString()),
|
DialogTool(data, Draw::Calculation, parent), ui(new Ui::DialogSinglePoint), name(QString()),
|
||||||
point(QPointF()){
|
point(QPointF()){
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
ui->doubleSpinBoxX->setRange(0,PaperSize/PrintDPI*25.4);
|
ui->doubleSpinBoxX->setRange(0,toMM(PaperSize));
|
||||||
ui->doubleSpinBoxY->setRange(0,PaperSize/PrintDPI*25.4);
|
ui->doubleSpinBoxY->setRange(0,toMM(PaperSize));
|
||||||
bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
|
bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
|
||||||
labelEditNamePoint = ui->labelEditName;
|
labelEditNamePoint = ui->labelEditName;
|
||||||
flagName = false;
|
flagName = false;
|
||||||
|
@ -40,18 +40,17 @@ DialogSinglePoint::DialogSinglePoint(const VContainer *data, QWidget *parent) :
|
||||||
|
|
||||||
void DialogSinglePoint::mousePress(QPointF scenePos){
|
void DialogSinglePoint::mousePress(QPointF scenePos){
|
||||||
if(isInitialized == false){
|
if(isInitialized == false){
|
||||||
ui->doubleSpinBoxX->setValue(scenePos.x()/PrintDPI*25.4);
|
ui->doubleSpinBoxX->setValue(toMM(scenePos.x()));
|
||||||
ui->doubleSpinBoxY->setValue(scenePos.y()/PrintDPI*25.4);
|
ui->doubleSpinBoxY->setValue(toMM(scenePos.y()));
|
||||||
this->show();
|
this->show();
|
||||||
} else {
|
} else {
|
||||||
ui->doubleSpinBoxX->setValue(scenePos.x()/PrintDPI*25.4);
|
ui->doubleSpinBoxX->setValue(toMM(scenePos.x()));
|
||||||
ui->doubleSpinBoxY->setValue(scenePos.y()/PrintDPI*25.4);
|
ui->doubleSpinBoxY->setValue(toMM(scenePos.y()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogSinglePoint::DialogAccepted(){
|
void DialogSinglePoint::DialogAccepted(){
|
||||||
point = QPointF(ui->doubleSpinBoxX->value()*PrintDPI/25.4,
|
point = QPointF(toPixel(ui->doubleSpinBoxX->value()), toPixel(ui->doubleSpinBoxY->value()));
|
||||||
ui->doubleSpinBoxY->value()*PrintDPI/25.4);
|
|
||||||
name = ui->lineEditName->text();
|
name = ui->lineEditName->text();
|
||||||
emit DialogClosed(QDialog::Accepted);
|
emit DialogClosed(QDialog::Accepted);
|
||||||
}
|
}
|
||||||
|
@ -61,8 +60,8 @@ void DialogSinglePoint::setData(const QString name, const QPointF point){
|
||||||
this->point = point;
|
this->point = point;
|
||||||
isInitialized = true;
|
isInitialized = true;
|
||||||
ui->lineEditName->setText(name);
|
ui->lineEditName->setText(name);
|
||||||
ui->doubleSpinBoxX->setValue(point.x()/PrintDPI*25.4);
|
ui->doubleSpinBoxX->setValue(toMM(point.x()));
|
||||||
ui->doubleSpinBoxY->setValue(point.y()/PrintDPI*25.4);
|
ui->doubleSpinBoxY->setValue(toMM(point.y()));
|
||||||
}
|
}
|
||||||
|
|
||||||
DialogSinglePoint::~DialogSinglePoint(){
|
DialogSinglePoint::~DialogSinglePoint(){
|
||||||
|
|
|
@ -151,12 +151,11 @@ void MainWindow::ActionNewDraw(){
|
||||||
comboBoxDraws->setCurrentIndex(index);
|
comboBoxDraws->setCurrentIndex(index);
|
||||||
currentDrawChanged( index );
|
currentDrawChanged( index );
|
||||||
}
|
}
|
||||||
connect(comboBoxDraws, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
connect(comboBoxDraws, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
||||||
this, &MainWindow::currentDrawChanged);
|
&MainWindow::currentDrawChanged);
|
||||||
data->ClearObject();
|
data->ClearObject();
|
||||||
//Create single point
|
//Create single point
|
||||||
qint64 id = data->AddPoint(VPointF((10+comboBoxDraws->count()*5)*PrintDPI/25.4, 10*PrintDPI/25.4, "А", 5,
|
qint64 id = data->AddPoint(VPointF(toPixel((10+comboBoxDraws->count()*5)), toPixel(10), "А", 5, 10));
|
||||||
10));
|
|
||||||
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);
|
||||||
|
@ -664,8 +663,8 @@ void MainWindow::currentDrawChanged( int index ){
|
||||||
|
|
||||||
void MainWindow::mouseMove(QPointF scenePos){
|
void MainWindow::mouseMove(QPointF scenePos){
|
||||||
QString string = QString("%1, %2")
|
QString string = QString("%1, %2")
|
||||||
.arg(static_cast<qint32>(scenePos.x()/PrintDPI*25.4))
|
.arg(static_cast<qint32>(toMM(scenePos.x())))
|
||||||
.arg(static_cast<qint32>(scenePos.y()/PrintDPI*25.4));
|
.arg(static_cast<qint32>(toMM(scenePos.y())));
|
||||||
mouseCoordinate->setText(string);
|
mouseCoordinate->setText(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ TableWindow::TableWindow(QWidget *parent) :
|
||||||
ui->statusBar->addWidget(numberDetal);
|
ui->statusBar->addWidget(numberDetal);
|
||||||
ui->statusBar->addWidget(colission);
|
ui->statusBar->addWidget(colission);
|
||||||
outItems = collidingItems = false;
|
outItems = collidingItems = false;
|
||||||
//sceneRect = QRectF(0, 0, 203*PrintDPI/25.4, 287*PrintDPI/25.4);
|
//sceneRect = QRectF(0, 0, toPixel(203), toPixel(287));
|
||||||
sceneRect = QRectF(0, 0, toPixel(823), toPixel(1171));
|
sceneRect = QRectF(0, 0, toPixel(823), toPixel(1171));
|
||||||
currentScene = new QGraphicsScene(sceneRect);
|
currentScene = new QGraphicsScene(sceneRect);
|
||||||
QBrush *brush = new QBrush();
|
QBrush *brush = new QBrush();
|
||||||
|
|
|
@ -90,7 +90,7 @@ void VToolBisector::Create(const qint64 _id, const QString &formula, const qint6
|
||||||
qreal result = cal.eval(formula, &errorMsg);
|
qreal result = cal.eval(formula, &errorMsg);
|
||||||
if(errorMsg.isEmpty()){
|
if(errorMsg.isEmpty()){
|
||||||
QPointF fPoint = VToolBisector::FindPoint(firstPoint.toQPointF(), secondPoint.toQPointF(),
|
QPointF fPoint = VToolBisector::FindPoint(firstPoint.toQPointF(), secondPoint.toQPointF(),
|
||||||
thirdPoint.toQPointF(), result*PrintDPI/25.4);
|
thirdPoint.toQPointF(), toPixel(result));
|
||||||
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));
|
||||||
|
@ -104,9 +104,8 @@ void VToolBisector::Create(const qint64 _id, const QString &formula, const qint6
|
||||||
}
|
}
|
||||||
VDrawTool::AddRecord(id, Tool::BisectorTool, doc);
|
VDrawTool::AddRecord(id, Tool::BisectorTool, doc);
|
||||||
if(parse == Document::FullParse){
|
if(parse == Document::FullParse){
|
||||||
VToolBisector *point = new VToolBisector(doc, data, id, typeLine, formula,
|
VToolBisector *point = new VToolBisector(doc, data, id, typeLine, formula, firstPointId, secondPointId,
|
||||||
firstPointId, secondPointId, thirdPointId,
|
thirdPointId, typeCreation);
|
||||||
typeCreation);
|
|
||||||
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);
|
||||||
|
@ -163,8 +162,8 @@ void VToolBisector::AddToFile(){
|
||||||
AddAttribute(domElement, "id", id);
|
AddAttribute(domElement, "id", id);
|
||||||
AddAttribute(domElement, "type", "bisector");
|
AddAttribute(domElement, "type", "bisector");
|
||||||
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);
|
||||||
|
|
|
@ -53,7 +53,7 @@ QPointF VToolShoulderPoint::FindPoint(const QPointF &p1Line, const QPointF &p2Li
|
||||||
QLineF line = QLineF(p1Line, p2Line);
|
QLineF line = QLineF(p1Line, p2Line);
|
||||||
qreal dist = line.length();
|
qreal dist = line.length();
|
||||||
if(dist>length){
|
if(dist>length){
|
||||||
qDebug()<<"A3П2="<<length/PrintDPI*25.4<<"А30П ="<<dist/PrintDPI*25.4;
|
qDebug()<<"A3П2="<<toMM(length)<<"А30П ="<<toMM(dist);
|
||||||
throw"Не можу знайти точку плеча. Довжина А3П2 < А3П.";
|
throw"Не можу знайти точку плеча. Довжина А3П2 < А3П.";
|
||||||
}
|
}
|
||||||
if(dist==length){
|
if(dist==length){
|
||||||
|
@ -95,7 +95,7 @@ void VToolShoulderPoint::Create(const qint64 _id, const QString &formula, const
|
||||||
qreal result = cal.eval(formula, &errorMsg);
|
qreal result = cal.eval(formula, &errorMsg);
|
||||||
if(errorMsg.isEmpty()){
|
if(errorMsg.isEmpty()){
|
||||||
QPointF fPoint = VToolShoulderPoint::FindPoint(firstPoint.toQPointF(), secondPoint.toQPointF(),
|
QPointF fPoint = VToolShoulderPoint::FindPoint(firstPoint.toQPointF(), secondPoint.toQPointF(),
|
||||||
shoulderPoint.toQPointF(), result*PrintDPI/25.4);
|
shoulderPoint.toQPointF(), toPixel(result));
|
||||||
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));
|
||||||
|
|
|
@ -25,14 +25,10 @@
|
||||||
VModelingArc::VModelingArc(VDomDocument *doc, VContainer *data, qint64 id, Tool::Sources typeCreation,
|
VModelingArc::VModelingArc(VDomDocument *doc, VContainer *data, qint64 id, Tool::Sources typeCreation,
|
||||||
QGraphicsItem *parent):VModelingTool(doc, data, id), QGraphicsPathItem(parent),
|
QGraphicsItem *parent):VModelingTool(doc, data, id), QGraphicsPathItem(parent),
|
||||||
dialogArc(QSharedPointer<DialogArc>()){
|
dialogArc(QSharedPointer<DialogArc>()){
|
||||||
VArc arc = data->GetModelingArc(id);
|
this->setPen(QPen(baseColor, widthHairLine));
|
||||||
QPainterPath path;
|
|
||||||
path.addPath(arc.GetPath());
|
|
||||||
path.setFillRule( Qt::WindingFill );
|
|
||||||
this->setPath(path);
|
|
||||||
this->setPen(QPen(Qt::black, widthHairLine));
|
|
||||||
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
|
||||||
this->setAcceptHoverEvents(true);
|
this->setAcceptHoverEvents(true);
|
||||||
|
RefreshGeometry();
|
||||||
|
|
||||||
if(typeCreation == Tool::FromGui){
|
if(typeCreation == Tool::FromGui){
|
||||||
AddToFile();
|
AddToFile();
|
||||||
|
@ -68,7 +64,7 @@ VModelingArc* VModelingArc::Create(const qint64 _id, const qint64 ¢er, const
|
||||||
QString errorMsg;
|
QString errorMsg;
|
||||||
qreal result = cal.eval(radius, &errorMsg);
|
qreal result = cal.eval(radius, &errorMsg);
|
||||||
if(errorMsg.isEmpty()){
|
if(errorMsg.isEmpty()){
|
||||||
calcRadius = result*PrintDPI/25.4;
|
calcRadius = toPixel(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
errorMsg.clear();
|
errorMsg.clear();
|
||||||
|
|
|
@ -78,7 +78,7 @@ VModelingBisector *VModelingBisector::Create(const qint64 _id, const QString &fo
|
||||||
qreal result = cal.eval(formula, &errorMsg);
|
qreal result = cal.eval(formula, &errorMsg);
|
||||||
if(errorMsg.isEmpty()){
|
if(errorMsg.isEmpty()){
|
||||||
QPointF fPoint = VToolBisector::FindPoint(firstPoint.toQPointF(), secondPoint.toQPointF(),
|
QPointF fPoint = VToolBisector::FindPoint(firstPoint.toQPointF(), secondPoint.toQPointF(),
|
||||||
thirdPoint.toQPointF(), result*PrintDPI/25.4);
|
thirdPoint.toQPointF(), toPixel(result));
|
||||||
qint64 id = _id;
|
qint64 id = _id;
|
||||||
if(typeCreation == Tool::FromGui){
|
if(typeCreation == Tool::FromGui){
|
||||||
id = data->AddModelingPoint(VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
|
id = data->AddModelingPoint(VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
|
||||||
|
@ -140,8 +140,8 @@ void VModelingBisector::AddToFile(){
|
||||||
AddAttribute(domElement, "id", id);
|
AddAttribute(domElement, "id", id);
|
||||||
AddAttribute(domElement, "type", "bisector");
|
AddAttribute(domElement, "type", "bisector");
|
||||||
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);
|
||||||
|
|
|
@ -135,8 +135,8 @@ void VModelingLineIntersect::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);
|
||||||
|
|
|
@ -135,8 +135,8 @@ void VModelingNormal::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);
|
||||||
|
|
|
@ -134,8 +134,8 @@ void VModelingPointOfContact::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);
|
||||||
|
|
|
@ -140,8 +140,8 @@ void VModelingShoulderPoint::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);
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
VControlPointSpline::VControlPointSpline(const qint32 &indexSpline, SplinePoint::Position position,
|
VControlPointSpline::VControlPointSpline(const qint32 &indexSpline, SplinePoint::Position position,
|
||||||
const QPointF &controlPoint, const QPointF &splinePoint,
|
const QPointF &controlPoint, const QPointF &splinePoint,
|
||||||
QGraphicsItem *parent):QGraphicsEllipseItem(parent),
|
QGraphicsItem *parent):QGraphicsEllipseItem(parent),
|
||||||
radius(1.5*PrintDPI/25.4), controlLine(0), indexSpline(indexSpline), position(position){
|
radius(toPixel(1.5)), controlLine(0), indexSpline(indexSpline), position(position){
|
||||||
//create circle
|
//create circle
|
||||||
QRectF rec = QRectF(0, 0, radius*2, radius*2);
|
QRectF rec = QRectF(0, 0, radius*2, radius*2);
|
||||||
rec.translate(-rec.center().x(), -rec.center().y());
|
rec.translate(-rec.center().x(), -rec.center().y());
|
||||||
|
|
Loading…
Reference in New Issue
Block a user