First commit for tool simple point
This commit is contained in:
parent
96cbc7b2d8
commit
65ad791e3e
24
.hgignore
Normal file
24
.hgignore
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
syntax: glob
|
||||||
|
# This line is a comment, and will be skipped.
|
||||||
|
# Empty lines are skipped too.
|
||||||
|
|
||||||
|
# Backup files left behind by the Emacs editor.
|
||||||
|
*~
|
||||||
|
|
||||||
|
# Lock files used by the Emacs editor.
|
||||||
|
# Notice that the "#" character is quoted with a backslash.
|
||||||
|
# This prevents it from being interpreted as starting a comment.
|
||||||
|
.\#*
|
||||||
|
|
||||||
|
# Temporary files used by the vim editor.
|
||||||
|
.*.swp
|
||||||
|
|
||||||
|
# A hidden file created by the Mac OS X Finder.
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# Ignore this directory.
|
||||||
|
html/
|
||||||
|
latex/
|
||||||
|
|
||||||
|
# Ignore file used QtCreator for user profile.
|
||||||
|
*.pro.user
|
|
@ -13,8 +13,18 @@ TEMPLATE = app
|
||||||
|
|
||||||
|
|
||||||
SOURCES += main.cpp\
|
SOURCES += main.cpp\
|
||||||
mainwindow.cpp
|
mainwindow.cpp \
|
||||||
|
widgets/vmaingraphicsscene.cpp \
|
||||||
|
dialogs/dialogsinglepoint.cpp
|
||||||
|
|
||||||
HEADERS += mainwindow.h
|
HEADERS += mainwindow.h \
|
||||||
|
widgets/vmaingraphicsscene.h \
|
||||||
|
dialogs/dialogsinglepoint.h \
|
||||||
|
options.h
|
||||||
|
|
||||||
FORMS += mainwindow.ui
|
FORMS += mainwindow.ui \
|
||||||
|
dialogs/dialogsinglepoint.ui
|
||||||
|
|
||||||
|
RESOURCES += \
|
||||||
|
icon.qrc \
|
||||||
|
cursor.qrc
|
||||||
|
|
5
cursor.qrc
Normal file
5
cursor.qrc
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<RCC>
|
||||||
|
<qresource prefix="/">
|
||||||
|
<file>cursor/spoint_cursor.png</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
BIN
cursor/spoint_cursor.png
Normal file
BIN
cursor/spoint_cursor.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
61
dialogs/dialogsinglepoint.cpp
Normal file
61
dialogs/dialogsinglepoint.cpp
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
#include "dialogsinglepoint.h"
|
||||||
|
#include "ui_dialogsinglepoint.h"
|
||||||
|
#include <QShowEvent>
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
|
#include "../options.h"
|
||||||
|
|
||||||
|
DialogSinglePoint::DialogSinglePoint(QWidget *parent) :
|
||||||
|
QDialog(parent),
|
||||||
|
ui(new Ui::DialogSinglePoint)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
isInitialized = false;
|
||||||
|
ui->spinBoxX->setRange(0,(qint32)(PaperSize*PrintDPI/25.4));
|
||||||
|
ui->spinBoxY->setRange(0,(qint32)(PaperSize*PrintDPI/25.4));
|
||||||
|
QPushButton* pOkButton = ui->buttonBox->button(QDialogButtonBox::Ok);
|
||||||
|
pOkButton->setEnabled(false);
|
||||||
|
connect(ui->lineEditName, &QLineEdit::textChanged, this, &DialogSinglePoint::NameChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogSinglePoint::mousePress(QPointF scenePos){
|
||||||
|
if(isInitialized == false){
|
||||||
|
ui->spinBoxX->setValue((qint32)(scenePos.x()*PrintDPI/25.4));
|
||||||
|
ui->spinBoxY->setValue((qint32)(scenePos.y()*PrintDPI/25.4));
|
||||||
|
this->show();
|
||||||
|
} else {
|
||||||
|
ui->spinBoxX->setValue((qint32)(scenePos.x()*PrintDPI/25.4));
|
||||||
|
ui->spinBoxY->setValue((qint32)(scenePos.y()*PrintDPI/25.4));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogSinglePoint::showEvent( QShowEvent *event ){
|
||||||
|
QDialog::showEvent( event );
|
||||||
|
if( event->spontaneous() ){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isInitialized){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// do your init stuff here
|
||||||
|
|
||||||
|
isInitialized = true;//перший показ вікна вже відбувся
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogSinglePoint::NameChanged(){
|
||||||
|
QString name = ui->lineEditName->text();
|
||||||
|
if(name.isEmpty() || name.contains(" ")){
|
||||||
|
QPushButton* pOkButton = ui->buttonBox->button(QDialogButtonBox::Ok);
|
||||||
|
pOkButton->setEnabled(false);
|
||||||
|
} else {
|
||||||
|
QPushButton* pOkButton = ui->buttonBox->button(QDialogButtonBox::Ok);
|
||||||
|
pOkButton->setEnabled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DialogSinglePoint::~DialogSinglePoint()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
27
dialogs/dialogsinglepoint.h
Normal file
27
dialogs/dialogsinglepoint.h
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
#ifndef DIALOGSINGLEPOINT_H
|
||||||
|
#define DIALOGSINGLEPOINT_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class DialogSinglePoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
class DialogSinglePoint : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit DialogSinglePoint(QWidget *parent = 0);
|
||||||
|
~DialogSinglePoint();
|
||||||
|
protected:
|
||||||
|
void showEvent( QShowEvent *event );
|
||||||
|
public slots:
|
||||||
|
void mousePress(QPointF scenePos);
|
||||||
|
void NameChanged();
|
||||||
|
private:
|
||||||
|
Ui::DialogSinglePoint *ui;
|
||||||
|
bool isInitialized;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DIALOGSINGLEPOINT_H
|
132
dialogs/dialogsinglepoint.ui
Normal file
132
dialogs/dialogsinglepoint.ui
Normal file
|
@ -0,0 +1,132 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>DialogSinglePoint</class>
|
||||||
|
<widget class="QDialog" name="DialogSinglePoint">
|
||||||
|
<property name="windowModality">
|
||||||
|
<enum>Qt::WindowModal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>249</width>
|
||||||
|
<height>202</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Параметри точки</string>
|
||||||
|
</property>
|
||||||
|
<property name="modal">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<widget class="QGroupBox" name="groupBox">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>10</x>
|
||||||
|
<y>40</y>
|
||||||
|
<width>241</width>
|
||||||
|
<height>129</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string>Координати</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QSpinBox" name="spinBoxY"/>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QLabel" name="labelYCor">
|
||||||
|
<property name="text">
|
||||||
|
<string>Y координата</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QSpinBox" name="spinBoxX"/>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QLabel" name="labelXCor">
|
||||||
|
<property name="text">
|
||||||
|
<string>Х координата</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLabel" name="labelName">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>170</x>
|
||||||
|
<y>10</y>
|
||||||
|
<width>72</width>
|
||||||
|
<height>17</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Ім'я точки</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QLineEdit" name="lineEditName">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>15</x>
|
||||||
|
<y>9</y>
|
||||||
|
<width>146</width>
|
||||||
|
<height>27</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>20</x>
|
||||||
|
<y>170</y>
|
||||||
|
<width>221</width>
|
||||||
|
<height>27</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>DialogSinglePoint</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>248</x>
|
||||||
|
<y>254</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>157</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>DialogSinglePoint</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>316</x>
|
||||||
|
<y>260</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>286</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
9
icon.qrc
Normal file
9
icon.qrc
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<RCC>
|
||||||
|
<qresource prefix="/">
|
||||||
|
<file>icon/64x64/icon64x64.png</file>
|
||||||
|
<file>icon/32x32/draw.png</file>
|
||||||
|
<file>icon/32x32/kontur.png</file>
|
||||||
|
<file>icon/32x32/spoint.png</file>
|
||||||
|
<file>icon/32x32/arrow_cursor.png</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
BIN
icon/32x32/arrow_cursor.png
Normal file
BIN
icon/32x32/arrow_cursor.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
BIN
icon/32x32/draw.png
Normal file
BIN
icon/32x32/draw.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.8 KiB |
BIN
icon/32x32/kontur.png
Normal file
BIN
icon/32x32/kontur.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
BIN
icon/32x32/spoint.png
Normal file
BIN
icon/32x32/spoint.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
BIN
icon/64x64/icon64x64.png
Normal file
BIN
icon/64x64/icon64x64.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.4 KiB |
6
main.cpp
6
main.cpp
|
@ -1,11 +1,13 @@
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QTextCodec>
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QApplication a(argc, argv);
|
QApplication app(argc, argv);
|
||||||
MainWindow w;
|
MainWindow w;
|
||||||
|
app.setWindowIcon(QIcon(":/icon/64x64/icon64x64.png"));
|
||||||
w.show();
|
w.show();
|
||||||
|
|
||||||
return a.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
|
152
mainwindow.cpp
152
mainwindow.cpp
|
@ -2,21 +2,167 @@
|
||||||
#include "ui_mainwindow.h"
|
#include "ui_mainwindow.h"
|
||||||
|
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QSpinBox>
|
||||||
|
#include <QScrollBar>
|
||||||
|
#include <QShowEvent>
|
||||||
|
|
||||||
|
#include "options.h"
|
||||||
|
|
||||||
MainWindow::MainWindow(QWidget *parent) :
|
MainWindow::MainWindow(QWidget *parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent), ui(new Ui::MainWindow)
|
||||||
ui(new Ui::MainWindow)
|
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
tool = Tools::ArrayTool;
|
||||||
|
isInitialized = false;
|
||||||
|
ToolBarOption();
|
||||||
|
ToolBarDraws();
|
||||||
|
QRectF sceneRect = QRectF(0, 0, PaperSize*PrintDPI/25.4, PaperSize*PrintDPI/25.4);
|
||||||
|
scene = new VMainGraphicsScene(sceneRect);
|
||||||
|
ui->graphicsView->setScene(scene);
|
||||||
|
|
||||||
|
connect(scene, &VMainGraphicsScene::mouseMove, this, &MainWindow::mouseMove);
|
||||||
|
connect(ui->toolButtonSinglePoint, &QToolButton::clicked, this,
|
||||||
|
&MainWindow::clickedToolButtonSinglePoint);
|
||||||
|
helpLabel = new QLabel("Створіть новий файл для початку роботи.");
|
||||||
|
ui->statusBar->addWidget(helpLabel);
|
||||||
|
|
||||||
|
connect(ui->actionArrowTool, &QAction::triggered, this, &MainWindow::triggeredActionAroowTool);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Інструмет базова точка креслення.
|
||||||
|
*/
|
||||||
|
void MainWindow::clickedToolButtonSinglePoint(){
|
||||||
|
tool = Tools::SinglePointTool;
|
||||||
|
QPixmap pixmap(":/cursor/spoint_cursor.png");
|
||||||
|
QCursor cur(pixmap, 2, 3);
|
||||||
|
ui->graphicsView->setCursor(cur);
|
||||||
|
helpLabel->setText("Виберіть розташування для точки.");
|
||||||
|
dialogSinglePoint = new DialogSinglePoint;
|
||||||
|
connect(scene, &VMainGraphicsScene::mousePress, dialogSinglePoint, &DialogSinglePoint::mousePress);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::showEvent( QShowEvent *event ){
|
||||||
|
QMainWindow::showEvent( event );
|
||||||
|
if( event->spontaneous() ){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isInitialized){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// do your init stuff here
|
||||||
|
QScrollBar *horScrollBar = ui->graphicsView->horizontalScrollBar();
|
||||||
|
horScrollBar->setValue(horScrollBar->minimum());
|
||||||
|
QScrollBar *verScrollBar = ui->graphicsView->verticalScrollBar();
|
||||||
|
verScrollBar->setValue(verScrollBar->minimum());
|
||||||
|
|
||||||
|
isInitialized = true;//перший показ вікна вже відбувся
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::ToolBarOption(){
|
||||||
|
QLabel * labelGrowth = new QLabel;
|
||||||
|
labelGrowth->setText("Зріст: ");
|
||||||
|
ui->toolBarOption->addWidget(labelGrowth);
|
||||||
|
|
||||||
QStringList list;
|
QStringList list;
|
||||||
|
list << "104"<<"110"<<"116"<<"122"<<"128"<<"134"<<"140"<<"146"<<"152"<<"158"<<"164"<<"170"<<"176"
|
||||||
|
<< "182" << "188";
|
||||||
|
QComboBox* comboBoxGrow = new QComboBox;
|
||||||
|
comboBoxGrow->clear();
|
||||||
|
comboBoxGrow->addItems(list);
|
||||||
|
comboBoxGrow->setCurrentIndex(12);
|
||||||
|
ui->toolBarOption->addWidget(comboBoxGrow);
|
||||||
|
|
||||||
|
QLabel * labelSize = new QLabel;
|
||||||
|
labelSize->setText(" Розмір: ");
|
||||||
|
ui->toolBarOption->addWidget(labelSize);
|
||||||
|
|
||||||
|
list.clear();
|
||||||
list << "28"<<"30"<<"32"<<"34"<<"36"<<"38"<<"40"<<"42"<<"44"<<"46"<<"48"<<"50" << "52" << "54" << "56";
|
list << "28"<<"30"<<"32"<<"34"<<"36"<<"38"<<"40"<<"42"<<"44"<<"46"<<"48"<<"50" << "52" << "54" << "56";
|
||||||
QComboBox* comboBoxSize = new QComboBox;
|
QComboBox* comboBoxSize = new QComboBox;
|
||||||
comboBoxSize ->clear();
|
comboBoxSize->clear();
|
||||||
comboBoxSize->addItems(list);
|
comboBoxSize->addItems(list);
|
||||||
|
comboBoxSize->setCurrentIndex(11);
|
||||||
ui->toolBarOption->addWidget(comboBoxSize);
|
ui->toolBarOption->addWidget(comboBoxSize);
|
||||||
|
|
||||||
|
ui->toolBarOption->addSeparator();
|
||||||
|
|
||||||
|
mouseCoordinate = new QLabel;
|
||||||
|
mouseCoordinate ->setText("0, 0");
|
||||||
|
ui->toolBarOption->addWidget(mouseCoordinate);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::ToolBarDraws(){
|
||||||
|
QLabel * labelNameDraw = new QLabel;
|
||||||
|
labelNameDraw ->setText("Креслення: ");
|
||||||
|
ui->toolBarDraws->addWidget(labelNameDraw);
|
||||||
|
|
||||||
|
QComboBox* comboBoxDraws = new QComboBox;
|
||||||
|
ui->toolBarDraws->addWidget(comboBoxDraws);
|
||||||
|
|
||||||
|
ui->toolBarDraws->addSeparator();
|
||||||
|
|
||||||
|
QLabel* labelTranslateX = new QLabel;
|
||||||
|
labelTranslateX ->setText(" Зміщення по Х: ");
|
||||||
|
ui->toolBarDraws->addWidget(labelTranslateX);
|
||||||
|
|
||||||
|
QSpinBox* spinBoxTranslateX = new QSpinBox;
|
||||||
|
spinBoxTranslateX->setRange(0,(qint32)(PaperSize*PrintDPI/25.4));
|
||||||
|
spinBoxTranslateX->setFixedSize(80,25);
|
||||||
|
ui->toolBarDraws->addWidget(spinBoxTranslateX);
|
||||||
|
|
||||||
|
QLabel* labelTranslateY = new QLabel;
|
||||||
|
labelTranslateY ->setText(" Зміщення по Y: ");
|
||||||
|
ui->toolBarDraws->addWidget(labelTranslateY);
|
||||||
|
|
||||||
|
QSpinBox* spinBoxTranslateY = new QSpinBox;
|
||||||
|
spinBoxTranslateY->setRange(0,(qint32)(PaperSize*PrintDPI/25.4));
|
||||||
|
spinBoxTranslateY->setFixedSize(80,25);
|
||||||
|
ui->toolBarDraws->addWidget(spinBoxTranslateY);
|
||||||
|
|
||||||
|
QPushButton* pushButtonTranslate = new QPushButton;
|
||||||
|
pushButtonTranslate->setText("Застосувати");
|
||||||
|
ui->toolBarDraws->addWidget(pushButtonTranslate);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::mouseMove(QPointF scenePos){
|
||||||
|
QString string = QString("%1, %2")
|
||||||
|
.arg((qint32)(scenePos.x()*PrintDPI/25.4))
|
||||||
|
.arg((qint32)(scenePos.y()*PrintDPI/25.4));
|
||||||
|
mouseCoordinate->setText(string);
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::CanselTool(){
|
||||||
|
switch( tool )
|
||||||
|
{
|
||||||
|
case Tools::ArrowTool:
|
||||||
|
//Покищо нічого тут не робимо.
|
||||||
|
break;
|
||||||
|
case Tools::SinglePointTool:
|
||||||
|
//Знищимо діалогове вікно.
|
||||||
|
delete dialogSinglePoint;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::ArrowTool(){
|
||||||
|
CanselTool();
|
||||||
|
tool = Tools::ArrowTool;
|
||||||
|
QCursor cur(Qt::ArrowCursor);
|
||||||
|
ui->graphicsView->setCursor(cur);
|
||||||
|
helpLabel->setText("");
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::triggeredActionAroowTool(){
|
||||||
|
ArrowTool();
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
{
|
{
|
||||||
|
CanselTool();
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
35
mainwindow.h
35
mainwindow.h
|
@ -2,21 +2,46 @@
|
||||||
#define MAINWINDOW_H
|
#define MAINWINDOW_H
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
|
#include <QLabel>
|
||||||
|
|
||||||
|
#include "widgets/vmaingraphicsscene.h"
|
||||||
|
#include "dialogs/dialogsinglepoint.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class MainWindow;
|
class MainWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace Tools{
|
||||||
|
enum Enum
|
||||||
|
{
|
||||||
|
ArrowTool,
|
||||||
|
SinglePointTool
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
class MainWindow : public QMainWindow
|
class MainWindow : public QMainWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit MainWindow(QWidget *parent = 0);
|
explicit MainWindow(QWidget *parent = 0);
|
||||||
~MainWindow();
|
~MainWindow();
|
||||||
|
public slots:
|
||||||
|
void mouseMove(QPointF scenePos);
|
||||||
|
void showEvent( QShowEvent *event );
|
||||||
|
void clickedToolButtonSinglePoint();
|
||||||
|
void triggeredActionAroowTool();
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
|
Tools::Enum tool;
|
||||||
|
VMainGraphicsScene *scene;
|
||||||
|
QLabel *mouseCoordinate;
|
||||||
|
QLabel *helpLabel;
|
||||||
|
bool isInitialized;
|
||||||
|
DialogSinglePoint *dialogSinglePoint;
|
||||||
|
void ToolBarOption();
|
||||||
|
void ToolBarDraws();
|
||||||
|
void CanselTool();
|
||||||
|
void ArrowTool();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
|
209
mainwindow.ui
209
mainwindow.ui
|
@ -6,7 +6,7 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>1000</width>
|
<width>1100</width>
|
||||||
<height>700</height>
|
<height>700</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
@ -14,9 +14,37 @@
|
||||||
<string>Valentina</string>
|
<string>Valentina</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="centralWidget">
|
<widget class="QWidget" name="centralWidget">
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
<item row="0" column="0" alignment="Qt::AlignTop">
|
<item row="0" column="2">
|
||||||
|
<widget class="QGraphicsView" name="graphicsView">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||||
|
<horstretch>6</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>922</width>
|
||||||
|
<height>582</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="mouseTracking">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignBottom|Qt::AlignRight|Qt::AlignTrailing</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
<widget class="QToolBox" name="toolBox">
|
<widget class="QToolBox" name="toolBox">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||||
|
<horstretch>1</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
|
@ -25,42 +53,72 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>117</width>
|
<width>154</width>
|
||||||
<height>111</height>
|
<height>81</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Maximum">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<attribute name="label">
|
<attribute name="label">
|
||||||
<string>Точка</string>
|
<string>Точка</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item>
|
<item row="0" column="3">
|
||||||
<widget class="QPushButton" name="pushButton">
|
<widget class="QToolButton" name="toolButton_5">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>PushButton</string>
|
<string>...</string>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="buttonGroup">
|
|
||||||
<string notr="true">buttonGroup</string>
|
|
||||||
</attribute>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item row="0" column="1">
|
||||||
<widget class="QPushButton" name="pushButton_2">
|
<widget class="QToolButton" name="toolButton_2">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>PushButton</string>
|
<string>...</string>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="buttonGroup">
|
|
||||||
<string notr="true">buttonGroup</string>
|
|
||||||
</attribute>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item row="0" column="2">
|
||||||
<widget class="QPushButton" name="pushButton_3">
|
<widget class="QToolButton" name="toolButton_3">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>PushButton</string>
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QToolButton" name="toolButtonSinglePoint">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Точка</string>
|
||||||
|
</property>
|
||||||
|
<property name="statusTip">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Точка</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="icon.qrc">
|
||||||
|
<normaloff>:/icon/32x32/spoint.png</normaloff>:/icon/32x32/spoint.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="iconSize">
|
||||||
|
<size>
|
||||||
|
<width>24</width>
|
||||||
|
<height>24</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QToolButton" name="toolButton_4">
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="buttonGroup">
|
|
||||||
<string notr="true">buttonGroup</string>
|
|
||||||
</attribute>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
@ -70,15 +128,21 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>117</width>
|
<width>154</width>
|
||||||
<height>111</height>
|
<height>111</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<attribute name="label">
|
<attribute name="label">
|
||||||
<string>Лінія</string>
|
<string>Лінія</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<layout class="QGridLayout" name="gridLayout_3">
|
||||||
<item>
|
<item row="0" column="0">
|
||||||
<widget class="QPushButton" name="pushButton_4">
|
<widget class="QPushButton" name="pushButton_4">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>PushButton</string>
|
<string>PushButton</string>
|
||||||
|
@ -88,7 +152,7 @@
|
||||||
</attribute>
|
</attribute>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item row="1" column="0">
|
||||||
<widget class="QPushButton" name="pushButton_5">
|
<widget class="QPushButton" name="pushButton_5">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>PushButton</string>
|
<string>PushButton</string>
|
||||||
|
@ -98,7 +162,7 @@
|
||||||
</attribute>
|
</attribute>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item row="2" column="0">
|
||||||
<widget class="QPushButton" name="pushButton_6">
|
<widget class="QPushButton" name="pushButton_6">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>PushButton</string>
|
<string>PushButton</string>
|
||||||
|
@ -115,15 +179,21 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>117</width>
|
<width>154</width>
|
||||||
<height>73</height>
|
<height>45</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<attribute name="label">
|
<attribute name="label">
|
||||||
<string>Сплайн</string>
|
<string>Сплайн</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QGridLayout" name="gridLayout_4">
|
||||||
<item>
|
<item row="0" column="0">
|
||||||
<widget class="QPushButton" name="pushButton_7">
|
<widget class="QPushButton" name="pushButton_7">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>PushButton</string>
|
<string>PushButton</string>
|
||||||
|
@ -137,15 +207,21 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>117</width>
|
<width>154</width>
|
||||||
<height>73</height>
|
<height>45</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<attribute name="label">
|
<attribute name="label">
|
||||||
<string>Дуга</string>
|
<string>Дуга</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QGridLayout" name="gridLayout_5">
|
||||||
<item>
|
<item row="0" column="0">
|
||||||
<widget class="QPushButton" name="pushButton_8">
|
<widget class="QPushButton" name="pushButton_8">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>PushButton</string>
|
<string>PushButton</string>
|
||||||
|
@ -156,16 +232,6 @@
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="QGraphicsView" name="graphicsView">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
|
||||||
<horstretch>2</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenuBar" name="menuBar">
|
<widget class="QMenuBar" name="menuBar">
|
||||||
|
@ -173,7 +239,7 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>1000</width>
|
<width>1100</width>
|
||||||
<height>25</height>
|
<height>25</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
@ -203,6 +269,7 @@
|
||||||
</attribute>
|
</attribute>
|
||||||
<addaction name="actionDraw"/>
|
<addaction name="actionDraw"/>
|
||||||
<addaction name="actionDetails"/>
|
<addaction name="actionDetails"/>
|
||||||
|
<addaction name="actionArrowTool"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QToolBar" name="toolBarDraws">
|
<widget class="QToolBar" name="toolBarDraws">
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -223,7 +290,7 @@
|
||||||
<enum>BottomToolBarArea</enum>
|
<enum>BottomToolBarArea</enum>
|
||||||
</attribute>
|
</attribute>
|
||||||
<attribute name="toolBarBreak">
|
<attribute name="toolBarBreak">
|
||||||
<bool>true</bool>
|
<bool>false</bool>
|
||||||
</attribute>
|
</attribute>
|
||||||
</widget>
|
</widget>
|
||||||
<action name="actionNew">
|
<action name="actionNew">
|
||||||
|
@ -282,6 +349,16 @@
|
||||||
<property name="checkable">
|
<property name="checkable">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="icon.qrc">
|
||||||
|
<normaloff>:/icon/32x32/draw.png</normaloff>:/icon/32x32/draw.png</iconset>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Креслення</string>
|
<string>Креслення</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -290,6 +367,13 @@
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionDetails">
|
<action name="actionDetails">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="icon.qrc">
|
||||||
|
<normaloff>:/icon/32x32/kontur.png</normaloff>:/icon/32x32/kontur.png</iconset>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Деталі</string>
|
<string>Деталі</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -297,9 +381,29 @@
|
||||||
<string>Режим деталі</string>
|
<string>Режим деталі</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionArrowTool">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="icon.qrc">
|
||||||
|
<normaloff>:/icon/32x32/arrow_cursor.png</normaloff>:/icon/32x32/arrow_cursor.png</iconset>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Інструмент вказівник</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Інструмент вказівник</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
<resources/>
|
<resources>
|
||||||
|
<include location="icon.qrc"/>
|
||||||
|
</resources>
|
||||||
<connections/>
|
<connections/>
|
||||||
<buttongroups>
|
<buttongroups>
|
||||||
<buttongroup name="buttonGroup_2">
|
<buttongroup name="buttonGroup_2">
|
||||||
|
@ -307,10 +411,5 @@
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
</buttongroup>
|
</buttongroup>
|
||||||
<buttongroup name="buttonGroup">
|
|
||||||
<property name="exclusive">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
</buttongroup>
|
|
||||||
</buttongroups>
|
</buttongroups>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
7
options.h
Normal file
7
options.h
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
#ifndef OPTIONS_H
|
||||||
|
#define OPTIONS_H
|
||||||
|
|
||||||
|
#define PrintDPI 96
|
||||||
|
#define PaperSize 50000
|
||||||
|
|
||||||
|
#endif // OPTIONS_H
|
21
widgets/vmaingraphicsscene.cpp
Normal file
21
widgets/vmaingraphicsscene.cpp
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
#include "vmaingraphicsscene.h"
|
||||||
|
|
||||||
|
|
||||||
|
VMainGraphicsScene::VMainGraphicsScene():QGraphicsScene()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VMainGraphicsScene::VMainGraphicsScene(const QRectF & sceneRect, QObject * parent):QGraphicsScene ( sceneRect, parent )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void VMainGraphicsScene::mouseMoveEvent(QGraphicsSceneMouseEvent* event){
|
||||||
|
emit mouseMove(event->scenePos());
|
||||||
|
QGraphicsScene::mouseMoveEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VMainGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *event){
|
||||||
|
emit mousePress(event->scenePos());
|
||||||
|
QGraphicsScene::mousePressEvent(event);
|
||||||
|
}
|
21
widgets/vmaingraphicsscene.h
Normal file
21
widgets/vmaingraphicsscene.h
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
#ifndef VMAINGRAPHICSSCENE_H
|
||||||
|
#define VMAINGRAPHICSSCENE_H
|
||||||
|
|
||||||
|
#include <QGraphicsScene>
|
||||||
|
#include <QGraphicsSceneMouseEvent>
|
||||||
|
|
||||||
|
class VMainGraphicsScene : public QGraphicsScene
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
VMainGraphicsScene();
|
||||||
|
VMainGraphicsScene(const QRectF & sceneRect, QObject * parent = 0);
|
||||||
|
private:
|
||||||
|
void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
|
||||||
|
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
signals:
|
||||||
|
void mouseMove(QPointF scenePos);
|
||||||
|
void mousePress(QPointF scenePos);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // VMAINGRAPHICSSCENE_H
|
Loading…
Reference in New Issue
Block a user