2013-11-15 13:41:26 +01:00
|
|
|
|
/************************************************************************
|
2013-09-18 21:16:19 +02:00
|
|
|
|
**
|
2013-11-15 13:50:05 +01:00
|
|
|
|
** @file mainwindow.cpp
|
2013-11-15 13:41:26 +01:00
|
|
|
|
** @author Roman Telezhinsky <dismine@gmail.com>
|
2013-11-15 13:50:05 +01:00
|
|
|
|
** @date November 15, 2013
|
2013-09-18 21:16:19 +02:00
|
|
|
|
**
|
2013-11-15 13:41:26 +01:00
|
|
|
|
** @brief
|
|
|
|
|
** @copyright
|
|
|
|
|
** This source code is part of the Valentine project, a pattern making
|
|
|
|
|
** program, whose allow create and modeling patterns of clothing.
|
|
|
|
|
** Copyright (C) 2013 Valentina project
|
|
|
|
|
** <https://bitbucket.org/dismine/valentina> All Rights Reserved.
|
2013-09-18 21:16:19 +02:00
|
|
|
|
**
|
2013-11-15 13:41:26 +01:00
|
|
|
|
** Valentina is free software: you can redistribute it and/or modify
|
2013-09-18 21:16:19 +02:00
|
|
|
|
** 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.
|
|
|
|
|
**
|
2013-10-27 13:36:29 +01:00
|
|
|
|
** Valentina is distributed in the hope that it will be useful,
|
2013-09-18 21:16:19 +02:00
|
|
|
|
** 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-11-15 13:41:26 +01:00
|
|
|
|
*************************************************************************/
|
2013-09-18 21:16:19 +02:00
|
|
|
|
|
2013-06-20 16:09:50 +02:00
|
|
|
|
#include "mainwindow.h"
|
|
|
|
|
#include "ui_mainwindow.h"
|
2013-08-05 10:37:56 +02:00
|
|
|
|
#include "geometry/vspline.h"
|
2013-09-23 14:08:06 +02:00
|
|
|
|
#include "exception/vexceptionobjecterror.h"
|
|
|
|
|
#include "exception/vexceptionconversionerror.h"
|
|
|
|
|
#include "exception/vexceptionemptyparameter.h"
|
|
|
|
|
#include "exception/vexceptionwrongparameterid.h"
|
2013-10-07 11:13:24 +02:00
|
|
|
|
#include "exception/vexceptionuniqueid.h"
|
2013-10-23 12:40:51 +02:00
|
|
|
|
#include "version.h"
|
2013-06-20 16:09:50 +02:00
|
|
|
|
|
2013-11-21 13:05:26 +01:00
|
|
|
|
#include <QInputDialog>
|
|
|
|
|
#include <QtCore>
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
#include <QShowEvent>
|
|
|
|
|
#include <QScrollBar>
|
|
|
|
|
#include <QFileDialog>
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
MainWindow::MainWindow(QWidget *parent)
|
2013-12-29 17:48:57 +01:00
|
|
|
|
:QMainWindow(parent), ui(new Ui::MainWindow), pattern(0), doc(0), tool(Tool::ArrowTool), currentScene(0),
|
|
|
|
|
sceneDraw(0), 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>()),
|
2013-10-18 12:03:01 +02:00
|
|
|
|
dialogLineIntersect(QSharedPointer<DialogLineIntersect>()), dialogSpline(QSharedPointer<DialogSpline>()),
|
2013-08-20 12:26:02 +02:00
|
|
|
|
dialogArc(QSharedPointer<DialogArc>()), dialogSplinePath(QSharedPointer<DialogSplinePath>()),
|
2013-10-18 12:03:01 +02:00
|
|
|
|
dialogPointOfContact(QSharedPointer<DialogPointOfContact>()),
|
|
|
|
|
dialogDetail(QSharedPointer<DialogDetail>()), dialogHeight(QSharedPointer<DialogHeight>()),
|
2013-10-18 20:20:54 +02:00
|
|
|
|
dialogTriangle(QSharedPointer<DialogTriangle>()),
|
2013-10-21 16:09:05 +02:00
|
|
|
|
dialogPointOfIntersection(QSharedPointer<DialogPointOfIntersection>()),
|
2013-12-18 12:13:32 +01:00
|
|
|
|
dialogCutSpline(QSharedPointer<DialogCutSpline>()), dialogCutSplinePath (QSharedPointer<DialogCutSplinePath>()),
|
2014-01-08 15:05:32 +01:00
|
|
|
|
dialogUnionDetails(QSharedPointer<DialogUnionDetails>()), dialogCutArc(QSharedPointer<DialogCutArc>()),
|
2013-12-29 17:48:57 +01:00
|
|
|
|
dialogHistory(0), comboBoxDraws(0), fileName(QString()), changeInFile(false),
|
2014-01-12 20:23:44 +01:00
|
|
|
|
mode(Draw::Calculation), currentDrawIndex(0), currentToolBoxIndex(0), drawMode(true)
|
2013-11-04 21:35:15 +01:00
|
|
|
|
{
|
2013-06-20 16:09:50 +02:00
|
|
|
|
ui->setupUi(this);
|
2014-01-03 22:02:51 +01:00
|
|
|
|
static const char * GENERIC_ICON_TO_CHECK = "document-open";
|
|
|
|
|
static const char * FALLBACK_ICON_THEME = "win.icon.theme";
|
|
|
|
|
if (!QIcon::hasThemeIcon(GENERIC_ICON_TO_CHECK)) {
|
|
|
|
|
//If there is no default working icon theme then we should
|
|
|
|
|
//use an icon theme that we provide via a .qrc file
|
|
|
|
|
//This case happens under Windows and Mac OS X
|
|
|
|
|
//This does not happen under GNOME or KDE
|
|
|
|
|
QIcon::setThemeName(FALLBACK_ICON_THEME);
|
|
|
|
|
ui->actionNew->setIcon(QIcon::fromTheme("document-new"));
|
|
|
|
|
ui->actionOpen->setIcon(QIcon::fromTheme("document-open"));
|
|
|
|
|
ui->actionSave->setIcon(QIcon::fromTheme("document-save"));
|
|
|
|
|
ui->actionSaveAs->setIcon(QIcon::fromTheme("document-save-as"));
|
|
|
|
|
}
|
2013-07-03 14:29:26 +02:00
|
|
|
|
ToolBarOption();
|
|
|
|
|
ToolBarDraws();
|
2014-01-11 18:08:40 +01:00
|
|
|
|
sceneDraw = new VMainGraphicsScene();
|
2013-08-28 10:55:11 +02:00
|
|
|
|
currentScene = sceneDraw;
|
|
|
|
|
connect(sceneDraw, &VMainGraphicsScene::mouseMove, this, &MainWindow::mouseMove);
|
2014-01-11 18:08:40 +01:00
|
|
|
|
sceneDetails = new VMainGraphicsScene();
|
2013-08-28 10:55:11 +02:00
|
|
|
|
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);
|
2014-01-11 15:09:44 +01:00
|
|
|
|
|
|
|
|
|
sceneDraw->setTransform(view->transform());
|
|
|
|
|
sceneDetails->setTransform(view->transform());
|
|
|
|
|
|
2013-10-16 11:17:34 +02:00
|
|
|
|
connect(view, &VMainGraphicsView::NewFactor, sceneDraw, &VMainGraphicsScene::SetFactor);
|
2013-08-13 18:48:36 +02:00
|
|
|
|
QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
|
|
|
|
policy.setHorizontalStretch(12);
|
|
|
|
|
view->setSizePolicy(policy);
|
2013-12-19 11:42:00 +01:00
|
|
|
|
helpLabel = new QLabel(tr("Create new pattern piece to start working."));
|
2013-07-03 14:29:26 +02:00
|
|
|
|
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-10-18 12:03:01 +02:00
|
|
|
|
connect(ui->toolButtonHeight, &QToolButton::clicked, this, &MainWindow::ToolHeight);
|
2013-10-18 20:20:54 +02:00
|
|
|
|
connect(ui->toolButtonTriangle, &QToolButton::clicked, this, &MainWindow::ToolTriangle);
|
2013-10-21 16:09:05 +02:00
|
|
|
|
connect(ui->toolButtonPointOfIntersection, &QToolButton::clicked, this, &MainWindow::ToolPointOfIntersection);
|
2013-12-18 12:13:32 +01:00
|
|
|
|
connect(ui->toolButtonSplineCutPoint, &QToolButton::clicked, this, &MainWindow::ToolCutSpline);
|
|
|
|
|
connect(ui->toolButtonSplinePathCutPoint, &QToolButton::clicked, this, &MainWindow::ToolCutSplinePath);
|
2013-12-29 17:48:57 +01:00
|
|
|
|
connect(ui->toolButtonUnionDetails, &QToolButton::clicked, this, &MainWindow::ToolUnionDetails);
|
2014-01-08 15:05:32 +01:00
|
|
|
|
connect(ui->toolButtonArcCutPoint, &QToolButton::clicked, this, &MainWindow::ToolCutArc);
|
2013-07-13 12:51:31 +02:00
|
|
|
|
|
2013-12-29 17:48:57 +01:00
|
|
|
|
pattern = new VContainer();
|
2013-07-13 12:51:31 +02:00
|
|
|
|
|
2013-12-29 17:48:57 +01:00
|
|
|
|
doc = new VDomDocument(pattern, comboBoxDraws, &mode);
|
2013-07-13 12:51:31 +02:00
|
|
|
|
doc->CreateEmptyFile();
|
|
|
|
|
connect(doc, &VDomDocument::haveChange, this, &MainWindow::haveChange);
|
|
|
|
|
|
2013-10-04 16:00:19 +02:00
|
|
|
|
//Autosaving file each 5 minutes
|
|
|
|
|
QTimer *timer = new QTimer(this);
|
|
|
|
|
timer->setTimerType(Qt::VeryCoarseTimer);
|
|
|
|
|
connect(timer, &QTimer::timeout, this, &MainWindow::AutoSavePattern);
|
|
|
|
|
timer->start(300000);
|
2013-10-05 14:07:04 +02:00
|
|
|
|
|
|
|
|
|
connect(ui->actionAbout_Qt, &QAction::triggered, this, &MainWindow::AboutQt);
|
|
|
|
|
connect(ui->actionAbout_Valentina, &QAction::triggered, this, &MainWindow::About);
|
|
|
|
|
connect(ui->actionExit, &QAction::triggered, this, &MainWindow::close);
|
2013-10-06 18:22:21 +02:00
|
|
|
|
|
|
|
|
|
ui->toolBox->setCurrentIndex(0);
|
2013-07-13 12:51:31 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ActionNewDraw()
|
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
|
QString nameDraw;
|
|
|
|
|
bool bOk;
|
|
|
|
|
qint32 index;
|
2013-12-21 18:47:20 +01:00
|
|
|
|
QString nDraw = QString(tr("Pattern piece %1")).arg(comboBoxDraws->count()+1);
|
2013-07-13 12:51:31 +02:00
|
|
|
|
QInputDialog *dlg = new QInputDialog(this);
|
|
|
|
|
dlg->setInputMode( QInputDialog::TextInput );
|
2013-12-21 18:47:20 +01:00
|
|
|
|
dlg->setLabelText(tr("Pattern piece:"));
|
2013-07-13 12:51:31 +02:00
|
|
|
|
dlg->setTextEchoMode(QLineEdit::Normal);
|
2013-12-19 11:42:00 +01:00
|
|
|
|
dlg->setWindowTitle(tr("Enter a label for the pattern piece."));
|
2013-11-04 21:35:15 +01:00
|
|
|
|
dlg->resize(300, 100);
|
2013-07-13 12:51:31 +02:00
|
|
|
|
dlg->setTextValue(nDraw);
|
2013-11-04 21:35:15 +01:00
|
|
|
|
while (1)
|
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
|
bOk = dlg->exec();
|
|
|
|
|
nameDraw = dlg->textValue();
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if (bOk == false || nameDraw.isEmpty())
|
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
|
delete dlg;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
index = comboBoxDraws->findText(nameDraw);
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if (index != -1)
|
|
|
|
|
{//we already have this name
|
2013-12-19 11:42:00 +01:00
|
|
|
|
qCritical()<<tr("Error. Pattern piece of same label already exists.");
|
2013-11-04 21:35:15 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
delete dlg;
|
|
|
|
|
bOk = doc->appendDraw(nameDraw);
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if (bOk == false)
|
|
|
|
|
{
|
2013-12-30 12:54:38 +01:00
|
|
|
|
qCritical()<<tr("Error creating pattern with the name ")<<nameDraw<<".";
|
2013-09-18 18:52:49 +02:00
|
|
|
|
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);
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if ( index != -1 )
|
|
|
|
|
{ // -1 for not found
|
2013-07-13 12:51:31 +02:00
|
|
|
|
comboBoxDraws->setCurrentIndex(index);
|
2013-08-15 22:39:00 +02:00
|
|
|
|
currentDrawChanged( index );
|
2013-07-13 12:51:31 +02:00
|
|
|
|
}
|
2013-10-28 18:27:31 +01:00
|
|
|
|
connect(comboBoxDraws, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
|
|
|
|
|
&MainWindow::currentDrawChanged);
|
2014-01-02 16:50:01 +01:00
|
|
|
|
pattern->ClearGObjects();
|
2013-08-15 22:39:00 +02:00
|
|
|
|
//Create single point
|
2013-12-29 17:48:57 +01:00
|
|
|
|
qint64 id = pattern->AddGObject(new VPointF(toPixel((10+comboBoxDraws->count()*5)), toPixel(10), "А", 5, 10));
|
|
|
|
|
VToolSinglePoint *spoint = new VToolSinglePoint(doc, pattern, id, Tool::FromGui);
|
2013-08-28 10:55:11 +02:00
|
|
|
|
sceneDraw->addItem(spoint);
|
|
|
|
|
connect(spoint, &VToolPoint::ChoosedTool, sceneDraw, &VMainGraphicsScene::ChoosedItem);
|
2013-10-16 11:17:34 +02:00
|
|
|
|
connect(sceneDraw, &VMainGraphicsScene::NewFactor, spoint, &VToolSinglePoint::SetFactor);
|
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-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::OptionDraw()
|
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
|
QString nameDraw;
|
|
|
|
|
qint32 index;
|
|
|
|
|
QString nDraw = doc->GetNameActivDraw();
|
|
|
|
|
QInputDialog *dlg = new QInputDialog(this);
|
|
|
|
|
dlg->setInputMode( QInputDialog::TextInput );
|
2013-12-19 11:42:00 +01:00
|
|
|
|
dlg->setLabelText(tr("Pattern piece:"));
|
2013-07-13 12:51:31 +02:00
|
|
|
|
dlg->setTextEchoMode(QLineEdit::Normal);
|
2013-12-19 11:42:00 +01:00
|
|
|
|
dlg->setWindowTitle(tr("Enter a new label for the pattern piece."));
|
2013-11-04 21:35:15 +01:00
|
|
|
|
dlg->resize(300, 100);
|
2013-07-13 12:51:31 +02:00
|
|
|
|
dlg->setTextValue(nDraw);
|
2013-11-04 21:35:15 +01:00
|
|
|
|
while (1)
|
|
|
|
|
{
|
|
|
|
|
bool bOk = dlg->exec();
|
2013-07-13 12:51:31 +02:00
|
|
|
|
nameDraw = dlg->textValue();
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if (bOk == false || nameDraw.isEmpty())
|
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
|
delete dlg;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
index = comboBoxDraws->findText(nameDraw);
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if (index != -1)
|
|
|
|
|
{//we already have this name
|
2013-12-19 11:42:00 +01:00
|
|
|
|
qCritical()<<tr("Error. Pattern piece of same name already exists.");
|
2013-11-04 21:35:15 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
delete dlg;
|
|
|
|
|
index = comboBoxDraws->findText(doc->GetNameActivDraw());
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if (doc->SetNameDraw(nameDraw))
|
|
|
|
|
{
|
2013-10-10 12:00:04 +02:00
|
|
|
|
comboBoxDraws->setItemText(index, nameDraw);
|
2013-11-04 21:35:15 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2013-12-19 11:42:00 +01:00
|
|
|
|
QMessageBox::warning(this, tr("Error saving change!!!"), tr("Can't save new label of pattern piece"));
|
2013-10-10 12:00:04 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-07-03 14:29:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-08-13 18:48:36 +02:00
|
|
|
|
template <typename Dialog, typename Func>
|
2013-10-28 16:45:27 +01:00
|
|
|
|
void MainWindow::SetToolButton(bool checked, Tool::Tools t, const QString &cursor, const QString &toolTip,
|
2013-11-04 21:35:15 +01:00
|
|
|
|
QSharedPointer<Dialog> &dialog, Func closeDialogSlot)
|
|
|
|
|
{
|
|
|
|
|
if (checked)
|
|
|
|
|
{
|
2013-08-13 18:48:36 +02:00
|
|
|
|
CanselTool();
|
|
|
|
|
tool = t;
|
|
|
|
|
QPixmap pixmap(cursor);
|
|
|
|
|
QCursor cur(pixmap, 2, 3);
|
|
|
|
|
view->setCursor(cur);
|
2013-10-07 13:11:56 +02:00
|
|
|
|
helpLabel->setText(toolTip);
|
2013-12-29 17:48:57 +01:00
|
|
|
|
dialog = QSharedPointer<Dialog>(new Dialog(pattern));
|
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);
|
2013-10-07 13:11:56 +02:00
|
|
|
|
connect(dialog.data(), &Dialog::ToolTip, this, &MainWindow::ShowToolTip);
|
2013-08-13 18:48:36 +02:00
|
|
|
|
connect(doc, &VDomDocument::FullUpdateFromFile, dialog.data(), &Dialog::UpdateList);
|
2013-11-04 21:35:15 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (QToolButton *tButton = qobject_cast< QToolButton * >(this->sender()))
|
|
|
|
|
{
|
2013-10-28 16:45:27 +01:00
|
|
|
|
Q_ASSERT(tButton != 0);
|
2013-08-13 18:48:36 +02:00
|
|
|
|
tButton->setChecked(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-27 11:17:00 +02:00
|
|
|
|
template <typename T>
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::AddToolToDetail(T *tool, const qint64 &id, Tool::Tools typeTool, const qint64 &idDetail)
|
|
|
|
|
{
|
2013-10-04 13:32:42 +02:00
|
|
|
|
QHash<qint64, VDataTool*>* tools = doc->getTools();
|
2013-12-18 19:55:27 +01:00
|
|
|
|
Q_ASSERT(tools != 0);
|
2013-09-10 14:29:06 +02:00
|
|
|
|
VToolDetail *det = qobject_cast<VToolDetail*>(tools->value(idDetail));
|
2013-10-14 16:44:33 +02:00
|
|
|
|
Q_ASSERT(det != 0);
|
2013-09-10 14:29:06 +02:00
|
|
|
|
det->AddTool(tool, id, typeTool);
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-21 12:36:51 +01:00
|
|
|
|
template <typename DrawTool, typename Dialog>
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ClosedDialog(QSharedPointer<Dialog> &dialog, int result)
|
|
|
|
|
{
|
|
|
|
|
if (result == QDialog::Accepted)
|
|
|
|
|
{
|
2013-12-29 17:48:57 +01:00
|
|
|
|
DrawTool::Create(dialog, currentScene, doc, pattern);
|
2013-07-25 14:00:51 +02:00
|
|
|
|
}
|
|
|
|
|
ArrowTool();
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ToolEndLine(bool checked)
|
|
|
|
|
{
|
2013-10-29 16:17:47 +01:00
|
|
|
|
SetToolButton(checked, Tool::EndLineTool, ":/cursor/endline_cursor.png", tr("Select point"),
|
|
|
|
|
dialogEndLine, &MainWindow::ClosedDialogEndLine);
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ClosedDialogEndLine(int result)
|
|
|
|
|
{
|
2013-12-21 12:36:51 +01:00
|
|
|
|
ClosedDialog<VToolEndLine>(dialogEndLine, result);
|
2013-10-29 16:17:47 +01:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ToolLine(bool checked)
|
|
|
|
|
{
|
2013-10-07 13:11:56 +02:00
|
|
|
|
SetToolButton(checked, Tool::LineTool, ":/cursor/line_cursor.png", tr("Select first point"),
|
|
|
|
|
dialogLine, &MainWindow::ClosedDialogLine);
|
2013-07-25 20:39:51 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ClosedDialogLine(int result)
|
|
|
|
|
{
|
2013-12-21 12:36:51 +01:00
|
|
|
|
ClosedDialog<VToolLine>(dialogLine, result);
|
2013-07-25 20:39:51 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ToolAlongLine(bool checked)
|
|
|
|
|
{
|
2013-10-07 13:11:56 +02:00
|
|
|
|
SetToolButton(checked, Tool::AlongLineTool, ":/cursor/alongline_cursor.png", tr("Select point"),
|
|
|
|
|
dialogAlongLine, &MainWindow::ClosedDialogAlongLine);
|
2013-07-28 00:18:06 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ClosedDialogAlongLine(int result)
|
|
|
|
|
{
|
2013-12-21 12:36:51 +01:00
|
|
|
|
ClosedDialog<VToolAlongLine>(dialogAlongLine, result);
|
2013-07-28 00:18:06 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ToolShoulderPoint(bool checked)
|
|
|
|
|
{
|
2013-10-07 13:11:56 +02:00
|
|
|
|
SetToolButton(checked, Tool::ShoulderPointTool, ":/cursor/shoulder_cursor.png",
|
|
|
|
|
tr("Select first point of line"), dialogShoulderPoint,
|
2013-08-13 18:48:36 +02:00
|
|
|
|
&MainWindow::ClosedDialogShoulderPoint);
|
2013-07-29 14:55:40 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ClosedDialogShoulderPoint(int result)
|
|
|
|
|
{
|
2013-12-21 12:36:51 +01:00
|
|
|
|
ClosedDialog<VToolShoulderPoint>(dialogShoulderPoint, result);
|
2013-07-29 14:55:40 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ToolNormal(bool checked)
|
|
|
|
|
{
|
2013-10-07 13:11:56 +02:00
|
|
|
|
SetToolButton(checked, Tool::NormalTool, ":/cursor/normal_cursor.png",
|
|
|
|
|
tr("Select first point of line"), dialogNormal, &MainWindow::ClosedDialogNormal);
|
2013-07-30 15:09:34 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ClosedDialogNormal(int result)
|
|
|
|
|
{
|
2013-12-21 12:36:51 +01:00
|
|
|
|
ClosedDialog<VToolNormal>(dialogNormal, result);
|
2013-07-30 15:09:34 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ToolBisector(bool checked)
|
|
|
|
|
{
|
2013-10-07 13:11:56 +02:00
|
|
|
|
SetToolButton(checked, Tool::BisectorTool, ":/cursor/bisector_cursor.png",
|
|
|
|
|
tr("Select first point of angle"), dialogBisector, &MainWindow::ClosedDialogBisector);
|
2013-07-30 20:46:40 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ClosedDialogBisector(int result)
|
|
|
|
|
{
|
2013-12-21 12:36:51 +01:00
|
|
|
|
ClosedDialog<VToolBisector>(dialogBisector, result);
|
2013-07-30 20:46:40 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ToolLineIntersect(bool checked)
|
|
|
|
|
{
|
2013-10-07 13:11:56 +02:00
|
|
|
|
SetToolButton(checked, Tool::LineIntersectTool, ":/cursor/intersect_cursor.png",
|
|
|
|
|
tr("Select first point of first line"), dialogLineIntersect,
|
2013-08-13 18:48:36 +02:00
|
|
|
|
&MainWindow::ClosedDialogLineIntersect);
|
2013-07-31 13:34:39 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ClosedDialogLineIntersect(int result)
|
|
|
|
|
{
|
2013-12-21 12:36:51 +01:00
|
|
|
|
ClosedDialog<VToolLineIntersect>(dialogLineIntersect, result);
|
2013-07-31 13:34:39 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ToolSpline(bool checked)
|
|
|
|
|
{
|
2013-10-07 13:11:56 +02:00
|
|
|
|
SetToolButton(checked, Tool::SplineTool, ":/cursor/spline_cursor.png",
|
|
|
|
|
tr("Select first point curve"), dialogSpline, &MainWindow::ClosedDialogSpline);
|
2013-08-05 10:37:56 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ClosedDialogSpline(int result)
|
|
|
|
|
{
|
2013-12-21 12:36:51 +01:00
|
|
|
|
ClosedDialog<VToolSpline>(dialogSpline, result);
|
2013-08-05 10:37:56 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-12-18 12:13:32 +01:00
|
|
|
|
void MainWindow::ToolCutSpline(bool checked)
|
|
|
|
|
{
|
|
|
|
|
SetToolButton(checked, Tool::CutSplineTool, ":/cursor/spline_cut_point_cursor.png",
|
|
|
|
|
tr("Select simple curve"), dialogCutSpline, &MainWindow::ClosedDialogCutSpline);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::ClosedDialogCutSpline(int result)
|
|
|
|
|
{
|
2013-12-21 12:36:51 +01:00
|
|
|
|
ClosedDialog<VToolCutSpline>(dialogCutSpline, result);
|
2013-08-05 10:37:56 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ToolArc(bool checked)
|
|
|
|
|
{
|
2013-10-07 13:11:56 +02:00
|
|
|
|
SetToolButton(checked, Tool::ArcTool, ":/cursor/arc_cursor.png",
|
|
|
|
|
tr("Select point of center of arc"), dialogArc, &MainWindow::ClosedDialogArc);
|
2013-08-06 09:56:09 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ClosedDialogArc(int result)
|
|
|
|
|
{
|
2013-12-21 12:36:51 +01:00
|
|
|
|
ClosedDialog<VToolArc>(dialogArc, result);
|
2013-08-06 09:56:09 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ToolSplinePath(bool checked)
|
|
|
|
|
{
|
2013-10-07 13:11:56 +02:00
|
|
|
|
SetToolButton(checked, Tool::SplinePathTool, ":/cursor/splinepath_cursor.png",
|
2013-12-18 12:13:32 +01:00
|
|
|
|
tr("Select point of curve path"), dialogSplinePath, &MainWindow::ClosedDialogSplinePath);
|
2013-08-09 08:49:34 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ClosedDialogSplinePath(int result)
|
|
|
|
|
{
|
2013-12-21 12:36:51 +01:00
|
|
|
|
ClosedDialog<VToolSplinePath>(dialogSplinePath, result);
|
2013-08-09 08:49:34 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-12-18 12:13:32 +01:00
|
|
|
|
void MainWindow::ToolCutSplinePath(bool checked)
|
|
|
|
|
{
|
|
|
|
|
SetToolButton(checked, Tool::CutSplinePathTool, ":/cursor/splinepath_cut_point_cursor.png",
|
|
|
|
|
tr("Select curve path"), dialogCutSplinePath, &MainWindow::ClosedDialogCutSplinePath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::ClosedDialogCutSplinePath(int result)
|
|
|
|
|
{
|
2013-12-21 12:36:51 +01:00
|
|
|
|
ClosedDialog<VToolCutSplinePath>(dialogCutSplinePath, result);
|
2013-08-09 08:49:34 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ToolPointOfContact(bool checked)
|
|
|
|
|
{
|
2013-10-07 13:11:56 +02:00
|
|
|
|
SetToolButton(checked, Tool::PointOfContact, ":/cursor/pointcontact_cursor.png",
|
|
|
|
|
tr("Select first point of line"), dialogPointOfContact,
|
2013-08-21 10:03:53 +02:00
|
|
|
|
&MainWindow::ClosedDialogPointOfContact);
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ClosedDialogPointOfContact(int result)
|
|
|
|
|
{
|
2013-12-21 12:36:51 +01:00
|
|
|
|
ClosedDialog<VToolPointOfContact>(dialogPointOfContact, result);
|
2013-08-28 10:55:11 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ToolDetail(bool checked)
|
|
|
|
|
{
|
|
|
|
|
if (checked)
|
|
|
|
|
{
|
2013-08-28 10:55:11 +02:00
|
|
|
|
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);
|
2013-10-07 18:45:42 +02:00
|
|
|
|
helpLabel->setText(tr("Select points, arcs, curves clockwise."));
|
2013-12-29 17:48:57 +01:00
|
|
|
|
dialogDetail = QSharedPointer<DialogDetail>(new DialogDetail(pattern));
|
2013-08-28 10:55:11 +02:00
|
|
|
|
connect(currentScene, &VMainGraphicsScene::ChoosedObject, dialogDetail.data(),
|
|
|
|
|
&DialogDetail::ChoosedObject);
|
|
|
|
|
connect(dialogDetail.data(), &DialogDetail::DialogClosed, this, &MainWindow::ClosedDialogDetail);
|
|
|
|
|
connect(doc, &VDomDocument::FullUpdateFromFile, dialogDetail.data(), &DialogDetail::UpdateList);
|
2013-11-04 21:35:15 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (QToolButton *tButton = qobject_cast< QToolButton * >(this->sender()))
|
|
|
|
|
{
|
2013-08-28 10:55:11 +02:00
|
|
|
|
tButton->setChecked(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ClosedDialogDetail(int result)
|
|
|
|
|
{
|
|
|
|
|
if (result == QDialog::Accepted)
|
|
|
|
|
{
|
2013-12-29 17:48:57 +01:00
|
|
|
|
VToolDetail::Create(dialogDetail, sceneDetails, doc, pattern);
|
2013-08-21 10:03:53 +02:00
|
|
|
|
}
|
|
|
|
|
ArrowTool();
|
2014-01-07 11:04:29 +01:00
|
|
|
|
doc->FullUpdateTree();
|
2013-08-21 10:03:53 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ToolHeight(bool checked)
|
|
|
|
|
{
|
2013-10-18 12:03:01 +02:00
|
|
|
|
SetToolButton(checked, Tool::Height, ":/cursor/height_cursor.png", tr("Select base point"),
|
|
|
|
|
dialogHeight, &MainWindow::ClosedDialogHeight);
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ClosedDialogHeight(int result)
|
|
|
|
|
{
|
2013-12-21 12:36:51 +01:00
|
|
|
|
ClosedDialog<VToolHeight>(dialogHeight, result);
|
2013-10-18 12:03:01 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ToolTriangle(bool checked)
|
|
|
|
|
{
|
2013-10-18 20:20:54 +02:00
|
|
|
|
SetToolButton(checked, Tool::Triangle, ":/cursor/triangle_cursor.png", tr("Select first point of axis"),
|
2013-10-21 16:09:05 +02:00
|
|
|
|
dialogTriangle, &MainWindow::ClosedDialogTriangle);
|
2013-10-18 20:20:54 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ClosedDialogTriangle(int result)
|
|
|
|
|
{
|
2013-12-21 12:36:51 +01:00
|
|
|
|
ClosedDialog<VToolTriangle>(dialogTriangle, result);
|
2013-10-18 20:20:54 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ToolPointOfIntersection(bool checked)
|
|
|
|
|
{
|
2013-10-21 16:09:05 +02:00
|
|
|
|
SetToolButton(checked, Tool::PointOfIntersection, ":/cursor/pointofintersect_cursor.png",
|
|
|
|
|
tr("Select point vertically"),
|
|
|
|
|
dialogPointOfIntersection, &MainWindow::ClosedDialogPointOfIntersection);
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ClosedDialogPointOfIntersection(int result)
|
|
|
|
|
{
|
2013-12-21 12:36:51 +01:00
|
|
|
|
ClosedDialog<VToolPointOfIntersection>(dialogPointOfIntersection, result);
|
2013-10-21 16:09:05 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-12-29 17:48:57 +01:00
|
|
|
|
void MainWindow::ToolUnionDetails(bool checked)
|
|
|
|
|
{
|
|
|
|
|
SetToolButton(checked, Tool::UnionDetails, ":/cursor/union_cursor.png",
|
|
|
|
|
tr("Select detail"), dialogUnionDetails, &MainWindow::ClosedDialogUnionDetails);
|
2014-01-02 16:50:01 +01:00
|
|
|
|
//Must disconnect this signal here.
|
|
|
|
|
disconnect(doc, &VDomDocument::FullUpdateFromFile, dialogUnionDetails.data(), &DialogUnionDetails::UpdateList);
|
2013-12-29 17:48:57 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-01-08 15:05:32 +01:00
|
|
|
|
void MainWindow::ToolCutArc(bool checked)
|
|
|
|
|
{
|
|
|
|
|
SetToolButton(checked, Tool::CutArcTool, ":/cursor/arc_cut_cursor.png",
|
|
|
|
|
tr("Select arc"), dialogCutArc, &MainWindow::ClosedDialogCutArc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::ClosedDialogCutArc(int result)
|
|
|
|
|
{
|
|
|
|
|
ClosedDialog<VToolCutArc>(dialogCutArc, result);
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-29 17:48:57 +01:00
|
|
|
|
void MainWindow::ClosedDialogUnionDetails(int result)
|
|
|
|
|
{
|
|
|
|
|
ClosedDialog<VToolUnionDetails>(dialogUnionDetails, result);
|
2014-01-07 12:46:58 +01:00
|
|
|
|
doc->FullUpdateTree();
|
2013-12-29 17:48:57 +01:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::About()
|
|
|
|
|
{
|
2013-10-23 12:40:51 +02:00
|
|
|
|
QString fullName = QString("Valentina %1").arg(APP_VERSION);
|
|
|
|
|
QString qtBase(tr("Based on Qt %2 (32 bit)").arg(QT_VERSION_STR));
|
|
|
|
|
QString buildOn(tr("Built on %3 at %4").arg(__DATE__).arg(__TIME__));
|
2013-11-04 21:35:15 +01:00
|
|
|
|
QString about = QString(tr("<h1>%1</h1> %2 <br/><br/> %3 <br/><br/> %4")).arg(fullName).arg(qtBase).arg(
|
|
|
|
|
buildOn).arg(WARRANTY);
|
2013-10-23 12:40:51 +02:00
|
|
|
|
QMessageBox::about(this, tr("About Valentina"), about);
|
2013-10-05 14:07:04 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::AboutQt()
|
|
|
|
|
{
|
2013-10-05 14:07:04 +02:00
|
|
|
|
QMessageBox::aboutQt(this, tr("About Qt"));
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ShowToolTip(const QString &toolTip)
|
|
|
|
|
{
|
2013-10-07 13:11:56 +02:00
|
|
|
|
helpLabel->setText(toolTip);
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::tableClosed()
|
|
|
|
|
{
|
2013-08-29 12:31:50 +02:00
|
|
|
|
show();
|
|
|
|
|
MinimumScrollBar();
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::showEvent( QShowEvent *event )
|
|
|
|
|
{
|
2013-07-03 14:29:26 +02:00
|
|
|
|
QMainWindow::showEvent( event );
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if ( event->spontaneous() )
|
|
|
|
|
{
|
2013-07-03 14:29:26 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if (isInitialized)
|
|
|
|
|
{
|
2013-07-03 14:29:26 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
// do your init stuff here
|
2014-01-11 18:08:40 +01:00
|
|
|
|
|
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-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::closeEvent(QCloseEvent *event)
|
|
|
|
|
{
|
|
|
|
|
if (changeInFile == true)
|
|
|
|
|
{
|
2013-09-26 15:47:46 +02:00
|
|
|
|
QMessageBox msgBox;
|
2013-10-04 15:22:37 +02:00
|
|
|
|
msgBox.setText(tr("The pattern has been modified."));
|
|
|
|
|
msgBox.setInformativeText(tr("Do you want to save your changes?"));
|
2013-09-26 15:47:46 +02:00
|
|
|
|
msgBox.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
|
|
|
|
|
msgBox.setDefaultButton(QMessageBox::Save);
|
|
|
|
|
msgBox.setIcon(QMessageBox::Question);
|
|
|
|
|
int ret = msgBox.exec();
|
2013-11-04 21:35:15 +01:00
|
|
|
|
switch (ret)
|
|
|
|
|
{
|
|
|
|
|
case QMessageBox::Save:
|
|
|
|
|
// Save was clicked
|
|
|
|
|
if (fileName.isEmpty())
|
|
|
|
|
{
|
|
|
|
|
ActionSaveAs();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ActionSave();
|
|
|
|
|
}
|
|
|
|
|
if (changeInFile)
|
|
|
|
|
{
|
|
|
|
|
// We did't save file
|
|
|
|
|
event->ignore();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// We have successfully saved the file
|
|
|
|
|
event->accept();
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case QMessageBox::Discard:
|
|
|
|
|
// Don't Save was clicked
|
|
|
|
|
event->accept();
|
|
|
|
|
break;
|
|
|
|
|
case QMessageBox::Cancel:
|
|
|
|
|
// Cancel was clicked
|
2013-10-04 15:22:37 +02:00
|
|
|
|
event->ignore();
|
2013-11-04 21:35:15 +01:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
// should never be reached
|
2013-10-04 15:22:37 +02:00
|
|
|
|
event->accept();
|
2013-11-04 21:35:15 +01:00
|
|
|
|
break;
|
2013-09-26 15:47:46 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ToolBarOption()
|
|
|
|
|
{
|
2013-07-03 14:29:26 +02:00
|
|
|
|
QLabel * labelGrowth = new QLabel;
|
2013-12-30 12:54:38 +01:00
|
|
|
|
labelGrowth->setText(tr("Height: "));
|
2013-07-03 14:29:26 +02:00
|
|
|
|
ui->toolBarOption->addWidget(labelGrowth);
|
|
|
|
|
|
2013-06-20 16:09:50 +02:00
|
|
|
|
QStringList list;
|
2013-11-04 21:35:15 +01:00
|
|
|
|
list <<"92"<<"98"<<"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);
|
2013-11-04 21:35:15 +01:00
|
|
|
|
comboBoxGrow->setCurrentIndex(14);
|
2013-07-03 14:29:26 +02:00
|
|
|
|
ui->toolBarOption->addWidget(comboBoxGrow);
|
2014-01-09 15:56:53 +01:00
|
|
|
|
connect(comboBoxGrow, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
|
2013-07-17 13:38:11 +02:00
|
|
|
|
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-11-04 21:35:15 +01:00
|
|
|
|
list <<"22"<<"24"<<"26"<<"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-11-04 21:35:15 +01:00
|
|
|
|
comboBoxSize->setCurrentIndex(14);
|
2013-06-20 16:09:50 +02:00
|
|
|
|
ui->toolBarOption->addWidget(comboBoxSize);
|
2014-01-09 15:56:53 +01:00
|
|
|
|
connect(comboBoxSize, static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),
|
2013-07-17 13:38:11 +02:00
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ToolBarDraws()
|
|
|
|
|
{
|
2013-07-03 14:29:26 +02:00
|
|
|
|
QLabel * labelNameDraw = new QLabel;
|
2013-12-21 18:47:20 +01:00
|
|
|
|
labelNameDraw ->setText(tr("Pattern Piece: "));
|
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);
|
2014-01-12 21:04:15 +01:00
|
|
|
|
ui->actionLayout->setEnabled(false);
|
2013-07-13 12:51:31 +02:00
|
|
|
|
}
|
2013-07-03 14:29:26 +02:00
|
|
|
|
|
2013-11-04 21:35:15 +01: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));
|
2014-01-12 20:23:44 +01:00
|
|
|
|
if(drawMode)
|
2014-01-10 10:16:55 +01:00
|
|
|
|
{
|
2014-01-12 21:08:52 +01:00
|
|
|
|
ArrowTool();
|
2014-01-12 20:23:44 +01:00
|
|
|
|
qint64 id = doc->SPointActiveDraw();
|
|
|
|
|
if (id != 0)
|
|
|
|
|
{
|
|
|
|
|
const VPointF *p = pattern->GeometricObject<const VPointF *>(id);
|
|
|
|
|
view->centerOn(p->toQPointF());
|
|
|
|
|
}
|
2014-01-10 10:16:55 +01:00
|
|
|
|
}
|
2013-07-13 12:51:31 +02:00
|
|
|
|
}
|
2013-07-03 14:29:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-06 22:11:12 +01:00
|
|
|
|
void MainWindow::mouseMove(const QPointF &scenePos)
|
2013-11-04 21:35:15 +01:00
|
|
|
|
{
|
2013-07-03 14:29:26 +02:00
|
|
|
|
QString string = QString("%1, %2")
|
2013-10-28 18:27:31 +01:00
|
|
|
|
.arg(static_cast<qint32>(toMM(scenePos.x())))
|
|
|
|
|
.arg(static_cast<qint32>(toMM(scenePos.y())));
|
2013-07-03 14:29:26 +02:00
|
|
|
|
mouseCoordinate->setText(string);
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::CanselTool()
|
|
|
|
|
{
|
|
|
|
|
switch ( tool )
|
|
|
|
|
{
|
|
|
|
|
case Tool::ArrowTool:
|
|
|
|
|
ui->actionArrowTool->setChecked(false);
|
|
|
|
|
helpLabel->setText("");
|
|
|
|
|
break;
|
|
|
|
|
case Tool::SinglePointTool:
|
|
|
|
|
Q_UNREACHABLE();
|
|
|
|
|
//Nothing to do here because we can't create this tool from main window.
|
|
|
|
|
break;
|
|
|
|
|
case Tool::EndLineTool:
|
|
|
|
|
dialogEndLine.clear();
|
|
|
|
|
ui->toolButtonEndLine->setChecked(false);
|
|
|
|
|
currentScene->setFocus(Qt::OtherFocusReason);
|
|
|
|
|
currentScene->clearSelection();
|
|
|
|
|
break;
|
|
|
|
|
case Tool::LineTool:
|
|
|
|
|
dialogLine.clear();
|
|
|
|
|
ui->toolButtonLine->setChecked(false);
|
|
|
|
|
currentScene->setFocus(Qt::OtherFocusReason);
|
|
|
|
|
currentScene->clearFocus();
|
|
|
|
|
break;
|
|
|
|
|
case Tool::AlongLineTool:
|
|
|
|
|
dialogAlongLine.clear();
|
|
|
|
|
ui->toolButtonAlongLine->setChecked(false);
|
|
|
|
|
currentScene->setFocus(Qt::OtherFocusReason);
|
|
|
|
|
currentScene->clearSelection();
|
|
|
|
|
break;
|
|
|
|
|
case Tool::ShoulderPointTool:
|
|
|
|
|
dialogShoulderPoint.clear();
|
|
|
|
|
ui->toolButtonShoulderPoint->setChecked(false);
|
|
|
|
|
currentScene->setFocus(Qt::OtherFocusReason);
|
|
|
|
|
currentScene->clearSelection();
|
|
|
|
|
break;
|
|
|
|
|
case Tool::NormalTool:
|
|
|
|
|
dialogNormal.clear();
|
|
|
|
|
ui->toolButtonNormal->setChecked(false);
|
|
|
|
|
currentScene->setFocus(Qt::OtherFocusReason);
|
|
|
|
|
currentScene->clearSelection();
|
|
|
|
|
break;
|
|
|
|
|
case Tool::BisectorTool:
|
|
|
|
|
dialogBisector.clear();
|
|
|
|
|
ui->toolButtonBisector->setChecked(false);
|
|
|
|
|
currentScene->setFocus(Qt::OtherFocusReason);
|
|
|
|
|
currentScene->clearSelection();
|
|
|
|
|
break;
|
|
|
|
|
case Tool::LineIntersectTool:
|
|
|
|
|
dialogLineIntersect.clear();
|
|
|
|
|
ui->toolButtonLineIntersect->setChecked(false);
|
|
|
|
|
currentScene->setFocus(Qt::OtherFocusReason);
|
|
|
|
|
currentScene->clearSelection();
|
|
|
|
|
break;
|
|
|
|
|
case Tool::SplineTool:
|
|
|
|
|
dialogSpline.clear();
|
|
|
|
|
ui->toolButtonSpline->setChecked(false);
|
|
|
|
|
currentScene->setFocus(Qt::OtherFocusReason);
|
|
|
|
|
currentScene->clearSelection();
|
|
|
|
|
break;
|
|
|
|
|
case Tool::ArcTool:
|
|
|
|
|
dialogArc.clear();
|
|
|
|
|
ui->toolButtonArc->setChecked(false);
|
|
|
|
|
currentScene->setFocus(Qt::OtherFocusReason);
|
|
|
|
|
currentScene->clearSelection();
|
|
|
|
|
break;
|
|
|
|
|
case Tool::SplinePathTool:
|
|
|
|
|
dialogSplinePath.clear();
|
|
|
|
|
ui->toolButtonSplinePath->setChecked(false);
|
|
|
|
|
currentScene->setFocus(Qt::OtherFocusReason);
|
|
|
|
|
currentScene->clearSelection();
|
|
|
|
|
break;
|
|
|
|
|
case Tool::PointOfContact:
|
|
|
|
|
dialogPointOfContact.clear();
|
|
|
|
|
ui->toolButtonPointOfContact->setChecked(false);
|
|
|
|
|
currentScene->setFocus(Qt::OtherFocusReason);
|
|
|
|
|
currentScene->clearSelection();
|
|
|
|
|
break;
|
|
|
|
|
case Tool::Detail:
|
|
|
|
|
dialogDetail.clear();
|
|
|
|
|
ui->toolButtonNewDetail->setChecked(false);
|
|
|
|
|
break;
|
|
|
|
|
case Tool::Height:
|
|
|
|
|
dialogHeight.clear();
|
|
|
|
|
ui->toolButtonHeight->setChecked(false);
|
|
|
|
|
currentScene->setFocus(Qt::OtherFocusReason);
|
|
|
|
|
currentScene->clearSelection();
|
|
|
|
|
break;
|
|
|
|
|
case Tool::Triangle:
|
|
|
|
|
dialogTriangle.clear();
|
|
|
|
|
ui->toolButtonTriangle->setChecked(false);
|
|
|
|
|
currentScene->setFocus(Qt::OtherFocusReason);
|
|
|
|
|
currentScene->clearSelection();
|
|
|
|
|
break;
|
|
|
|
|
case Tool::PointOfIntersection:
|
|
|
|
|
dialogPointOfIntersection.clear();
|
|
|
|
|
ui->toolButtonPointOfIntersection->setChecked(false);
|
|
|
|
|
currentScene->setFocus(Qt::OtherFocusReason);
|
|
|
|
|
currentScene->clearSelection();
|
|
|
|
|
break;
|
2013-12-18 12:13:32 +01:00
|
|
|
|
case Tool::CutSplineTool:
|
|
|
|
|
dialogCutSpline.clear();
|
|
|
|
|
ui->toolButtonSplineCutPoint->setChecked(false);
|
|
|
|
|
currentScene->setFocus(Qt::OtherFocusReason);
|
|
|
|
|
currentScene->clearSelection();
|
|
|
|
|
break;
|
|
|
|
|
case Tool::CutSplinePathTool:
|
|
|
|
|
dialogCutSplinePath.clear();
|
|
|
|
|
ui->toolButtonSplinePathCutPoint->setChecked(false);
|
|
|
|
|
currentScene->setFocus(Qt::OtherFocusReason);
|
|
|
|
|
currentScene->clearSelection();
|
|
|
|
|
break;
|
2014-01-02 16:50:01 +01:00
|
|
|
|
case Tool::UnionDetails:
|
|
|
|
|
dialogUnionDetails.clear();
|
|
|
|
|
ui->toolButtonUnionDetails->setChecked(false);
|
|
|
|
|
currentScene->setFocus(Qt::OtherFocusReason);
|
|
|
|
|
currentScene->clearSelection();
|
|
|
|
|
break;
|
2014-01-08 15:05:32 +01:00
|
|
|
|
case Tool::CutArcTool:
|
|
|
|
|
dialogCutArc.clear();
|
|
|
|
|
ui->toolButtonArcCutPoint->setChecked(false);
|
|
|
|
|
currentScene->setFocus(Qt::OtherFocusReason);
|
|
|
|
|
currentScene->clearSelection();
|
|
|
|
|
break;
|
2013-11-04 21:35:15 +01:00
|
|
|
|
default:
|
2013-12-21 18:47:20 +01:00
|
|
|
|
qWarning()<<"Got wrong tool type. Ignored.";
|
2013-11-04 21:35:15 +01:00
|
|
|
|
break;
|
2013-07-03 14:29:26 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ArrowTool()
|
|
|
|
|
{
|
2013-07-03 14:29:26 +02:00
|
|
|
|
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-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ActionAroowTool()
|
|
|
|
|
{
|
2013-07-03 14:29:26 +02:00
|
|
|
|
ArrowTool();
|
2013-06-20 16:09:50 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::keyPressEvent ( QKeyEvent * event )
|
|
|
|
|
{
|
|
|
|
|
switch (event->key())
|
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
|
case Qt::Key_Escape:
|
|
|
|
|
ArrowTool();
|
|
|
|
|
break;
|
2013-11-12 19:29:03 +01:00
|
|
|
|
default:
|
|
|
|
|
break;
|
2013-07-13 12:51:31 +02:00
|
|
|
|
}
|
|
|
|
|
QMainWindow::keyPressEvent ( event );
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-11 15:09:44 +01:00
|
|
|
|
void MainWindow::SaveCurrentScene()
|
|
|
|
|
{
|
|
|
|
|
/*Save transform*/
|
|
|
|
|
currentScene->setTransform(view->transform());
|
|
|
|
|
/*Save scroll bars value for previous scene.*/
|
|
|
|
|
QScrollBar *horScrollBar = view->horizontalScrollBar();
|
|
|
|
|
currentScene->setHorScrollBar(horScrollBar->value());
|
|
|
|
|
QScrollBar *verScrollBar = view->verticalScrollBar();
|
|
|
|
|
currentScene->setVerScrollBar(verScrollBar->value());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::RestoreCurrentScene()
|
|
|
|
|
{
|
|
|
|
|
/*Set transform for current scene*/
|
|
|
|
|
view->setTransform(currentScene->transform());
|
|
|
|
|
/*Set value for current scene scroll bar.*/
|
|
|
|
|
QScrollBar *horScrollBar = view->horizontalScrollBar();
|
|
|
|
|
horScrollBar->setValue(currentScene->getHorScrollBar());
|
|
|
|
|
QScrollBar *verScrollBar = view->verticalScrollBar();
|
|
|
|
|
verScrollBar->setValue(currentScene->getVerScrollBar());
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ActionDraw(bool checked)
|
|
|
|
|
{
|
|
|
|
|
if (checked)
|
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
|
ui->actionDetails->setChecked(false);
|
2014-01-11 15:09:44 +01:00
|
|
|
|
SaveCurrentScene();
|
2013-09-17 20:13:02 +02:00
|
|
|
|
|
2013-08-28 10:55:11 +02:00
|
|
|
|
currentScene = sceneDraw;
|
|
|
|
|
view->setScene(currentScene);
|
2014-01-11 15:09:44 +01:00
|
|
|
|
RestoreCurrentScene();
|
2013-09-17 20:13:02 +02:00
|
|
|
|
|
2014-01-08 15:05:32 +01:00
|
|
|
|
mode = Draw::Calculation;
|
2014-01-09 15:56:53 +01:00
|
|
|
|
comboBoxDraws->setEnabled(true);
|
2014-01-07 11:04:29 +01:00
|
|
|
|
comboBoxDraws->setCurrentIndex(currentDrawIndex);//restore current pattern peace
|
2014-01-12 20:23:44 +01:00
|
|
|
|
drawMode = true;
|
2014-01-02 16:50:01 +01:00
|
|
|
|
|
2013-12-21 13:57:20 +01:00
|
|
|
|
SetEnableTool(true);
|
2013-08-29 12:31:50 +02:00
|
|
|
|
doc->setCurrentData();
|
2014-01-08 21:45:42 +01:00
|
|
|
|
ui->toolBox->setCurrentIndex(currentToolBoxIndex);
|
2014-01-12 21:04:15 +01:00
|
|
|
|
|
|
|
|
|
ui->actionHistory->setEnabled(true);
|
|
|
|
|
ui->actionLayout->setEnabled(false);
|
|
|
|
|
ui->actionOptionDraw->setEnabled(true);
|
|
|
|
|
ui->actionNewDraw->setEnabled(true);
|
2013-11-04 21:35:15 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
|
ui->actionDraw->setChecked(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ActionDetails(bool checked)
|
|
|
|
|
{
|
|
|
|
|
if (checked)
|
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
|
ui->actionDraw->setChecked(false);
|
2014-01-11 15:09:44 +01:00
|
|
|
|
SaveCurrentScene();
|
2013-09-17 20:13:02 +02:00
|
|
|
|
|
2013-08-28 10:55:11 +02:00
|
|
|
|
currentScene = sceneDetails;
|
|
|
|
|
view->setScene(sceneDetails);
|
2014-01-11 15:09:44 +01:00
|
|
|
|
RestoreCurrentScene();
|
2014-01-02 16:50:01 +01:00
|
|
|
|
|
2014-01-12 20:23:44 +01:00
|
|
|
|
drawMode = false;
|
2014-01-07 11:04:29 +01:00
|
|
|
|
currentDrawIndex = comboBoxDraws->currentIndex();//save current pattern peace
|
2014-01-02 16:50:01 +01:00
|
|
|
|
comboBoxDraws->setCurrentIndex(comboBoxDraws->count()-1);
|
2014-01-09 15:56:53 +01:00
|
|
|
|
comboBoxDraws->setEnabled(false);
|
2014-01-02 16:50:01 +01:00
|
|
|
|
|
2014-01-12 20:23:44 +01:00
|
|
|
|
|
2013-08-28 10:55:11 +02:00
|
|
|
|
mode = Draw::Modeling;
|
2013-12-21 13:57:20 +01:00
|
|
|
|
SetEnableTool(true);
|
2014-01-08 21:45:42 +01:00
|
|
|
|
currentToolBoxIndex = ui->toolBox->currentIndex();
|
2013-12-21 13:57:20 +01:00
|
|
|
|
ui->toolBox->setCurrentIndex(4);
|
2014-01-12 21:04:15 +01:00
|
|
|
|
|
|
|
|
|
ui->actionHistory->setEnabled(false);
|
|
|
|
|
ui->actionLayout->setEnabled(true);
|
|
|
|
|
ui->actionOptionDraw->setEnabled(false);
|
|
|
|
|
ui->actionNewDraw->setEnabled(false);
|
2013-11-04 21:35:15 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
|
ui->actionDetails->setChecked(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ActionSaveAs()
|
|
|
|
|
{
|
2013-10-04 15:22:37 +02:00
|
|
|
|
QString filters(tr("Lekalo files (*.xml);;All files (*.*)"));
|
|
|
|
|
QString defaultFilter(tr("Lekalo files (*.xml)"));
|
|
|
|
|
QString fName = QFileDialog::getSaveFileName(this, tr("Save as"), QDir::homePath(),
|
2013-09-30 18:29:03 +02:00
|
|
|
|
filters, &defaultFilter);
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if (fName.isEmpty())
|
|
|
|
|
{
|
2013-08-13 18:48:36 +02:00
|
|
|
|
return;
|
2013-11-04 21:35:15 +01:00
|
|
|
|
}
|
|
|
|
|
if (fName.indexOf(".xml", fName.size()-4)<0)
|
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
|
fName.append(".xml");
|
|
|
|
|
}
|
|
|
|
|
fileName = fName;
|
|
|
|
|
|
2013-10-04 15:22:37 +02:00
|
|
|
|
ActionSave();
|
2013-07-13 12:51:31 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ActionSave()
|
|
|
|
|
{
|
|
|
|
|
if (fileName.isEmpty() == false)
|
|
|
|
|
{
|
2013-10-04 15:22:37 +02:00
|
|
|
|
bool result = SafeSaveing(fileName);
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if (result)
|
|
|
|
|
{
|
2013-10-04 15:22:37 +02:00
|
|
|
|
ui->actionSave->setEnabled(false);
|
|
|
|
|
changeInFile = false;
|
|
|
|
|
QFileInfo info(fileName);
|
|
|
|
|
QString title(info.fileName());
|
|
|
|
|
title.append("-Valentina");
|
|
|
|
|
setWindowTitle(title);
|
2013-11-04 21:35:15 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2013-10-04 15:22:37 +02:00
|
|
|
|
QMessageBox msgBox;
|
|
|
|
|
msgBox.setWindowTitle(tr("Error!"));
|
|
|
|
|
msgBox.setText(tr("Error saving file. Can't save file."));
|
|
|
|
|
msgBox.setStandardButtons(QMessageBox::Ok);
|
|
|
|
|
msgBox.setDefaultButton(QMessageBox::Ok);
|
|
|
|
|
msgBox.setIcon(QMessageBox::Warning);
|
|
|
|
|
msgBox.exec();
|
2013-07-13 12:51:31 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01: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-11-04 21:35:15 +01:00
|
|
|
|
if (fName.isEmpty())
|
|
|
|
|
{
|
2013-08-13 18:48:36 +02:00
|
|
|
|
return;
|
2013-11-04 21:35:15 +01:00
|
|
|
|
}
|
|
|
|
|
if (fileName.isEmpty() && changeInFile == false)
|
|
|
|
|
{
|
2013-09-23 15:17:15 +02:00
|
|
|
|
OpenPattern(fName);
|
2014-01-12 20:23:44 +01:00
|
|
|
|
|
|
|
|
|
QRectF rect = sceneDraw->itemsBoundingRect();
|
|
|
|
|
//Correct BoundingRect
|
|
|
|
|
rect = QRectF(0, 0, rect.width() + rect.x(), rect.height() + rect.y());
|
|
|
|
|
|
|
|
|
|
QRect rec = view->contentsRect();
|
|
|
|
|
//Correct contentsRect
|
|
|
|
|
rec = QRect(0, 0, rec.width() - rec.x(), rec.height() - rec.y());
|
|
|
|
|
|
|
|
|
|
if(rec.contains(rect.toRect()))
|
|
|
|
|
{
|
|
|
|
|
sceneDraw->setSceneRect(rec);
|
|
|
|
|
sceneDetails->setSceneRect(rec);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
rect = rect.united(rec);
|
|
|
|
|
sceneDraw->setSceneRect(rect);
|
|
|
|
|
sceneDetails->setSceneRect(rect);
|
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2013-09-23 15:17:15 +02:00
|
|
|
|
/*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-11-04 21:35:15 +01: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-12-29 17:48:57 +01:00
|
|
|
|
pattern->Clear();
|
2013-07-13 12:51:31 +02:00
|
|
|
|
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-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ActionNew()
|
|
|
|
|
{
|
2013-09-23 15:17:15 +02:00
|
|
|
|
QProcess *v = new QProcess(this);
|
|
|
|
|
v->startDetached(QCoreApplication::applicationFilePath ());
|
|
|
|
|
delete v;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::haveChange()
|
|
|
|
|
{
|
|
|
|
|
if (fileName.isEmpty() == false)
|
|
|
|
|
{
|
2013-07-13 12:51:31 +02:00
|
|
|
|
ui->actionSave->setEnabled(true);
|
2013-09-23 15:17:15 +02:00
|
|
|
|
changeInFile = true;
|
2013-10-04 15:22:37 +02:00
|
|
|
|
QFileInfo info(fileName);
|
|
|
|
|
QString title(info.fileName());
|
|
|
|
|
title.append("*-Valentina");
|
|
|
|
|
setWindowTitle(title);
|
2013-07-13 12:51:31 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ChangedSize(const QString & text)
|
|
|
|
|
{
|
2013-07-17 13:38:11 +02:00
|
|
|
|
qint32 size = text.toInt();
|
2013-12-29 17:48:57 +01:00
|
|
|
|
pattern->SetSize(size*10);
|
2013-07-17 13:38:11 +02:00
|
|
|
|
doc->FullUpdateTree();
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ChangedGrowth(const QString &text)
|
|
|
|
|
{
|
2013-07-17 13:38:11 +02:00
|
|
|
|
qint32 growth = text.toInt();
|
2013-12-29 17:48:57 +01:00
|
|
|
|
pattern->SetGrowth(growth*10);
|
2013-07-17 13:38:11 +02:00
|
|
|
|
doc->FullUpdateTree();
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::SetEnableWidgets(bool enable)
|
|
|
|
|
{
|
2013-07-17 13:38:11 +02:00
|
|
|
|
ui->actionSaveAs->setEnabled(enable);
|
|
|
|
|
ui->actionDraw->setEnabled(enable);
|
|
|
|
|
ui->actionDetails->setEnabled(enable);
|
|
|
|
|
ui->actionOptionDraw->setEnabled(enable);
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if (enable == true && fileName.isEmpty() == false)
|
|
|
|
|
{
|
2013-07-25 14:00:51 +02:00
|
|
|
|
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-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ActionTable(bool checked)
|
|
|
|
|
{
|
|
|
|
|
if (checked)
|
|
|
|
|
{
|
2013-12-29 17:48:57 +01:00
|
|
|
|
dialogTable = new DialogIncrements(pattern, doc, this);
|
2013-07-28 00:18:06 +02:00
|
|
|
|
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();
|
2013-11-04 21:35:15 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2013-07-17 13:38:11 +02:00
|
|
|
|
ui->actionTable->setChecked(true);
|
|
|
|
|
dialogTable->activateWindow();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ClosedActionTable()
|
|
|
|
|
{
|
2013-07-17 13:38:11 +02:00
|
|
|
|
ui->actionTable->setChecked(false);
|
|
|
|
|
delete dialogTable;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ActionHistory(bool checked)
|
|
|
|
|
{
|
|
|
|
|
if (checked)
|
|
|
|
|
{
|
2013-12-29 17:48:57 +01:00
|
|
|
|
dialogHistory = new DialogHistory(pattern, doc, this);
|
2013-08-15 22:39:00 +02:00
|
|
|
|
dialogHistory->setWindowFlags(Qt::Window);
|
|
|
|
|
connect(dialogHistory, &DialogHistory::DialogClosed, this,
|
|
|
|
|
&MainWindow::ClosedActionHistory);
|
|
|
|
|
dialogHistory->show();
|
2013-11-04 21:35:15 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2013-08-15 22:39:00 +02:00
|
|
|
|
ui->actionHistory->setChecked(true);
|
|
|
|
|
dialogHistory->activateWindow();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ActionLayout(bool checked)
|
|
|
|
|
{
|
2013-08-29 12:31:50 +02:00
|
|
|
|
Q_UNUSED(checked);
|
|
|
|
|
hide();
|
|
|
|
|
QVector<VItem*> listDetails;
|
2013-12-29 17:48:57 +01:00
|
|
|
|
pattern->PrepareDetails(listDetails);
|
2013-08-29 12:31:50 +02:00
|
|
|
|
emit ModelChosen(listDetails);
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::ClosedActionHistory()
|
|
|
|
|
{
|
2013-08-15 22:39:00 +02:00
|
|
|
|
ui->actionHistory->setChecked(false);
|
|
|
|
|
delete dialogHistory;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::SetEnableTool(bool enable)
|
|
|
|
|
{
|
2013-12-21 13:57:20 +01:00
|
|
|
|
bool drawTools = false;
|
|
|
|
|
bool modelingTools = false;
|
2013-12-31 09:44:54 +01:00
|
|
|
|
if (mode == Draw::Calculation)
|
2013-12-21 13:57:20 +01:00
|
|
|
|
{
|
|
|
|
|
drawTools = enable;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2013-12-23 18:23:50 +01:00
|
|
|
|
modelingTools = enable;
|
2013-12-21 13:57:20 +01:00
|
|
|
|
}
|
|
|
|
|
//Drawing Tools
|
|
|
|
|
ui->toolButtonEndLine->setEnabled(drawTools);
|
|
|
|
|
ui->toolButtonLine->setEnabled(drawTools);
|
|
|
|
|
ui->toolButtonAlongLine->setEnabled(drawTools);
|
|
|
|
|
ui->toolButtonShoulderPoint->setEnabled(drawTools);
|
|
|
|
|
ui->toolButtonNormal->setEnabled(drawTools);
|
|
|
|
|
ui->toolButtonBisector->setEnabled(drawTools);
|
|
|
|
|
ui->toolButtonLineIntersect->setEnabled(drawTools);
|
|
|
|
|
ui->toolButtonSpline->setEnabled(drawTools);
|
|
|
|
|
ui->toolButtonArc->setEnabled(drawTools);
|
|
|
|
|
ui->toolButtonSplinePath->setEnabled(drawTools);
|
|
|
|
|
ui->toolButtonPointOfContact->setEnabled(drawTools);
|
|
|
|
|
ui->toolButtonNewDetail->setEnabled(drawTools);
|
|
|
|
|
ui->toolButtonHeight->setEnabled(drawTools);
|
|
|
|
|
ui->toolButtonTriangle->setEnabled(drawTools);
|
|
|
|
|
ui->toolButtonPointOfIntersection->setEnabled(drawTools);
|
|
|
|
|
ui->toolButtonSplineCutPoint->setEnabled(drawTools);
|
|
|
|
|
ui->toolButtonSplinePathCutPoint->setEnabled(drawTools);
|
2014-01-08 15:05:32 +01:00
|
|
|
|
ui->toolButtonArcCutPoint->setEnabled(drawTools);
|
2013-12-23 18:23:50 +01:00
|
|
|
|
|
|
|
|
|
//Modeling Tools
|
|
|
|
|
ui->toolButtonUnionDetails->setEnabled(modelingTools);
|
2013-07-25 14:00:51 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::MinimumScrollBar()
|
|
|
|
|
{
|
2013-08-29 12:31:50 +02:00
|
|
|
|
QScrollBar *horScrollBar = view->horizontalScrollBar();
|
|
|
|
|
horScrollBar->setValue(horScrollBar->minimum());
|
|
|
|
|
QScrollBar *verScrollBar = view->verticalScrollBar();
|
|
|
|
|
verScrollBar->setValue(verScrollBar->minimum());
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
bool MainWindow::SafeSaveing(const QString &fileName) const
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2013-10-21 12:18:12 +02:00
|
|
|
|
doc->TestUniqueId();
|
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
|
catch (const VExceptionUniqueId &e)
|
|
|
|
|
{
|
2013-10-21 12:18:12 +02:00
|
|
|
|
QMessageBox msgBox;
|
|
|
|
|
msgBox.setWindowTitle(tr("Error!"));
|
2013-12-19 11:42:00 +01:00
|
|
|
|
msgBox.setText(tr("Error no unique id."));
|
2013-10-21 12:18:12 +02:00
|
|
|
|
msgBox.setInformativeText(e.ErrorMessage());
|
|
|
|
|
msgBox.setStandardButtons(QMessageBox::Ok);
|
|
|
|
|
msgBox.setDefaultButton(QMessageBox::Ok);
|
|
|
|
|
msgBox.setDetailedText(e.DetailedInformation());
|
|
|
|
|
msgBox.setIcon(QMessageBox::Critical);
|
|
|
|
|
msgBox.exec();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if (fileName.isEmpty())
|
|
|
|
|
{
|
2013-10-04 15:22:37 +02:00
|
|
|
|
qWarning()<<tr("Got empty file name.");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
//Writing in temporary file
|
|
|
|
|
QFileInfo tempInfo(fileName);
|
|
|
|
|
QString temp = tempInfo.absolutePath() + "/" + tempInfo.baseName() + ".tmp";
|
|
|
|
|
qDebug()<<"file "<<fileName<<"temp file "<<temp;
|
|
|
|
|
QFile tempFile(temp);
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if (tempFile.open(QIODevice::WriteOnly| QIODevice::Truncate))
|
|
|
|
|
{
|
2013-10-04 15:22:37 +02:00
|
|
|
|
const int Indent = 4;
|
|
|
|
|
QTextStream out(&tempFile);
|
|
|
|
|
doc->save(out, Indent);
|
|
|
|
|
tempFile.close();
|
|
|
|
|
}
|
|
|
|
|
//Replace temp file our
|
|
|
|
|
bool result = false;
|
|
|
|
|
QFile patternFile(fileName);
|
|
|
|
|
// We need here temporary file because we need restore pattern after error of copying temp file.
|
|
|
|
|
QTemporaryFile tempOfPattern;
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if (tempOfPattern.open())
|
|
|
|
|
{
|
2013-10-04 15:22:37 +02:00
|
|
|
|
patternFile.copy(tempOfPattern.fileName());
|
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if ( patternFile.exists() == false || patternFile.remove() )
|
|
|
|
|
{
|
|
|
|
|
if ( tempFile.copy(patternFile.fileName()) == false )
|
|
|
|
|
{
|
2013-10-04 15:22:37 +02:00
|
|
|
|
qCritical()<<tr("Could not copy temp file to pattern file")<<Q_FUNC_INFO;
|
|
|
|
|
tempOfPattern.copy(fileName);
|
|
|
|
|
result = false;
|
2013-11-04 21:35:15 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2013-10-04 15:22:37 +02:00
|
|
|
|
result = true;
|
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2013-10-04 15:22:37 +02:00
|
|
|
|
qCritical()<<tr("Could not remove pattern file")<<Q_FUNC_INFO;
|
|
|
|
|
result = false;
|
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if (result)
|
|
|
|
|
{
|
2013-10-04 15:22:37 +02:00
|
|
|
|
tempFile.remove();
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::AutoSavePattern()
|
|
|
|
|
{
|
|
|
|
|
if (fileName.isEmpty() == false && changeInFile == true)
|
|
|
|
|
{
|
2013-10-04 16:00:19 +02:00
|
|
|
|
bool result = SafeSaveing(fileName);
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if (result)
|
|
|
|
|
{
|
2013-10-04 16:00:19 +02:00
|
|
|
|
ui->actionSave->setEnabled(false);
|
|
|
|
|
changeInFile = false;
|
|
|
|
|
QFileInfo info(fileName);
|
|
|
|
|
QString title(info.fileName());
|
|
|
|
|
title.append("-Valentina");
|
|
|
|
|
setWindowTitle(title);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01: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
|
|
|
|
|
2013-12-29 17:48:57 +01:00
|
|
|
|
delete pattern;
|
2013-12-30 19:59:33 +01:00
|
|
|
|
delete doc;
|
|
|
|
|
delete sceneDetails;
|
|
|
|
|
delete sceneDraw;
|
2013-09-23 15:17:15 +02:00
|
|
|
|
}
|
|
|
|
|
|
2013-11-04 21:35:15 +01:00
|
|
|
|
void MainWindow::OpenPattern(const QString &fileName)
|
|
|
|
|
{
|
|
|
|
|
if (fileName.isEmpty())
|
|
|
|
|
{
|
2013-12-21 18:47:20 +01:00
|
|
|
|
qWarning()<<tr("Can't open pattern file. File name is empty")<<Q_FUNC_INFO;
|
2013-09-23 15:17:15 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
QFile file(fileName);
|
|
|
|
|
QString errorMsg;
|
|
|
|
|
qint32 errorLine = 0;
|
|
|
|
|
qint32 errorColumn = 0;
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if (file.open(QIODevice::ReadOnly))
|
|
|
|
|
{
|
|
|
|
|
if (doc->setContent(&file, &errorMsg, &errorLine, &errorColumn))
|
|
|
|
|
{
|
2013-09-23 15:17:15 +02:00
|
|
|
|
disconnect(comboBoxDraws, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
2013-10-07 11:13:24 +02:00
|
|
|
|
this, &MainWindow::currentDrawChanged);
|
2013-11-04 21:35:15 +01:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
doc->Parse(Document::FullParse, sceneDraw, sceneDetails);
|
2013-09-23 15:17:15 +02:00
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
|
catch (const VExceptionObjectError &e)
|
|
|
|
|
{
|
2013-09-23 15:17:15 +02:00
|
|
|
|
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;
|
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
|
catch (const VExceptionConversionError &e)
|
|
|
|
|
{
|
2013-09-23 15:17:15 +02:00
|
|
|
|
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;
|
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
|
catch (const VExceptionEmptyParameter &e)
|
|
|
|
|
{
|
2013-09-23 15:17:15 +02:00
|
|
|
|
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;
|
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
|
catch (const VExceptionWrongParameterId &e)
|
|
|
|
|
{
|
2013-09-23 15:17:15 +02:00
|
|
|
|
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;
|
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
|
catch (const VExceptionUniqueId &e)
|
|
|
|
|
{
|
2013-10-07 11:13:24 +02:00
|
|
|
|
QMessageBox msgBox;
|
|
|
|
|
msgBox.setWindowTitle(tr("Error!"));
|
2013-12-19 11:42:00 +01:00
|
|
|
|
msgBox.setText(tr("Error no unique id."));
|
2013-10-07 11:13:24 +02:00
|
|
|
|
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;
|
|
|
|
|
}
|
2013-09-23 15:17:15 +02:00
|
|
|
|
connect(comboBoxDraws, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
|
|
|
|
this, &MainWindow::currentDrawChanged);
|
|
|
|
|
QString nameDraw = doc->GetNameActivDraw();
|
|
|
|
|
qint32 index = comboBoxDraws->findText(nameDraw);
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if ( index != -1 )
|
|
|
|
|
{ // -1 for not found
|
2013-09-23 15:17:15 +02:00
|
|
|
|
comboBoxDraws->setCurrentIndex(index);
|
|
|
|
|
}
|
2013-11-04 21:35:15 +01:00
|
|
|
|
if (comboBoxDraws->count() > 0)
|
|
|
|
|
{
|
2013-09-23 15:17:15 +02:00
|
|
|
|
SetEnableTool(true);
|
2013-11-04 21:35:15 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2013-09-23 15:17:15 +02:00
|
|
|
|
SetEnableTool(false);
|
|
|
|
|
}
|
|
|
|
|
SetEnableWidgets(true);
|
2013-11-04 21:35:15 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2013-09-23 15:17:15 +02:00
|
|
|
|
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-10-07 13:11:56 +02:00
|
|
|
|
helpLabel->setText("");
|
2013-06-20 16:09:50 +02:00
|
|
|
|
}
|