Refactoring.

--HG--
branch : develop
This commit is contained in:
dismine 2013-10-28 19:27:31 +02:00
parent 8f76443160
commit f9f724fcab
12 changed files with 37 additions and 44 deletions

View File

@ -26,8 +26,8 @@ DialogSinglePoint::DialogSinglePoint(const VContainer *data, QWidget *parent) :
DialogTool(data, Draw::Calculation, parent), ui(new Ui::DialogSinglePoint), name(QString()),
point(QPointF()){
ui->setupUi(this);
ui->doubleSpinBoxX->setRange(0,PaperSize/PrintDPI*25.4);
ui->doubleSpinBoxY->setRange(0,PaperSize/PrintDPI*25.4);
ui->doubleSpinBoxX->setRange(0,toMM(PaperSize));
ui->doubleSpinBoxY->setRange(0,toMM(PaperSize));
bOk = ui->buttonBox->button(QDialogButtonBox::Ok);
labelEditNamePoint = ui->labelEditName;
flagName = false;
@ -40,18 +40,17 @@ DialogSinglePoint::DialogSinglePoint(const VContainer *data, QWidget *parent) :
void DialogSinglePoint::mousePress(QPointF scenePos){
if(isInitialized == false){
ui->doubleSpinBoxX->setValue(scenePos.x()/PrintDPI*25.4);
ui->doubleSpinBoxY->setValue(scenePos.y()/PrintDPI*25.4);
ui->doubleSpinBoxX->setValue(toMM(scenePos.x()));
ui->doubleSpinBoxY->setValue(toMM(scenePos.y()));
this->show();
} else {
ui->doubleSpinBoxX->setValue(scenePos.x()/PrintDPI*25.4);
ui->doubleSpinBoxY->setValue(scenePos.y()/PrintDPI*25.4);
ui->doubleSpinBoxX->setValue(toMM(scenePos.x()));
ui->doubleSpinBoxY->setValue(toMM(scenePos.y()));
}
}
void DialogSinglePoint::DialogAccepted(){
point = QPointF(ui->doubleSpinBoxX->value()*PrintDPI/25.4,
ui->doubleSpinBoxY->value()*PrintDPI/25.4);
point = QPointF(toPixel(ui->doubleSpinBoxX->value()), toPixel(ui->doubleSpinBoxY->value()));
name = ui->lineEditName->text();
emit DialogClosed(QDialog::Accepted);
}
@ -61,8 +60,8 @@ void DialogSinglePoint::setData(const QString name, const QPointF point){
this->point = point;
isInitialized = true;
ui->lineEditName->setText(name);
ui->doubleSpinBoxX->setValue(point.x()/PrintDPI*25.4);
ui->doubleSpinBoxY->setValue(point.y()/PrintDPI*25.4);
ui->doubleSpinBoxX->setValue(toMM(point.x()));
ui->doubleSpinBoxY->setValue(toMM(point.y()));
}
DialogSinglePoint::~DialogSinglePoint(){

View File

@ -151,12 +151,11 @@ void MainWindow::ActionNewDraw(){
comboBoxDraws->setCurrentIndex(index);
currentDrawChanged( index );
}
connect(comboBoxDraws, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, &MainWindow::currentDrawChanged);
connect(comboBoxDraws, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&MainWindow::currentDrawChanged);
data->ClearObject();
//Create single point
qint64 id = data->AddPoint(VPointF((10+comboBoxDraws->count()*5)*PrintDPI/25.4, 10*PrintDPI/25.4, "А", 5,
10));
qint64 id = data->AddPoint(VPointF(toPixel((10+comboBoxDraws->count()*5)), toPixel(10), "А", 5, 10));
VToolSinglePoint *spoint = new VToolSinglePoint(doc, data, id, Tool::FromGui);
sceneDraw->addItem(spoint);
connect(spoint, &VToolPoint::ChoosedTool, sceneDraw, &VMainGraphicsScene::ChoosedItem);
@ -664,8 +663,8 @@ void MainWindow::currentDrawChanged( int index ){
void MainWindow::mouseMove(QPointF scenePos){
QString string = QString("%1, %2")
.arg(static_cast<qint32>(scenePos.x()/PrintDPI*25.4))
.arg(static_cast<qint32>(scenePos.y()/PrintDPI*25.4));
.arg(static_cast<qint32>(toMM(scenePos.x())))
.arg(static_cast<qint32>(toMM(scenePos.y())));
mouseCoordinate->setText(string);
}

View File

@ -35,7 +35,7 @@ TableWindow::TableWindow(QWidget *parent) :
ui->statusBar->addWidget(numberDetal);
ui->statusBar->addWidget(colission);
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));
currentScene = new QGraphicsScene(sceneRect);
QBrush *brush = new QBrush();

View File

@ -90,7 +90,7 @@ void VToolBisector::Create(const qint64 _id, const QString &formula, const qint6
qreal result = cal.eval(formula, &errorMsg);
if(errorMsg.isEmpty()){
QPointF fPoint = VToolBisector::FindPoint(firstPoint.toQPointF(), secondPoint.toQPointF(),
thirdPoint.toQPointF(), result*PrintDPI/25.4);
thirdPoint.toQPointF(), toPixel(result));
qint64 id = _id;
if(typeCreation == Tool::FromGui){
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);
if(parse == Document::FullParse){
VToolBisector *point = new VToolBisector(doc, data, id, typeLine, formula,
firstPointId, secondPointId, thirdPointId,
typeCreation);
VToolBisector *point = new VToolBisector(doc, data, id, typeLine, formula, firstPointId, secondPointId,
thirdPointId, typeCreation);
scene->addItem(point);
connect(point, &VToolBisector::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
connect(point, &VToolBisector::RemoveTool, scene, &VMainGraphicsScene::RemoveTool);
@ -163,8 +162,8 @@ void VToolBisector::AddToFile(){
AddAttribute(domElement, "id", id);
AddAttribute(domElement, "type", "bisector");
AddAttribute(domElement, "name", point.name());
AddAttribute(domElement, "mx", point.mx()/PrintDPI*25.4);
AddAttribute(domElement, "my", point.my()/PrintDPI*25.4);
AddAttribute(domElement, "mx", toMM(point.mx()));
AddAttribute(domElement, "my", toMM(point.my()));
AddAttribute(domElement, "typeLine", typeLine);
AddAttribute(domElement, "length", formula);

View File

@ -53,7 +53,7 @@ QPointF VToolShoulderPoint::FindPoint(const QPointF &p1Line, const QPointF &p2Li
QLineF line = QLineF(p1Line, p2Line);
qreal dist = line.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П.";
}
if(dist==length){
@ -95,7 +95,7 @@ void VToolShoulderPoint::Create(const qint64 _id, const QString &formula, const
qreal result = cal.eval(formula, &errorMsg);
if(errorMsg.isEmpty()){
QPointF fPoint = VToolShoulderPoint::FindPoint(firstPoint.toQPointF(), secondPoint.toQPointF(),
shoulderPoint.toQPointF(), result*PrintDPI/25.4);
shoulderPoint.toQPointF(), toPixel(result));
qint64 id = _id;
if(typeCreation == Tool::FromGui){
id = data->AddPoint(VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));

View File

@ -25,14 +25,10 @@
VModelingArc::VModelingArc(VDomDocument *doc, VContainer *data, qint64 id, Tool::Sources typeCreation,
QGraphicsItem *parent):VModelingTool(doc, data, id), QGraphicsPathItem(parent),
dialogArc(QSharedPointer<DialogArc>()){
VArc arc = data->GetModelingArc(id);
QPainterPath path;
path.addPath(arc.GetPath());
path.setFillRule( Qt::WindingFill );
this->setPath(path);
this->setPen(QPen(Qt::black, widthHairLine));
this->setPen(QPen(baseColor, widthHairLine));
this->setFlag(QGraphicsItem::ItemIsSelectable, true);
this->setAcceptHoverEvents(true);
RefreshGeometry();
if(typeCreation == Tool::FromGui){
AddToFile();
@ -68,7 +64,7 @@ VModelingArc* VModelingArc::Create(const qint64 _id, const qint64 &center, const
QString errorMsg;
qreal result = cal.eval(radius, &errorMsg);
if(errorMsg.isEmpty()){
calcRadius = result*PrintDPI/25.4;
calcRadius = toPixel(result);
}
errorMsg.clear();

View File

@ -78,7 +78,7 @@ VModelingBisector *VModelingBisector::Create(const qint64 _id, const QString &fo
qreal result = cal.eval(formula, &errorMsg);
if(errorMsg.isEmpty()){
QPointF fPoint = VToolBisector::FindPoint(firstPoint.toQPointF(), secondPoint.toQPointF(),
thirdPoint.toQPointF(), result*PrintDPI/25.4);
thirdPoint.toQPointF(), toPixel(result));
qint64 id = _id;
if(typeCreation == Tool::FromGui){
id = data->AddModelingPoint(VPointF(fPoint.x(), fPoint.y(), pointName, mx, my));
@ -140,8 +140,8 @@ void VModelingBisector::AddToFile(){
AddAttribute(domElement, "id", id);
AddAttribute(domElement, "type", "bisector");
AddAttribute(domElement, "name", point.name());
AddAttribute(domElement, "mx", point.mx()/PrintDPI*25.4);
AddAttribute(domElement, "my", point.my()/PrintDPI*25.4);
AddAttribute(domElement, "mx", toMM(point.mx()));
AddAttribute(domElement, "my", toMM(point.my()));
AddAttribute(domElement, "typeLine", typeLine);
AddAttribute(domElement, "length", formula);

View File

@ -135,8 +135,8 @@ void VModelingLineIntersect::AddToFile(){
AddAttribute(domElement, "id", id);
AddAttribute(domElement, "type", "lineIntersect");
AddAttribute(domElement, "name", point.name());
AddAttribute(domElement, "mx", point.mx()/PrintDPI*25.4);
AddAttribute(domElement, "my", point.my()/PrintDPI*25.4);
AddAttribute(domElement, "mx", toMM(point.mx()));
AddAttribute(domElement, "my", toMM(point.my()));
AddAttribute(domElement, "p1Line1", p1Line1);
AddAttribute(domElement, "p2Line1", p2Line1);

View File

@ -135,8 +135,8 @@ void VModelingNormal::AddToFile(){
AddAttribute(domElement, "id", id);
AddAttribute(domElement, "type", "normal");
AddAttribute(domElement, "name", point.name());
AddAttribute(domElement, "mx", point.mx()/PrintDPI*25.4);
AddAttribute(domElement, "my", point.my()/PrintDPI*25.4);
AddAttribute(domElement, "mx", toMM(point.mx()));
AddAttribute(domElement, "my", toMM(point.my()));
AddAttribute(domElement, "typeLine", typeLine);
AddAttribute(domElement, "length", formula);

View File

@ -134,8 +134,8 @@ void VModelingPointOfContact::AddToFile(){
AddAttribute(domElement, "id", id);
AddAttribute(domElement, "type", "pointOfContact");
AddAttribute(domElement, "name", point.name());
AddAttribute(domElement, "mx", point.mx()/PrintDPI*25.4);
AddAttribute(domElement, "my", point.my()/PrintDPI*25.4);
AddAttribute(domElement, "mx", toMM(point.mx()));
AddAttribute(domElement, "my", toMM(point.my()));
AddAttribute(domElement, "radius", radius);
AddAttribute(domElement, "center", center);

View File

@ -140,8 +140,8 @@ void VModelingShoulderPoint::AddToFile(){
AddAttribute(domElement, "id", id);
AddAttribute(domElement, "type", "shoulder");
AddAttribute(domElement, "name", point.name());
AddAttribute(domElement, "mx", point.mx()/PrintDPI*25.4);
AddAttribute(domElement, "my", point.my()/PrintDPI*25.4);
AddAttribute(domElement, "mx", toMM(point.mx()));
AddAttribute(domElement, "my", toMM(point.my()));
AddAttribute(domElement, "typeLine", typeLine);
AddAttribute(domElement, "length", formula);

View File

@ -24,7 +24,7 @@
VControlPointSpline::VControlPointSpline(const qint32 &indexSpline, SplinePoint::Position position,
const QPointF &controlPoint, const QPointF &splinePoint,
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
QRectF rec = QRectF(0, 0, radius*2, radius*2);
rec.translate(-rec.center().x(), -rec.center().y());