2013-09-18 21:16:19 +02:00
|
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** Copyright (C) 2013 Valentina project All Rights Reserved.
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Valentina.
|
|
|
|
|
**
|
|
|
|
|
** Tox is free software: you can redistribute it and/or modify
|
|
|
|
|
** it under the terms of the GNU General Public License as published by
|
|
|
|
|
** the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
** (at your option) any later version.
|
|
|
|
|
**
|
|
|
|
|
** Tox is distributed in the hope that it will be useful,
|
|
|
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
** GNU General Public License for more details.
|
|
|
|
|
**
|
|
|
|
|
** You should have received a copy of the GNU General Public License
|
|
|
|
|
** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2013-06-20 16:09:50 +02:00
|
|
|
|
#include "mainwindow.h"
|
|
|
|
|
#include "ui_mainwindow.h"
|
2013-07-03 14:29:26 +02:00
|
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QSpinBox>
|
|
|
|
|
#include <QScrollBar>
|
|
|
|
|
#include <QShowEvent>
|
2013-07-13 12:51:31 +02:00
|
|
|
|
#include <QDebug>
|
|
|
|
|
#include <QInputDialog>
|
|
|
|
|
#include <QFileDialog>
|
2013-07-25 14:00:51 +02:00
|
|
|
|
#include <QDebug>
|
2013-08-05 10:37:56 +02:00
|
|
|
|
#include "geometry/vspline.h"
|
2013-09-23 14:08:06 +02:00
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
#include "exception/vexceptionobjecterror.h"
|
|
|
|
|
#include "exception/vexceptionconversionerror.h"
|
|
|
|
|
#include "exception/vexceptionemptyparameter.h"
|
|
|
|
|
#include "exception/vexceptionwrongparameterid.h"
|
2013-06-20 16:09:50 +02:00
|
|
|
|
|
|
|
|
|
MainWindow::MainWindow(QWidget *parent) :
|
2013-09-27 11:17:00 +02:00
|
|
|
|
QMainWindow(parent), ui(new Ui::MainWindow), tool(Tool::ArrowTool), currentScene(0), sceneDraw(0),
|
2013-08-28 10:55:11 +02:00
|
|
|
|
sceneDetails(0), mouseCoordinate(0), helpLabel(0), view(0), isInitialized(false), dialogTable(0),
|
2013-08-20 12:26:02 +02:00
|
|
|
|
dialogEndLine(QSharedPointer<DialogEndLine>()), dialogLine(QSharedPointer<DialogLine>()),
|
|
|
|
|
dialogAlongLine(QSharedPointer<DialogAlongLine>()),
|
|
|
|
|
dialogShoulderPoint(QSharedPointer<DialogShoulderPoint>()), dialogNormal(QSharedPointer<DialogNormal>()),
|
|
|
|
|
dialogBisector(QSharedPointer<DialogBisector>()),
|
|
|
|
|
dialogLineIntersect(QSharedPointer<DialogLineIntersect>()),
|
|
|
|
|
dialogSpline(QSharedPointer<DialogSpline>()),
|
|
|
|
|
dialogArc(QSharedPointer<DialogArc>()), dialogSplinePath(QSharedPointer<DialogSplinePath>()),
|
2013-08-28 10:55:11 +02:00
|
|
|
|
dialogPointOfContact(QSharedPointer<DialogPointOfContact>()), dialogDetail(QSharedPointer<DialogDetail>()),
|
|
|
|
|
dialogHistory(0), doc(0), data(0), comboBoxDraws(0), fileName(QString()), changeInFile(false),
|
|
|
|
|
mode(Draw::Calculation){
|
2013-06-20 16:09:50 +02:00
|
|
|
|
ui->setupUi(this);
|
2013-07-03 14:29:26 +02:00
|
|
|
|
ToolBarOption();
|
|
|
|
|
ToolBarDraws();
|
2013-07-13 12:51:31 +02:00
|
|
|
|
QRectF sceneRect = QRectF(0, 0, PaperSize, PaperSize);
|
2013-08-28 10:55:11 +02:00
|
|
|
|
sceneDraw = new VMainGraphicsScene(sceneRect);
|
|
|
|
|
currentScene = sceneDraw;
|
|
|
|
|
connect(sceneDraw, &VMainGraphicsScene::mouseMove, this, &MainWindow::mouseMove);
|
|
|
|
|
sceneDetails = new VMainGraphicsScene(sceneRect);
|
|
|
|
|
connect(sceneDetails, &VMainGraphicsScene::mouseMove, this, &MainWindow::mouseMove);
|
2013-08-13 18:48:36 +02:00
|
|
|
|
view = new VMainGraphicsView();
|
|
|
|
|
ui->LayoutView->addWidget(view);
|
2013-08-28 10:55:11 +02:00
|
|
|
|
view->setScene(currentScene);
|
2013-08-13 18:48:36 +02:00
|
|
|
|
QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
|
|
|
|
policy.setHorizontalStretch(12);
|
|
|
|
|
view->setSizePolicy(policy);
|
2013-07-03 14:29:26 +02:00
|
|
|
|
helpLabel = new QLabel("Створіть новий файл для початку роботи.");
|
|
|
|
|
ui->statusBar->addWidget(helpLabel);
|
|
|
|
|
|
2013-07-25 14:00:51 +02:00
|
|
|
|
connect(ui->actionArrowTool, &QAction::triggered, this, &MainWindow::ActionAroowTool);
|
|
|
|
|
connect(ui->actionDraw, &QAction::triggered, this, &MainWindow::ActionDraw);
|
|
|
|
|
connect(ui->actionDetails, &QAction::triggered, this, &MainWindow::ActionDetails);
|
|
|
|
|
connect(ui->actionNewDraw, &QAction::triggered, this, &MainWindow::ActionNewDraw);
|
|
|
|
|
connect(ui->actionOptionDraw, &QAction::triggered, this, &MainWindow::OptionDraw);
|
|
|
|
|
connect(ui->actionSaveAs, &QAction::triggered, this, &MainWindow::ActionSaveAs);
|
|
|
|
|
connect(ui->actionSave, &QAction::triggered, this, &MainWindow::ActionSave);
|
|
|
|
|
connect(ui->actionOpen, &QAction::triggered, this, &MainWindow::ActionOpen);
|
|
|
|
|
connect(ui->actionNew, &QAction::triggered, this, &MainWindow::ActionNew);
|
|
|
|
|
connect(ui->actionTable, &QAction::triggered, this, &MainWindow::ActionTable);
|
2013-08-15 22:39:00 +02:00
|
|
|
|
connect(ui->toolButtonEndLine, &QToolButton::clicked, this, &MainWindow::ToolEndLine);
|
|
|
|
|
connect(ui->toolButtonLine, &QToolButton::clicked, this, &MainWindow::ToolLine);
|
|
|
|
|
connect(ui->toolButtonAlongLine, &QToolButton::clicked, this, &MainWindow::ToolAlongLine);
|
|
|
|
|
connect(ui->toolButtonShoulderPoint, &QToolButton::clicked, this, &MainWindow::ToolShoulderPoint);
|
|
|
|
|
connect(ui->toolButtonNormal, &QToolButton::clicked, this, &MainWindow::ToolNormal);
|
|
|
|
|
connect(ui->toolButtonBisector, &QToolButton::clicked, this, &MainWindow::ToolBisector);
|
|
|
|
|
connect(ui->toolButtonLineIntersect, &QToolButton::clicked, this, &MainWindow::ToolLineIntersect);
|
|
|
|
|
connect(ui->toolButtonSpline, &QToolButton::clicked, this, &MainWindow::ToolSpline);
|
|
|
|
|
connect(ui->toolButtonArc, &QToolButton::clicked, this, &MainWindow::ToolArc);
|
|
|
|
|
connect(ui->toolButtonSplinePath, &QToolButton::clicked, this, &MainWindow::ToolSplinePath);
|
2013-08-21 10:03:53 +02:00
|
|
|
|
connect(ui->toolButtonPointOfContact, &QToolButton::clicked, this, &MainWindow::ToolPointOfContact);
|
2013-08-28 10:55:11 +02:00
|
|
|
|
connect(ui->toolButtonNewDetail, &QToolButton::clicked, this, &MainWindow::ToolDetail);
|
2013-07-13 12:51:31 +02:00
|
|
|
|
|
|
|
|
|
data = new VContainer;
|
|
|
|
|
|
2013-08-29 12:31:50 +02:00
|
|
|
|
doc = new VDomDocument(data, comboBoxDraws, &mode);
|
2013-07-13 12:51:31 +02:00
|
|
|
|
doc->CreateEmptyFile();
|
|
|
|
|
connect(doc, &VDomDocument::haveChange, this, &MainWindow::haveChange);
|
|
|
|
|
|
|
|
|
|
fileName.clear();
|
|
|
|
|
changeInFile = false;
|
2013-07-25 14:00:51 +02:00
|
|
|
|
|
2013-07-13 12:51:31 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-07-25 14:00:51 +02:00
|
|
|
|
void MainWindow::ActionNewDraw(){
|
2013-07-13 12:51:31 +02:00
|
|
|
|
QString nameDraw;
|
|
|
|
|
bool bOk;
|
|
|
|
|
qint32 index;
|
2013-09-18 18:52:49 +02:00
|
|
|
|
QString nDraw = QString(tr("Drawing %1")).arg(comboBoxDraws->count()+1);
|
2013-07-13 12:51:31 +02:00
|
|
|
|
QInputDialog *dlg = new QInputDialog(this);
|
|
|
|
|
dlg->setInputMode( QInputDialog::TextInput );
|
2013-09-18 18:52:49 +02:00
|
|
|
|
dlg->setLabelText(tr("Drawing:"));
|
2013-07-13 12:51:31 +02:00
|
|
|
|
dlg->setTextEchoMode(QLineEdit::Normal);
|
2013-09-18 18:52:49 +02:00
|
|
|
|
dlg->setWindowTitle(tr("Enter a name for the drawing."));
|
2013-07-13 12:51:31 +02:00
|
|
|
|
dlg->resize(300,100);
|
|
|
|
|
dlg->setTextValue(nDraw);
|
|
|
|
|
while(1){
|
|
|
|
|
bOk = dlg->exec();
|
|
|
|
|
nameDraw = dlg->textValue();
|
|
|
|
|
if(!bOk || nameDraw.isEmpty()){
|
|
|
|
|
delete dlg;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
index = comboBoxDraws->findText(nameDraw);
|
|
|
|
|
if(index != -1){//we already have this name
|
2013-09-18 18:52:49 +02:00
|
|
|
|
qCritical()<<tr("Error. Drawing of same name already exists.");
|
2013-07-13 12:51:31 +02:00
|
|
|
|
} else {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
delete dlg;
|
|
|
|
|
bOk = doc->appendDraw(nameDraw);
|
|
|
|
|
if(bOk == false){
|
2013-09-18 18:52:49 +02:00
|
|
|
|
qCritical()<<tr("Error creating drawing with the name")<<nameDraw<<".";
|
|
|
|
|
return;
|
2013-07-13 12:51:31 +02:00
|
|
|
|
}
|
2013-08-15 22:39:00 +02:00
|
|
|
|
disconnect(comboBoxDraws, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
|
|
|
|
this, &MainWindow::currentDrawChanged);
|
|
|
|
|
comboBoxDraws->addItem(nameDraw);
|
2013-07-13 12:51:31 +02:00
|
|
|
|
index = comboBoxDraws->findText(nameDraw);
|
|
|
|
|
if ( index != -1 ) { // -1 for not found
|
|
|
|
|
comboBoxDraws->setCurrentIndex(index);
|
2013-08-15 22:39:00 +02:00
|
|
|
|
currentDrawChanged( index );
|
2013-07-13 12:51:31 +02:00
|
|
|
|
}
|
2013-08-15 22:39:00 +02:00
|
|
|
|
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));
|
|
|
|
|
VToolSinglePoint *spoint = new VToolSinglePoint(doc, data, id, Tool::FromGui);
|
2013-08-28 10:55:11 +02:00
|
|
|
|
sceneDraw->addItem(spoint);
|
|
|
|
|
connect(spoint, &VToolPoint::ChoosedTool, sceneDraw, &VMainGraphicsScene::ChoosedItem);
|
2013-10-04 13:32:42 +02:00
|
|
|
|
QHash<qint64, VDataTool*>* tools = doc->getTools();
|
2013-08-15 22:39:00 +02:00
|
|
|
|
tools->insert(id, spoint);
|
2013-09-27 11:17:00 +02:00
|
|
|
|
VDrawTool::AddRecord(id, Tool::SinglePointTool, doc);
|
2013-08-15 22:39:00 +02:00
|
|
|
|
SetEnableTool(true);
|
2013-07-17 13:38:11 +02:00
|
|
|
|
SetEnableWidgets(true);
|
2013-09-26 15:47:46 +02:00
|
|
|
|
changeInFile = true;
|
2013-07-13 12:51:31 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-07-25 14:00:51 +02:00
|
|
|
|
void MainWindow::OptionDraw(){
|
2013-07-13 12:51:31 +02:00
|
|
|
|
QString nameDraw;
|
|
|
|
|
bool bOk;
|
|
|
|
|
qint32 index;
|
|
|
|
|
QString nDraw = doc->GetNameActivDraw();
|
|
|
|
|
QInputDialog *dlg = new QInputDialog(this);
|
|
|
|
|
dlg->setInputMode( QInputDialog::TextInput );
|
2013-09-18 18:52:49 +02:00
|
|
|
|
dlg->setLabelText(tr("Drawing:"));
|
2013-07-13 12:51:31 +02:00
|
|
|
|
dlg->setTextEchoMode(QLineEdit::Normal);
|
2013-09-18 18:52:49 +02:00
|
|
|
|
dlg->setWindowTitle(tr("Enter a new name for the drawing."));
|
2013-07-13 12:51:31 +02:00
|
|
|
|
dlg->resize(300,100);
|
|
|
|
|
dlg->setTextValue(nDraw);
|
|
|
|
|
while(1){
|
|
|
|
|
bOk = dlg->exec();
|
|
|
|
|
nameDraw = dlg->textValue();
|
|
|
|
|
if(!bOk || nameDraw.isEmpty()){
|
|
|
|
|
delete dlg;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
index = comboBoxDraws->findText(nameDraw);
|
|
|
|
|
if(index != -1){//we already have this name
|
2013-09-18 18:52:49 +02:00
|
|
|
|
qCritical()<<tr("Error. Drawing of same name already exists.");
|
2013-07-13 12:51:31 +02:00
|
|
|
|
} else {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
delete dlg;
|
|
|
|
|
index = comboBoxDraws->findText(doc->GetNameActivDraw());
|
|
|
|
|
doc->SetNameDraw(nameDraw);
|
|
|
|
|
comboBoxDraws->setItemText(index, nameDraw);
|
2013-07-03 14:29:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-08-13 18:48:36 +02:00
|
|
|
|
template <typename Dialog, typename Func>
|
2013-09-27 11:17:00 +02:00
|
|
|
|
void MainWindow::SetToolButton(bool checked, Tool::Tools t, const QString &cursor,
|
2013-08-13 18:48:36 +02:00
|
|
|
|
QSharedPointer<Dialog> &dialog, Func closeDialogSlot){
|
|
|
|
|
if(checked){
|
|
|
|
|
CanselTool();
|
|
|
|
|
tool = t;
|
|
|
|
|
QPixmap pixmap(cursor);
|
|
|
|
|
QCursor cur(pixmap, 2, 3);
|
|
|
|
|
view->setCursor(cur);
|
|
|
|
|
helpLabel->setText("Виберіть точки.");
|
2013-09-10 14:29:06 +02:00
|
|
|
|
dialog = QSharedPointer<Dialog>(new Dialog(data, mode));
|
2013-08-28 10:55:11 +02:00
|
|
|
|
connect(currentScene, &VMainGraphicsScene::ChoosedObject, dialog.data(), &Dialog::ChoosedObject);
|
2013-08-13 18:48:36 +02:00
|
|
|
|
connect(dialog.data(), &Dialog::DialogClosed, this, closeDialogSlot);
|
|
|
|
|
connect(doc, &VDomDocument::FullUpdateFromFile, dialog.data(), &Dialog::UpdateList);
|
|
|
|
|
} else {
|
|
|
|
|
if(QToolButton *tButton = qobject_cast< QToolButton * >(this->sender())){
|
|
|
|
|
tButton->setChecked(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-27 11:17:00 +02:00
|
|
|
|
template <typename T>
|
|
|
|
|
void MainWindow::AddToolToDetail(T *tool, const qint64 &id, Tool::Tools typeTool,
|
2013-09-10 14:29:06 +02:00
|
|
|
|
const qint64 &idDetail){
|
2013-10-04 13:32:42 +02:00
|
|
|
|
QHash<qint64, VDataTool*>* tools = doc->getTools();
|
2013-09-10 14:29:06 +02:00
|
|
|
|
VToolDetail *det = qobject_cast<VToolDetail*>(tools->value(idDetail));
|
|
|
|
|
Q_CHECK_PTR(det);
|
|
|
|
|
det->AddTool(tool, id, typeTool);
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-13 18:48:36 +02:00
|
|
|
|
void MainWindow::ToolEndLine(bool checked){
|
2013-09-27 11:17:00 +02:00
|
|
|
|
SetToolButton(checked, Tool::EndLineTool, ":/cursor/endline_cursor.png", dialogEndLine,
|
2013-08-13 18:48:36 +02:00
|
|
|
|
&MainWindow::ClosedDialogEndLine);
|
2013-07-25 14:00:51 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::ClosedDialogEndLine(int result){
|
|
|
|
|
if(result == QDialog::Accepted){
|
2013-09-10 14:29:06 +02:00
|
|
|
|
if(mode == Draw::Calculation){
|
|
|
|
|
VToolEndLine::Create(dialogEndLine, currentScene, doc, data);
|
|
|
|
|
} else {
|
|
|
|
|
VModelingEndLine *endLine = VModelingEndLine::Create(dialogEndLine, doc, data);
|
2013-09-27 11:17:00 +02:00
|
|
|
|
AddToolToDetail(endLine, endLine->getId(), Tool::EndLineTool, dialogEndLine->getIdDetail());
|
2013-09-10 14:29:06 +02:00
|
|
|
|
}
|
2013-07-25 14:00:51 +02:00
|
|
|
|
}
|
|
|
|
|
ArrowTool();
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-25 20:39:51 +02:00
|
|
|
|
void MainWindow::ToolLine(bool checked){
|
2013-09-27 11:17:00 +02:00
|
|
|
|
SetToolButton(checked, Tool::LineTool, ":/cursor/line_cursor.png", dialogLine,
|
2013-08-13 18:48:36 +02:00
|
|
|
|
&MainWindow::ClosedDialogLine);
|
2013-07-25 20:39:51 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::ClosedDialogLine(int result){
|
|
|
|
|
if(result == QDialog::Accepted){
|
2013-09-10 14:29:06 +02:00
|
|
|
|
if(mode == Draw::Calculation){
|
|
|
|
|
VToolLine::Create(dialogLine, currentScene, doc, data);
|
|
|
|
|
} else {
|
|
|
|
|
VModelingLine *line = VModelingLine::Create(dialogLine, doc, data);
|
2013-09-27 11:17:00 +02:00
|
|
|
|
AddToolToDetail(line, line->getId(), Tool::LineTool, dialogLine->getIdDetail());
|
2013-09-10 14:29:06 +02:00
|
|
|
|
}
|
2013-07-25 20:39:51 +02:00
|
|
|
|
}
|
|
|
|
|
ArrowTool();
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-28 00:18:06 +02:00
|
|
|
|
void MainWindow::ToolAlongLine(bool checked){
|
2013-09-27 11:17:00 +02:00
|
|
|
|
SetToolButton(checked, Tool::AlongLineTool, ":/cursor/alongline_cursor.png", dialogAlongLine,
|
2013-08-13 18:48:36 +02:00
|
|
|
|
&MainWindow::ClosedDialogAlongLine);
|
2013-07-28 00:18:06 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::ClosedDialogAlongLine(int result){
|
|
|
|
|
if(result == QDialog::Accepted){
|
2013-09-10 14:29:06 +02:00
|
|
|
|
if(mode == Draw::Calculation){
|
|
|
|
|
VToolAlongLine::Create(dialogAlongLine, currentScene, doc, data);
|
|
|
|
|
} else{
|
|
|
|
|
VModelingAlongLine *point = VModelingAlongLine::Create(dialogAlongLine, doc, data);
|
2013-09-27 11:17:00 +02:00
|
|
|
|
AddToolToDetail(point, point->getId(), Tool::AlongLineTool, dialogAlongLine->getIdDetail());
|
2013-09-10 14:29:06 +02:00
|
|
|
|
}
|
2013-07-28 00:18:06 +02:00
|
|
|
|
}
|
|
|
|
|
ArrowTool();
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-29 14:55:40 +02:00
|
|
|
|
void MainWindow::ToolShoulderPoint(bool checked){
|
2013-09-27 11:17:00 +02:00
|
|
|
|
SetToolButton(checked, Tool::ShoulderPointTool, ":/cursor/shoulder_cursor.png", dialogShoulderPoint,
|
2013-08-13 18:48:36 +02:00
|
|
|
|
&MainWindow::ClosedDialogShoulderPoint);
|
2013-07-29 14:55:40 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::ClosedDialogShoulderPoint(int result){
|
|
|
|
|
if(result == QDialog::Accepted){
|
2013-09-10 14:29:06 +02:00
|
|
|
|
if(mode == Draw::Calculation){
|
|
|
|
|
VToolShoulderPoint::Create(dialogShoulderPoint, currentScene, doc, data);
|
|
|
|
|
} else {
|
|
|
|
|
VModelingShoulderPoint *point = VModelingShoulderPoint::Create(dialogShoulderPoint, doc, data);
|
2013-09-27 11:17:00 +02:00
|
|
|
|
AddToolToDetail(point, point->getId(), Tool::ShoulderPointTool,
|
2013-09-10 14:29:06 +02:00
|
|
|
|
dialogShoulderPoint->getIdDetail());
|
|
|
|
|
}
|
2013-07-29 14:55:40 +02:00
|
|
|
|
}
|
|
|
|
|
ArrowTool();
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-30 15:09:34 +02:00
|
|
|
|
void MainWindow::ToolNormal(bool checked){
|
2013-09-27 11:17:00 +02:00
|
|
|
|
SetToolButton(checked, Tool::NormalTool, ":/cursor/normal_cursor.png", dialogNormal,
|
2013-08-13 18:48:36 +02:00
|
|
|
|
&MainWindow::ClosedDialogNormal);
|
2013-07-30 15:09:34 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::ClosedDialogNormal(int result){
|
|
|
|
|
if(result == QDialog::Accepted){
|
2013-09-10 14:29:06 +02:00
|
|
|
|
if(mode == Draw::Calculation){
|
|
|
|
|
VToolNormal::Create(dialogNormal, currentScene, doc, data);
|
|
|
|
|
} else {
|
|
|
|
|
VModelingNormal *point = VModelingNormal::Create(dialogNormal, doc, data);
|
2013-09-27 11:17:00 +02:00
|
|
|
|
AddToolToDetail(point, point->getId(), Tool::NormalTool, dialogNormal->getIdDetail());
|
2013-09-10 14:29:06 +02:00
|
|
|
|
}
|
2013-07-30 15:09:34 +02:00
|
|
|
|
}
|
|
|
|
|
ArrowTool();
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-30 20:46:40 +02:00
|
|
|
|
void MainWindow::ToolBisector(bool checked){
|
2013-09-27 11:17:00 +02:00
|
|
|
|
SetToolButton(checked, Tool::BisectorTool, ":/cursor/bisector_cursor.png", dialogBisector,
|
2013-08-13 18:48:36 +02:00
|
|
|
|
&MainWindow::ClosedDialogBisector);
|
2013-07-30 20:46:40 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::ClosedDialogBisector(int result){
|
|
|
|
|
if(result == QDialog::Accepted){
|
2013-09-10 14:29:06 +02:00
|
|
|
|
if(mode == Draw::Calculation){
|
|
|
|
|
VToolBisector::Create(dialogBisector, currentScene, doc, data);
|
|
|
|
|
} else {
|
|
|
|
|
VModelingBisector *point = VModelingBisector::Create(dialogBisector, doc, data);
|
2013-09-27 11:17:00 +02:00
|
|
|
|
AddToolToDetail(point, point->getId(), Tool::BisectorTool, dialogBisector->getIdDetail());
|
2013-09-10 14:29:06 +02:00
|
|
|
|
}
|
2013-07-30 20:46:40 +02:00
|
|
|
|
}
|
|
|
|
|
ArrowTool();
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-31 13:34:39 +02:00
|
|
|
|
void MainWindow::ToolLineIntersect(bool checked){
|
2013-09-27 11:17:00 +02:00
|
|
|
|
SetToolButton(checked, Tool::LineIntersectTool, ":/cursor/intersect_cursor.png", dialogLineIntersect,
|
2013-08-13 18:48:36 +02:00
|
|
|
|
&MainWindow::ClosedDialogLineIntersect);
|
2013-07-31 13:34:39 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::ClosedDialogLineIntersect(int result){
|
|
|
|
|
if(result == QDialog::Accepted){
|
2013-09-10 14:29:06 +02:00
|
|
|
|
if(mode == Draw::Calculation){
|
|
|
|
|
VToolLineIntersect::Create(dialogLineIntersect, currentScene, doc, data);
|
|
|
|
|
} else {
|
|
|
|
|
VModelingLineIntersect *point = VModelingLineIntersect::Create(dialogLineIntersect, doc, data);
|
2013-09-27 11:17:00 +02:00
|
|
|
|
AddToolToDetail(point, point->getId(), Tool::LineIntersectTool,
|
2013-09-10 14:29:06 +02:00
|
|
|
|
dialogLineIntersect->getIdDetail());
|
|
|
|
|
}
|
2013-07-31 13:34:39 +02:00
|
|
|
|
}
|
|
|
|
|
ArrowTool();
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-05 10:37:56 +02:00
|
|
|
|
void MainWindow::ToolSpline(bool checked){
|
2013-09-27 11:17:00 +02:00
|
|
|
|
SetToolButton(checked, Tool::SplineTool, ":/cursor/spline_cursor.png", dialogSpline,
|
2013-08-13 18:48:36 +02:00
|
|
|
|
&MainWindow::ClosedDialogSpline);
|
2013-08-05 10:37:56 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::ClosedDialogSpline(int result){
|
|
|
|
|
if(result == QDialog::Accepted){
|
2013-09-10 14:29:06 +02:00
|
|
|
|
if(mode == Draw::Calculation){
|
|
|
|
|
VToolSpline::Create(dialogSpline, currentScene, doc, data);
|
|
|
|
|
} else {
|
|
|
|
|
VModelingSpline *spl = VModelingSpline::Create(dialogSpline, doc, data);
|
2013-09-27 11:17:00 +02:00
|
|
|
|
AddToolToDetail(spl, spl->getId(), Tool::SplineTool, dialogSpline->getIdDetail());
|
2013-09-10 14:29:06 +02:00
|
|
|
|
}
|
2013-08-05 10:37:56 +02:00
|
|
|
|
}
|
|
|
|
|
ArrowTool();
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-06 09:56:09 +02:00
|
|
|
|
void MainWindow::ToolArc(bool checked){
|
2013-09-27 11:17:00 +02:00
|
|
|
|
SetToolButton(checked, Tool::ArcTool, ":/cursor/arc_cursor.png", dialogArc,
|
2013-08-13 18:48:36 +02:00
|
|
|
|
&MainWindow::ClosedDialogArc);
|
2013-08-06 09:56:09 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::ClosedDialogArc(int result){
|
|
|
|
|
if(result == QDialog::Accepted){
|
2013-09-10 14:29:06 +02:00
|
|
|
|
if(mode == Draw::Calculation){
|
|
|
|
|
VToolArc::Create(dialogArc, currentScene, doc, data);
|
|
|
|
|
} else {
|
|
|
|
|
VModelingArc *arc = VModelingArc::Create(dialogArc, doc, data);
|
2013-09-27 11:17:00 +02:00
|
|
|
|
AddToolToDetail(arc, arc->getId(), Tool::ArcTool, dialogArc->getIdDetail());
|
2013-09-10 14:29:06 +02:00
|
|
|
|
}
|
2013-08-06 09:56:09 +02:00
|
|
|
|
}
|
|
|
|
|
ArrowTool();
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-09 08:49:34 +02:00
|
|
|
|
void MainWindow::ToolSplinePath(bool checked){
|
2013-09-27 11:17:00 +02:00
|
|
|
|
SetToolButton(checked, Tool::SplinePathTool, ":/cursor/splinepath_cursor.png", dialogSplinePath,
|
2013-08-13 18:48:36 +02:00
|
|
|
|
&MainWindow::ClosedDialogSplinePath);
|
2013-08-09 08:49:34 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::ClosedDialogSplinePath(int result){
|
|
|
|
|
if(result == QDialog::Accepted){
|
2013-09-10 14:29:06 +02:00
|
|
|
|
if(mode == Draw::Calculation){
|
|
|
|
|
VToolSplinePath::Create(dialogSplinePath, currentScene, doc, data);
|
|
|
|
|
} else {
|
|
|
|
|
VModelingSplinePath *spl = VModelingSplinePath::Create(dialogSplinePath, doc, data);
|
2013-09-27 11:17:00 +02:00
|
|
|
|
AddToolToDetail(spl, spl->getId(), Tool::SplinePathTool, dialogSplinePath->getIdDetail());
|
2013-09-10 14:29:06 +02:00
|
|
|
|
}
|
2013-08-09 08:49:34 +02:00
|
|
|
|
}
|
|
|
|
|
ArrowTool();
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-21 10:03:53 +02:00
|
|
|
|
void MainWindow::ToolPointOfContact(bool checked){
|
2013-09-27 11:17:00 +02:00
|
|
|
|
SetToolButton(checked, Tool::PointOfContact, ":/cursor/pointcontact_cursor.png", dialogPointOfContact,
|
2013-08-21 10:03:53 +02:00
|
|
|
|
&MainWindow::ClosedDialogPointOfContact);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::ClosedDialogPointOfContact(int result){
|
|
|
|
|
if(result == QDialog::Accepted){
|
2013-09-10 14:29:06 +02:00
|
|
|
|
if(mode == Draw::Calculation){
|
|
|
|
|
VToolPointOfContact::Create(dialogPointOfContact, currentScene, doc, data);
|
|
|
|
|
} else {
|
|
|
|
|
VModelingPointOfContact *point = VModelingPointOfContact::Create(dialogPointOfContact, doc,
|
|
|
|
|
data);
|
2013-09-27 11:17:00 +02:00
|
|
|
|
AddToolToDetail(point, point->getId(), Tool::PointOfContact,
|
2013-09-10 14:29:06 +02:00
|
|
|
|
dialogPointOfContact->getIdDetail());
|
|
|
|
|
}
|
2013-08-28 10:55:11 +02:00
|
|
|
|
}
|
|
|
|
|
ArrowTool();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::ToolDetail(bool checked){
|
|
|
|
|
if(checked){
|
|
|
|
|
CanselTool();
|
2013-09-27 11:17:00 +02:00
|
|
|
|
tool = Tool::Detail;
|
2013-08-28 10:55:11 +02:00
|
|
|
|
QPixmap pixmap("://cursor/new_detail_cursor.png");
|
|
|
|
|
QCursor cur(pixmap, 2, 3);
|
|
|
|
|
view->setCursor(cur);
|
|
|
|
|
helpLabel->setText("Виберіть точки.");
|
|
|
|
|
dialogDetail = QSharedPointer<DialogDetail>(new DialogDetail(data, mode));
|
|
|
|
|
connect(currentScene, &VMainGraphicsScene::ChoosedObject, dialogDetail.data(),
|
|
|
|
|
&DialogDetail::ChoosedObject);
|
|
|
|
|
connect(dialogDetail.data(), &DialogDetail::DialogClosed, this, &MainWindow::ClosedDialogDetail);
|
|
|
|
|
connect(doc, &VDomDocument::FullUpdateFromFile, dialogDetail.data(), &DialogDetail::UpdateList);
|
|
|
|
|
} else {
|
|
|
|
|
if(QToolButton *tButton = qobject_cast< QToolButton * >(this->sender())){
|
|
|
|
|
tButton->setChecked(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::ClosedDialogDetail(int result){
|
|
|
|
|
if(result == QDialog::Accepted){
|
|
|
|
|
VToolDetail::Create(dialogDetail, sceneDetails, doc, data);
|
2013-08-21 10:03:53 +02:00
|
|
|
|
}
|
|
|
|
|
ArrowTool();
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-29 12:31:50 +02:00
|
|
|
|
void MainWindow::tableClosed(){
|
|
|
|
|
show();
|
|
|
|
|
MinimumScrollBar();
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-03 14:29:26 +02:00
|
|
|
|
void MainWindow::showEvent( QShowEvent *event ){
|
|
|
|
|
QMainWindow::showEvent( event );
|
|
|
|
|
if( event->spontaneous() ){
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(isInitialized){
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// do your init stuff here
|
2013-08-29 12:31:50 +02:00
|
|
|
|
MinimumScrollBar();
|
2013-07-03 14:29:26 +02:00
|
|
|
|
|
2013-09-18 18:52:49 +02:00
|
|
|
|
isInitialized = true;//first show windows are held
|
2013-07-03 14:29:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-09-26 15:47:46 +02:00
|
|
|
|
void MainWindow::closeEvent(QCloseEvent *event){
|
|
|
|
|
if(changeInFile == true){
|
|
|
|
|
QMessageBox msgBox;
|
|
|
|
|
msgBox.setText("The pattern has been modified.");
|
|
|
|
|
msgBox.setInformativeText("Do you want to save your changes?");
|
|
|
|
|
msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
|
|
|
|
|
msgBox.setDefaultButton(QMessageBox::Save);
|
|
|
|
|
msgBox.setIcon(QMessageBox::Question);
|
|
|
|
|
int ret = msgBox.exec();
|
|
|
|
|
switch (ret) {
|
|
|
|
|
case QMessageBox::Save:
|
|
|
|
|
// Save was clicked
|
|
|
|
|
if(fileName.isEmpty()){
|
|
|
|
|
ActionSaveAs();
|
|
|
|
|
} else {
|
|
|
|
|
ActionSave();
|
|
|
|
|
}
|
|
|
|
|
event->accept();
|
|
|
|
|
break;
|
|
|
|
|
case QMessageBox::Discard:
|
|
|
|
|
// Don't Save was clicked
|
|
|
|
|
event->accept();
|
|
|
|
|
break;
|
|
|
|
|
case QMessageBox::Cancel:
|
|
|
|
|
// Cancel was clicked
|
|
|
|
|
event->ignore();
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
// should never be reached
|
|
|
|
|
event->accept();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-03 14:29:26 +02:00
|
|
|
|
void MainWindow::ToolBarOption(){
|
|
|
|
|
QLabel * labelGrowth = new QLabel;
|
2013-09-18 18:52:49 +02:00
|
|
|
|
labelGrowth->setText(tr("Growth: "));
|
2013-07-03 14:29:26 +02:00
|
|
|
|
ui->toolBarOption->addWidget(labelGrowth);
|
|
|
|
|
|
2013-06-20 16:09:50 +02:00
|
|
|
|
QStringList list;
|
2013-07-03 14:29:26 +02:00
|
|
|
|
list << "104"<<"110"<<"116"<<"122"<<"128"<<"134"<<"140"<<"146"<<"152"<<"158"<<"164"<<"170"<<"176"
|
|
|
|
|
<< "182" << "188";
|
2013-07-17 13:38:11 +02:00
|
|
|
|
QComboBox *comboBoxGrow = new QComboBox;
|
2013-07-03 14:29:26 +02:00
|
|
|
|
comboBoxGrow->clear();
|
|
|
|
|
comboBoxGrow->addItems(list);
|
|
|
|
|
comboBoxGrow->setCurrentIndex(12);
|
|
|
|
|
ui->toolBarOption->addWidget(comboBoxGrow);
|
2013-07-17 13:38:11 +02:00
|
|
|
|
connect(comboBoxGrow,
|
|
|
|
|
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
|
|
|
|
|
this, &MainWindow::ChangedGrowth);
|
2013-07-03 14:29:26 +02:00
|
|
|
|
|
|
|
|
|
QLabel * labelSize = new QLabel;
|
2013-09-18 18:52:49 +02:00
|
|
|
|
labelSize->setText(tr(" Size: "));
|
2013-07-03 14:29:26 +02:00
|
|
|
|
ui->toolBarOption->addWidget(labelSize);
|
|
|
|
|
|
|
|
|
|
list.clear();
|
2013-06-20 16:09:50 +02:00
|
|
|
|
list << "28"<<"30"<<"32"<<"34"<<"36"<<"38"<<"40"<<"42"<<"44"<<"46"<<"48"<<"50" << "52" << "54" << "56";
|
2013-07-17 13:38:11 +02:00
|
|
|
|
QComboBox *comboBoxSize = new QComboBox;
|
2013-07-03 14:29:26 +02:00
|
|
|
|
comboBoxSize->clear();
|
2013-06-20 16:09:50 +02:00
|
|
|
|
comboBoxSize->addItems(list);
|
2013-07-03 14:29:26 +02:00
|
|
|
|
comboBoxSize->setCurrentIndex(11);
|
2013-06-20 16:09:50 +02:00
|
|
|
|
ui->toolBarOption->addWidget(comboBoxSize);
|
2013-07-17 13:38:11 +02:00
|
|
|
|
connect(comboBoxSize,
|
|
|
|
|
static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
|
|
|
|
|
this, &MainWindow::ChangedSize);
|
2013-07-03 14:29:26 +02:00
|
|
|
|
|
|
|
|
|
ui->toolBarOption->addSeparator();
|
|
|
|
|
|
|
|
|
|
mouseCoordinate = new QLabel;
|
|
|
|
|
mouseCoordinate ->setText("0, 0");
|
|
|
|
|
ui->toolBarOption->addWidget(mouseCoordinate);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::ToolBarDraws(){
|
|
|
|
|
QLabel * labelNameDraw = new QLabel;
|
2013-09-18 18:52:49 +02:00
|
|
|
|
labelNameDraw ->setText(tr("Drawing: "));
|
2013-07-03 14:29:26 +02:00
|
|
|
|
ui->toolBarDraws->addWidget(labelNameDraw);
|
|
|
|
|
|
2013-07-13 12:51:31 +02:00
|
|
|
|
comboBoxDraws = new QComboBox;
|
2013-07-03 14:29:26 +02:00
|
|
|
|
ui->toolBarDraws->addWidget(comboBoxDraws);
|
2013-07-13 12:51:31 +02:00
|
|
|
|
comboBoxDraws->setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
|
|
|
|
connect(comboBoxDraws, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
|
|
|
|
this, &MainWindow::currentDrawChanged);
|
2013-07-03 14:29:26 +02:00
|
|
|
|
|
2013-07-13 12:51:31 +02:00
|
|
|
|
ui->toolBarDraws->addAction(ui->actionOptionDraw);
|
|
|
|
|
ui->actionOptionDraw->setEnabled(false);
|
2013-07-17 13:38:11 +02:00
|
|
|
|
|
|
|
|
|
ui->toolBarDraws->addAction(ui->actionTable);
|
|
|
|
|
ui->actionTable->setEnabled(false);
|
2013-08-15 22:39:00 +02:00
|
|
|
|
|
|
|
|
|
ui->toolBarDraws->addAction(ui->actionHistory);
|
|
|
|
|
ui->actionHistory->setEnabled(false);
|
2013-08-29 12:31:50 +02:00
|
|
|
|
connect(ui->actionHistory, &QAction::triggered, this, &MainWindow::ActionHistory);
|
|
|
|
|
|
|
|
|
|
ui->toolBarDraws->addAction(ui->actionLayout);
|
|
|
|
|
connect(ui->actionLayout, &QAction::triggered, this, &MainWindow::ActionLayout);
|
2013-07-13 12:51:31 +02:00
|
|
|
|
}
|
2013-07-03 14:29:26 +02:00
|
|
|
|
|
2013-07-13 12:51:31 +02:00
|
|
|
|
void MainWindow::currentDrawChanged( int index ){
|
|
|
|
|
if(index != -1) {
|
2013-08-15 22:39:00 +02:00
|
|
|
|
doc->setCurrentData();
|
2013-07-13 12:51:31 +02:00
|
|
|
|
doc->ChangeActivDraw(comboBoxDraws->itemText(index));
|
|
|
|
|
}
|
2013-07-03 14:29:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::mouseMove(QPointF scenePos){
|
|
|
|
|
QString string = QString("%1, %2")
|
2013-08-15 22:39:00 +02:00
|
|
|
|
.arg(static_cast<qint32>(scenePos.x()/PrintDPI*25.4))
|
|
|
|
|
.arg(static_cast<qint32>(scenePos.y()/PrintDPI*25.4));
|
2013-07-03 14:29:26 +02:00
|
|
|
|
mouseCoordinate->setText(string);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::CanselTool(){
|
|
|
|
|
switch( tool )
|
|
|
|
|
{
|
2013-09-27 11:17:00 +02:00
|
|
|
|
case Tool::ArrowTool:
|
2013-07-13 12:51:31 +02:00
|
|
|
|
ui->actionArrowTool->setChecked(false);
|
2013-07-03 14:29:26 +02:00
|
|
|
|
break;
|
2013-09-27 11:17:00 +02:00
|
|
|
|
case Tool::SinglePointTool:
|
2013-08-15 22:39:00 +02:00
|
|
|
|
//Nothing to do here because we can't create this tool from main window.
|
2013-07-03 14:29:26 +02:00
|
|
|
|
break;
|
2013-09-27 11:17:00 +02:00
|
|
|
|
case Tool::EndLineTool:
|
2013-08-13 18:48:36 +02:00
|
|
|
|
dialogEndLine.clear();
|
2013-07-25 14:00:51 +02:00
|
|
|
|
ui->toolButtonEndLine->setChecked(false);
|
2013-08-28 10:55:11 +02:00
|
|
|
|
currentScene->setFocus(Qt::OtherFocusReason);
|
|
|
|
|
currentScene->clearSelection();
|
2013-07-25 14:00:51 +02:00
|
|
|
|
break;
|
2013-09-27 11:17:00 +02:00
|
|
|
|
case Tool::LineTool:
|
2013-08-13 18:48:36 +02:00
|
|
|
|
dialogLine.clear();
|
2013-07-25 20:39:51 +02:00
|
|
|
|
ui->toolButtonLine->setChecked(false);
|
2013-08-28 10:55:11 +02:00
|
|
|
|
currentScene->setFocus(Qt::OtherFocusReason);
|
|
|
|
|
currentScene->clearFocus();
|
2013-07-25 20:39:51 +02:00
|
|
|
|
break;
|
2013-09-27 11:17:00 +02:00
|
|
|
|
case Tool::AlongLineTool:
|
2013-08-13 18:48:36 +02:00
|
|
|
|
dialogAlongLine.clear();
|
2013-07-28 00:18:06 +02:00
|
|
|
|
ui->toolButtonAlongLine->setChecked(false);
|
2013-08-28 10:55:11 +02:00
|
|
|
|
currentScene->setFocus(Qt::OtherFocusReason);
|
|
|
|
|
currentScene->clearSelection();
|
2013-07-29 14:55:40 +02:00
|
|
|
|
break;
|
2013-09-27 11:17:00 +02:00
|
|
|
|
case Tool::ShoulderPointTool:
|
2013-08-13 18:48:36 +02:00
|
|
|
|
dialogShoulderPoint.clear();
|
2013-07-29 14:55:40 +02:00
|
|
|
|
ui->toolButtonShoulderPoint->setChecked(false);
|
2013-08-28 10:55:11 +02:00
|
|
|
|
currentScene->setFocus(Qt::OtherFocusReason);
|
|
|
|
|
currentScene->clearSelection();
|
2013-07-28 00:18:06 +02:00
|
|
|
|
break;
|
2013-09-27 11:17:00 +02:00
|
|
|
|
case Tool::NormalTool:
|
2013-08-13 18:48:36 +02:00
|
|
|
|
dialogNormal.clear();
|
2013-07-30 15:09:34 +02:00
|
|
|
|
ui->toolButtonNormal->setChecked(false);
|
2013-08-28 10:55:11 +02:00
|
|
|
|
currentScene->setFocus(Qt::OtherFocusReason);
|
|
|
|
|
currentScene->clearSelection();
|
2013-07-30 15:09:34 +02:00
|
|
|
|
break;
|
2013-09-27 11:17:00 +02:00
|
|
|
|
case Tool::BisectorTool:
|
2013-08-13 18:48:36 +02:00
|
|
|
|
dialogBisector.clear();
|
2013-07-30 20:46:40 +02:00
|
|
|
|
ui->toolButtonBisector->setChecked(false);
|
2013-08-28 10:55:11 +02:00
|
|
|
|
currentScene->setFocus(Qt::OtherFocusReason);
|
|
|
|
|
currentScene->clearSelection();
|
2013-07-30 20:46:40 +02:00
|
|
|
|
break;
|
2013-09-27 11:17:00 +02:00
|
|
|
|
case Tool::LineIntersectTool:
|
2013-08-13 18:48:36 +02:00
|
|
|
|
dialogLineIntersect.clear();
|
2013-07-31 13:34:39 +02:00
|
|
|
|
ui->toolButtonLineIntersect->setChecked(false);
|
2013-08-28 10:55:11 +02:00
|
|
|
|
currentScene->setFocus(Qt::OtherFocusReason);
|
|
|
|
|
currentScene->clearSelection();
|
2013-07-31 13:34:39 +02:00
|
|
|
|
break;
|
2013-09-27 11:17:00 +02:00
|
|
|
|
case Tool::SplineTool:
|
2013-08-13 18:48:36 +02:00
|
|
|
|
dialogSpline.clear();
|
2013-08-05 10:37:56 +02:00
|
|
|
|
ui->toolButtonSpline->setChecked(false);
|
2013-08-28 10:55:11 +02:00
|
|
|
|
currentScene->setFocus(Qt::OtherFocusReason);
|
|
|
|
|
currentScene->clearSelection();
|
2013-08-05 10:37:56 +02:00
|
|
|
|
break;
|
2013-09-27 11:17:00 +02:00
|
|
|
|
case Tool::ArcTool:
|
2013-08-13 18:48:36 +02:00
|
|
|
|
dialogArc.clear();
|
2013-08-06 09:56:09 +02:00
|
|
|
|
ui->toolButtonArc->setChecked(false);
|
2013-08-28 10:55:11 +02:00
|
|
|
|
currentScene->setFocus(Qt::OtherFocusReason);
|
|
|
|
|
currentScene->clearSelection();
|
2013-08-06 09:56:09 +02:00
|
|
|
|
break;
|
2013-09-27 11:17:00 +02:00
|
|
|
|
case Tool::SplinePathTool:
|
2013-08-13 18:48:36 +02:00
|
|
|
|
dialogSplinePath.clear();
|
2013-08-09 08:49:34 +02:00
|
|
|
|
ui->toolButtonSplinePath->setChecked(false);
|
2013-08-28 10:55:11 +02:00
|
|
|
|
currentScene->setFocus(Qt::OtherFocusReason);
|
|
|
|
|
currentScene->clearSelection();
|
2013-08-09 08:49:34 +02:00
|
|
|
|
break;
|
2013-09-27 11:17:00 +02:00
|
|
|
|
case Tool::PointOfContact:
|
2013-08-21 10:03:53 +02:00
|
|
|
|
dialogPointOfContact.clear();
|
|
|
|
|
ui->toolButtonPointOfContact->setChecked(false);
|
2013-08-28 10:55:11 +02:00
|
|
|
|
currentScene->setFocus(Qt::OtherFocusReason);
|
|
|
|
|
currentScene->clearSelection();
|
|
|
|
|
break;
|
2013-09-27 11:17:00 +02:00
|
|
|
|
case Tool::Detail:
|
2013-08-28 10:55:11 +02:00
|
|
|
|
dialogDetail.clear();
|
|
|
|
|
ui->toolButtonNewDetail->setChecked(false);
|
2013-08-21 10:03:53 +02:00
|
|
|
|
break;
|
2013-09-12 16:18:31 +02:00
|
|
|
|
default:
|
|
|
|
|
qWarning()<<"Get wrong tool type. Ignore.";
|
|
|
|
|
break;
|
2013-07-03 14:29:26 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::ArrowTool(){
|
|
|
|
|
CanselTool();
|
2013-07-13 12:51:31 +02:00
|
|
|
|
ui->actionArrowTool->setChecked(true);
|
2013-09-27 11:17:00 +02:00
|
|
|
|
tool = Tool::ArrowTool;
|
2013-07-03 14:29:26 +02:00
|
|
|
|
QCursor cur(Qt::ArrowCursor);
|
2013-08-13 18:48:36 +02:00
|
|
|
|
view->setCursor(cur);
|
2013-07-03 14:29:26 +02:00
|
|
|
|
helpLabel->setText("");
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-25 14:00:51 +02:00
|
|
|
|
void MainWindow::ActionAroowTool(){
|
2013-07-03 14:29:26 +02:00
|
|
|
|
ArrowTool();
|
2013-06-20 16:09:50 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-07-13 12:51:31 +02:00
|
|
|
|
void MainWindow::keyPressEvent ( QKeyEvent * event ){
|
|
|
|
|
switch(event->key()){
|
|
|
|
|
case Qt::Key_Escape:
|
|
|
|
|
ArrowTool();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
QMainWindow::keyPressEvent ( event );
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-25 14:00:51 +02:00
|
|
|
|
void MainWindow::ActionDraw(bool checked){
|
2013-07-13 12:51:31 +02:00
|
|
|
|
if(checked){
|
|
|
|
|
ui->actionDetails->setChecked(false);
|
2013-09-17 20:13:02 +02:00
|
|
|
|
/*Save scroll bars value for previous scene.*/
|
|
|
|
|
QScrollBar *horScrollBar = view->horizontalScrollBar();
|
|
|
|
|
currentScene->setHorScrollBar(horScrollBar->value());
|
|
|
|
|
QScrollBar *verScrollBar = view->verticalScrollBar();
|
|
|
|
|
currentScene->setVerScrollBar(verScrollBar->value());
|
|
|
|
|
|
2013-08-28 10:55:11 +02:00
|
|
|
|
currentScene = sceneDraw;
|
|
|
|
|
view->setScene(currentScene);
|
2013-09-17 20:13:02 +02:00
|
|
|
|
/*Set value for current scene scroll bar.*/
|
|
|
|
|
horScrollBar = view->horizontalScrollBar();
|
|
|
|
|
horScrollBar->setValue(currentScene->getHorScrollBar());
|
|
|
|
|
verScrollBar = view->verticalScrollBar();
|
|
|
|
|
verScrollBar->setValue(currentScene->getVerScrollBar());
|
|
|
|
|
|
2013-08-28 10:55:11 +02:00
|
|
|
|
mode = Draw::Calculation;
|
2013-08-29 12:31:50 +02:00
|
|
|
|
doc->setCurrentData();
|
2013-07-13 12:51:31 +02:00
|
|
|
|
} else {
|
|
|
|
|
ui->actionDraw->setChecked(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-25 14:00:51 +02:00
|
|
|
|
void MainWindow::ActionDetails(bool checked){
|
2013-07-13 12:51:31 +02:00
|
|
|
|
if(checked){
|
|
|
|
|
ui->actionDraw->setChecked(false);
|
2013-09-17 20:13:02 +02:00
|
|
|
|
/*Save scroll bars value for previous scene.*/
|
|
|
|
|
QScrollBar *horScrollBar = view->horizontalScrollBar();
|
|
|
|
|
currentScene->setHorScrollBar(horScrollBar->value());
|
|
|
|
|
QScrollBar *verScrollBar = view->verticalScrollBar();
|
|
|
|
|
currentScene->setVerScrollBar(verScrollBar->value());
|
|
|
|
|
|
2013-08-28 10:55:11 +02:00
|
|
|
|
currentScene = sceneDetails;
|
|
|
|
|
view->setScene(sceneDetails);
|
2013-09-17 20:13:02 +02:00
|
|
|
|
/*Set value for current scene scroll bar.*/
|
|
|
|
|
horScrollBar = view->horizontalScrollBar();
|
|
|
|
|
horScrollBar->setValue(currentScene->getHorScrollBar());
|
|
|
|
|
verScrollBar = view->verticalScrollBar();
|
|
|
|
|
verScrollBar->setValue(currentScene->getVerScrollBar());
|
2013-08-28 10:55:11 +02:00
|
|
|
|
mode = Draw::Modeling;
|
2013-07-13 12:51:31 +02:00
|
|
|
|
} else {
|
|
|
|
|
ui->actionDetails->setChecked(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-25 14:00:51 +02:00
|
|
|
|
void MainWindow::ActionSaveAs(){
|
2013-07-13 12:51:31 +02:00
|
|
|
|
QString filters("Lekalo files (*.xml);;All files (*.*)");
|
|
|
|
|
QString defaultFilter("Lekalo files (*.xml)");
|
|
|
|
|
QString fName = QFileDialog::getSaveFileName(this, "Зберегти файл як", QDir::homePath(),
|
2013-09-30 18:29:03 +02:00
|
|
|
|
filters, &defaultFilter);
|
2013-08-13 18:48:36 +02:00
|
|
|
|
if(fName.isEmpty())
|
|
|
|
|
return;
|
2013-07-13 12:51:31 +02:00
|
|
|
|
if(fName.indexOf(".xml",fName.size()-4)<0){
|
|
|
|
|
fName.append(".xml");
|
|
|
|
|
}
|
|
|
|
|
fileName = fName;
|
|
|
|
|
QFileInfo info(fileName);
|
|
|
|
|
QString title(info.fileName());
|
|
|
|
|
title.append("-Valentina");
|
|
|
|
|
setWindowTitle(title);
|
|
|
|
|
|
|
|
|
|
QFile file(fileName);
|
|
|
|
|
if(file.open(QIODevice::WriteOnly| QIODevice::Truncate)){
|
2013-08-28 10:55:11 +02:00
|
|
|
|
doc->GarbageCollector();
|
2013-07-13 12:51:31 +02:00
|
|
|
|
const int Indent = 4;
|
|
|
|
|
QTextStream out(&file);
|
|
|
|
|
doc->save(out, Indent);
|
|
|
|
|
file.close();
|
|
|
|
|
}
|
|
|
|
|
ui->actionSave->setEnabled(false);
|
|
|
|
|
changeInFile = false;
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-25 14:00:51 +02:00
|
|
|
|
void MainWindow::ActionSave(){
|
2013-07-13 12:51:31 +02:00
|
|
|
|
if(!fileName.isEmpty()){
|
|
|
|
|
QFile file(fileName);
|
|
|
|
|
if(file.open(QIODevice::WriteOnly| QIODevice::Truncate)){
|
2013-08-28 10:55:11 +02:00
|
|
|
|
doc->GarbageCollector();
|
2013-07-13 12:51:31 +02:00
|
|
|
|
const int Indent = 4;
|
|
|
|
|
QTextStream out(&file);
|
|
|
|
|
doc->save(out, Indent);
|
|
|
|
|
file.close();
|
|
|
|
|
}
|
|
|
|
|
ui->actionSave->setEnabled(false);
|
|
|
|
|
changeInFile = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-25 14:00:51 +02:00
|
|
|
|
void MainWindow::ActionOpen(){
|
2013-09-18 18:52:49 +02:00
|
|
|
|
QString filter(tr("Lekalo files (*.xml)"));
|
|
|
|
|
QString fName = QFileDialog::getOpenFileName(this, tr("Open file"), QDir::homePath(), filter);
|
2013-08-13 18:48:36 +02:00
|
|
|
|
if(fName.isEmpty())
|
|
|
|
|
return;
|
2013-09-23 15:17:15 +02:00
|
|
|
|
if(fileName.isEmpty() && changeInFile == false){
|
|
|
|
|
OpenPattern(fName);
|
|
|
|
|
} else {
|
|
|
|
|
/*Open new copy application*/
|
|
|
|
|
QProcess *v = new QProcess(this);
|
|
|
|
|
QStringList arguments;
|
|
|
|
|
arguments << "-o" << fName;
|
|
|
|
|
v->startDetached(QCoreApplication::applicationFilePath (), arguments);
|
|
|
|
|
delete v;
|
2013-07-13 12:51:31 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-23 15:17:15 +02:00
|
|
|
|
void MainWindow::Clear(){
|
2013-07-13 12:51:31 +02:00
|
|
|
|
setWindowTitle("Valentina");
|
2013-08-13 18:48:36 +02:00
|
|
|
|
fileName.clear();
|
2013-07-13 12:51:31 +02:00
|
|
|
|
data->Clear();
|
|
|
|
|
doc->clear();
|
2013-08-28 10:55:11 +02:00
|
|
|
|
sceneDraw->clear();
|
|
|
|
|
sceneDetails->clear();
|
2013-07-13 12:51:31 +02:00
|
|
|
|
CanselTool();
|
|
|
|
|
comboBoxDraws->clear();
|
|
|
|
|
fileName.clear();
|
|
|
|
|
ui->actionOptionDraw->setEnabled(false);
|
|
|
|
|
ui->actionSave->setEnabled(false);
|
2013-07-25 14:00:51 +02:00
|
|
|
|
SetEnableTool(false);
|
2013-07-13 12:51:31 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-09-23 15:17:15 +02:00
|
|
|
|
void MainWindow::ActionNew(){
|
|
|
|
|
QProcess *v = new QProcess(this);
|
|
|
|
|
v->startDetached(QCoreApplication::applicationFilePath ());
|
|
|
|
|
delete v;
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-13 12:51:31 +02:00
|
|
|
|
void MainWindow::haveChange(){
|
|
|
|
|
if(!fileName.isEmpty()){
|
|
|
|
|
ui->actionSave->setEnabled(true);
|
2013-09-23 15:17:15 +02:00
|
|
|
|
changeInFile = true;
|
2013-07-13 12:51:31 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-17 13:38:11 +02:00
|
|
|
|
void MainWindow::ChangedSize(const QString & text){
|
|
|
|
|
qint32 size = text.toInt();
|
|
|
|
|
data->SetSize(size*10);
|
|
|
|
|
doc->FullUpdateTree();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::ChangedGrowth(const QString &text){
|
|
|
|
|
qint32 growth = text.toInt();
|
|
|
|
|
data->SetGrowth(growth*10);
|
|
|
|
|
doc->FullUpdateTree();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::SetEnableWidgets(bool enable){
|
|
|
|
|
ui->actionSaveAs->setEnabled(enable);
|
|
|
|
|
ui->actionDraw->setEnabled(enable);
|
|
|
|
|
ui->actionDetails->setEnabled(enable);
|
|
|
|
|
ui->actionOptionDraw->setEnabled(enable);
|
2013-07-25 14:00:51 +02:00
|
|
|
|
if(enable == true && !fileName.isEmpty()){
|
|
|
|
|
ui->actionSave->setEnabled(enable);
|
|
|
|
|
}
|
2013-07-17 13:38:11 +02:00
|
|
|
|
ui->actionTable->setEnabled(enable);
|
2013-08-15 22:39:00 +02:00
|
|
|
|
ui->actionHistory->setEnabled(enable);
|
2013-07-17 13:38:11 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-07-25 14:00:51 +02:00
|
|
|
|
void MainWindow::ActionTable(bool checked){
|
2013-07-17 13:38:11 +02:00
|
|
|
|
if(checked){
|
2013-07-28 00:18:06 +02:00
|
|
|
|
dialogTable = new DialogIncrements(data, doc, this);
|
|
|
|
|
connect(dialogTable, &DialogIncrements::DialogClosed, this,
|
2013-07-25 14:00:51 +02:00
|
|
|
|
&MainWindow::ClosedActionTable);
|
2013-07-17 13:38:11 +02:00
|
|
|
|
dialogTable->show();
|
|
|
|
|
} else {
|
|
|
|
|
ui->actionTable->setChecked(true);
|
|
|
|
|
dialogTable->activateWindow();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-25 14:00:51 +02:00
|
|
|
|
void MainWindow::ClosedActionTable(){
|
2013-07-17 13:38:11 +02:00
|
|
|
|
ui->actionTable->setChecked(false);
|
|
|
|
|
delete dialogTable;
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-15 22:39:00 +02:00
|
|
|
|
void MainWindow::ActionHistory(bool checked){
|
|
|
|
|
if(checked){
|
|
|
|
|
dialogHistory = new DialogHistory(data, doc, this);
|
|
|
|
|
dialogHistory->setWindowFlags(Qt::Window);
|
|
|
|
|
connect(dialogHistory, &DialogHistory::DialogClosed, this,
|
|
|
|
|
&MainWindow::ClosedActionHistory);
|
|
|
|
|
dialogHistory->show();
|
|
|
|
|
} else {
|
|
|
|
|
ui->actionHistory->setChecked(true);
|
|
|
|
|
dialogHistory->activateWindow();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-29 12:31:50 +02:00
|
|
|
|
void MainWindow::ActionLayout(bool checked){
|
|
|
|
|
Q_UNUSED(checked);
|
|
|
|
|
hide();
|
|
|
|
|
QVector<VItem*> listDetails;
|
|
|
|
|
data->PrepareDetails(listDetails);
|
|
|
|
|
emit ModelChosen(listDetails);
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-15 22:39:00 +02:00
|
|
|
|
void MainWindow::ClosedActionHistory(){
|
|
|
|
|
ui->actionHistory->setChecked(false);
|
|
|
|
|
delete dialogHistory;
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-25 14:00:51 +02:00
|
|
|
|
void MainWindow::SetEnableTool(bool enable){
|
|
|
|
|
ui->toolButtonEndLine->setEnabled(enable);
|
2013-07-25 20:39:51 +02:00
|
|
|
|
ui->toolButtonLine->setEnabled(enable);
|
2013-07-28 00:18:06 +02:00
|
|
|
|
ui->toolButtonAlongLine->setEnabled(enable);
|
2013-07-29 14:55:40 +02:00
|
|
|
|
ui->toolButtonShoulderPoint->setEnabled(enable);
|
2013-07-30 15:09:34 +02:00
|
|
|
|
ui->toolButtonNormal->setEnabled(enable);
|
2013-07-30 20:46:40 +02:00
|
|
|
|
ui->toolButtonBisector->setEnabled(enable);
|
2013-07-31 13:34:39 +02:00
|
|
|
|
ui->toolButtonLineIntersect->setEnabled(enable);
|
2013-08-05 10:37:56 +02:00
|
|
|
|
ui->toolButtonSpline->setEnabled(enable);
|
2013-08-06 09:56:09 +02:00
|
|
|
|
ui->toolButtonArc->setEnabled(enable);
|
2013-08-09 08:49:34 +02:00
|
|
|
|
ui->toolButtonSplinePath->setEnabled(enable);
|
2013-08-21 10:03:53 +02:00
|
|
|
|
ui->toolButtonPointOfContact->setEnabled(enable);
|
2013-08-28 10:55:11 +02:00
|
|
|
|
ui->toolButtonNewDetail->setEnabled(enable);
|
2013-07-25 14:00:51 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-08-29 12:31:50 +02:00
|
|
|
|
void MainWindow::MinimumScrollBar(){
|
|
|
|
|
QScrollBar *horScrollBar = view->horizontalScrollBar();
|
|
|
|
|
horScrollBar->setValue(horScrollBar->minimum());
|
|
|
|
|
QScrollBar *verScrollBar = view->verticalScrollBar();
|
|
|
|
|
verScrollBar->setValue(verScrollBar->minimum());
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-13 12:51:31 +02:00
|
|
|
|
MainWindow::~MainWindow(){
|
2013-07-03 14:29:26 +02:00
|
|
|
|
CanselTool();
|
2013-06-20 16:09:50 +02:00
|
|
|
|
delete ui;
|
2013-07-13 12:51:31 +02:00
|
|
|
|
|
|
|
|
|
QFile file("lekalo.xml");
|
|
|
|
|
if(file.open(QIODevice::WriteOnly | QIODevice::Truncate)){
|
|
|
|
|
const int Indent = 4;
|
|
|
|
|
QTextStream out(&file);
|
|
|
|
|
doc->save(out, Indent);
|
|
|
|
|
file.close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
delete data;
|
|
|
|
|
if(!doc->isNull()){
|
|
|
|
|
delete doc;
|
2013-09-23 15:17:15 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::OpenPattern(const QString &fileName){
|
|
|
|
|
if(fileName.isEmpty()){
|
|
|
|
|
qWarning()<<tr("Can't open pattern file. File name empty")<<Q_FUNC_INFO;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
QFile file(fileName);
|
|
|
|
|
QString errorMsg;
|
|
|
|
|
qint32 errorLine = 0;
|
|
|
|
|
qint32 errorColumn = 0;
|
|
|
|
|
if(file.open(QIODevice::ReadOnly)){
|
|
|
|
|
if(doc->setContent(&file, &errorMsg, &errorLine, &errorColumn)){
|
|
|
|
|
disconnect(comboBoxDraws, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
|
|
|
|
this, &MainWindow::currentDrawChanged);
|
|
|
|
|
try{
|
|
|
|
|
doc->Parse(Document::FullParse, sceneDraw, sceneDetails);
|
|
|
|
|
}
|
|
|
|
|
catch(const VExceptionObjectError &e){
|
|
|
|
|
QMessageBox msgBox;
|
|
|
|
|
msgBox.setWindowTitle(tr("Error!"));
|
|
|
|
|
msgBox.setText(tr("Error parsing file."));
|
|
|
|
|
msgBox.setInformativeText(e.ErrorMessage());
|
|
|
|
|
msgBox.setStandardButtons(QMessageBox::Ok);
|
|
|
|
|
msgBox.setDefaultButton(QMessageBox::Ok);
|
|
|
|
|
msgBox.setDetailedText(e.DetailedInformation());
|
|
|
|
|
msgBox.setIcon(QMessageBox::Critical);
|
|
|
|
|
msgBox.exec();
|
|
|
|
|
file.close();
|
|
|
|
|
Clear();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
catch(const VExceptionConversionError &e){
|
|
|
|
|
QMessageBox msgBox;
|
|
|
|
|
msgBox.setWindowTitle(tr("Error!"));
|
|
|
|
|
msgBox.setText(tr("Error can't convert value."));
|
|
|
|
|
msgBox.setInformativeText(e.ErrorMessage());
|
|
|
|
|
msgBox.setStandardButtons(QMessageBox::Ok);
|
|
|
|
|
msgBox.setDefaultButton(QMessageBox::Ok);
|
|
|
|
|
msgBox.setIcon(QMessageBox::Critical);
|
|
|
|
|
msgBox.exec();
|
|
|
|
|
file.close();
|
|
|
|
|
Clear();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
catch(const VExceptionEmptyParameter &e){
|
|
|
|
|
QMessageBox msgBox;
|
|
|
|
|
msgBox.setWindowTitle(tr("Error!"));
|
|
|
|
|
msgBox.setText(tr("Error empty parameter."));
|
|
|
|
|
msgBox.setInformativeText(e.ErrorMessage());
|
|
|
|
|
msgBox.setStandardButtons(QMessageBox::Ok);
|
|
|
|
|
msgBox.setDefaultButton(QMessageBox::Ok);
|
|
|
|
|
msgBox.setDetailedText(e.DetailedInformation());
|
|
|
|
|
msgBox.setIcon(QMessageBox::Critical);
|
|
|
|
|
msgBox.exec();
|
|
|
|
|
file.close();
|
|
|
|
|
Clear();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
catch(const VExceptionWrongParameterId &e){
|
|
|
|
|
QMessageBox msgBox;
|
|
|
|
|
msgBox.setWindowTitle(tr("Error!"));
|
|
|
|
|
msgBox.setText(tr("Error wrong id."));
|
|
|
|
|
msgBox.setInformativeText(e.ErrorMessage());
|
|
|
|
|
msgBox.setStandardButtons(QMessageBox::Ok);
|
|
|
|
|
msgBox.setDefaultButton(QMessageBox::Ok);
|
|
|
|
|
msgBox.setDetailedText(e.DetailedInformation());
|
|
|
|
|
msgBox.setIcon(QMessageBox::Critical);
|
|
|
|
|
msgBox.exec();
|
|
|
|
|
file.close();
|
|
|
|
|
Clear();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
connect(comboBoxDraws, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
|
|
|
|
this, &MainWindow::currentDrawChanged);
|
|
|
|
|
QString nameDraw = doc->GetNameActivDraw();
|
|
|
|
|
qint32 index = comboBoxDraws->findText(nameDraw);
|
|
|
|
|
if ( index != -1 ) { // -1 for not found
|
|
|
|
|
comboBoxDraws->setCurrentIndex(index);
|
|
|
|
|
}
|
|
|
|
|
if(comboBoxDraws->count() > 0){
|
|
|
|
|
SetEnableTool(true);
|
|
|
|
|
} else {
|
|
|
|
|
SetEnableTool(false);
|
|
|
|
|
}
|
|
|
|
|
SetEnableWidgets(true);
|
|
|
|
|
} else {
|
|
|
|
|
QMessageBox msgBox;
|
|
|
|
|
msgBox.setWindowTitle(tr("Error!"));
|
|
|
|
|
msgBox.setText(tr("Error parsing pattern file."));
|
|
|
|
|
msgBox.setInformativeText(errorMsg);
|
|
|
|
|
msgBox.setStandardButtons(QMessageBox::Ok);
|
|
|
|
|
msgBox.setDefaultButton(QMessageBox::Ok);
|
|
|
|
|
QString error = QString(tr("Error in line %1 column %2")).arg(errorLine, errorColumn);
|
|
|
|
|
msgBox.setDetailedText(error);
|
|
|
|
|
msgBox.exec();
|
|
|
|
|
file.close();
|
|
|
|
|
Clear();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
file.close();
|
|
|
|
|
}
|
|
|
|
|
this->fileName = fileName;
|
|
|
|
|
QFileInfo info(fileName);
|
|
|
|
|
QString title(info.fileName());
|
|
|
|
|
title.append("-Valentina");
|
|
|
|
|
setWindowTitle(title);
|
2013-06-20 16:09:50 +02:00
|
|
|
|
}
|