ZoomOriginal and ZoomFitBest.
--HG-- branch : develop
|
@ -1067,6 +1067,9 @@ void MainWindow::ToolBarTools()
|
||||||
Qt::ControlModifier + Qt::Key_Minus + Qt::KeypadModifier};
|
Qt::ControlModifier + Qt::Key_Minus + Qt::KeypadModifier};
|
||||||
ui->actionZoomOut->setShortcuts(zoomOutShortcuts);
|
ui->actionZoomOut->setShortcuts(zoomOutShortcuts);
|
||||||
connect(ui->actionZoomOut, &QAction::triggered, view, &VMainGraphicsView::ZoomOut);
|
connect(ui->actionZoomOut, &QAction::triggered, view, &VMainGraphicsView::ZoomOut);
|
||||||
|
|
||||||
|
connect(ui->actionZoomOriginal, &QAction::triggered, view, &VMainGraphicsView::ZoomOriginal);
|
||||||
|
connect(ui->actionZoomFitBest, &QAction::triggered, view, &VMainGraphicsView::ZoomFitBest);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -1737,6 +1740,8 @@ void MainWindow::SetEnableWidgets(bool enable)
|
||||||
ui->actionEdit_pattern_code->setEnabled(enable);
|
ui->actionEdit_pattern_code->setEnabled(enable);
|
||||||
ui->actionZoomIn->setEnabled(enable);
|
ui->actionZoomIn->setEnabled(enable);
|
||||||
ui->actionZoomOut->setEnabled(enable);
|
ui->actionZoomOut->setEnabled(enable);
|
||||||
|
ui->actionZoomFitBest->setEnabled(enable);
|
||||||
|
ui->actionZoomOriginal->setEnabled(enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -2179,6 +2184,10 @@ MainWindow::~MainWindow()
|
||||||
*/
|
*/
|
||||||
void MainWindow::LoadPattern(const QString &fileName)
|
void MainWindow::LoadPattern(const QString &fileName)
|
||||||
{
|
{
|
||||||
|
// Fit scene to view
|
||||||
|
VAbstractTool::NewSceneRect(sceneDraw, view);
|
||||||
|
VAbstractTool::NewSceneRect(sceneDetails, view);
|
||||||
|
|
||||||
qApp->setOpeningPattern();//Begin opening file
|
qApp->setOpeningPattern();//Begin opening file
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -2231,6 +2240,15 @@ void MainWindow::LoadPattern(const QString &fileName)
|
||||||
helpLabel->setText(tr("File loaded"));
|
helpLabel->setText(tr("File loaded"));
|
||||||
|
|
||||||
qApp->setOpeningPattern();// End opening file
|
qApp->setOpeningPattern();// End opening file
|
||||||
|
|
||||||
|
VAbstractTool::NewSceneRect(sceneDraw, view);
|
||||||
|
VAbstractTool::NewSceneRect(sceneDetails, view);
|
||||||
|
|
||||||
|
ActionDetails(true);
|
||||||
|
view->ZoomFitBest();
|
||||||
|
|
||||||
|
ActionDraw(true);
|
||||||
|
view->ZoomFitBest();
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -2292,9 +2310,6 @@ void MainWindow::OpenPattern(const QString &filePath)
|
||||||
if (curFile.isEmpty() && this->isWindowModified() == false)
|
if (curFile.isEmpty() && this->isWindowModified() == false)
|
||||||
{
|
{
|
||||||
LoadPattern(filePath);
|
LoadPattern(filePath);
|
||||||
|
|
||||||
VAbstractTool::NewSceneRect(sceneDraw, view);
|
|
||||||
VAbstractTool::NewSceneRect(sceneDetails, view);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>150</width>
|
<width>144</width>
|
||||||
<height>150</height>
|
<height>150</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
@ -302,7 +302,7 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>150</width>
|
<width>100</width>
|
||||||
<height>58</height>
|
<height>58</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
@ -378,7 +378,7 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>150</width>
|
<width>100</width>
|
||||||
<height>104</height>
|
<height>104</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
@ -579,7 +579,7 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>150</width>
|
<width>100</width>
|
||||||
<height>58</height>
|
<height>58</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
@ -779,6 +779,8 @@
|
||||||
</attribute>
|
</attribute>
|
||||||
<addaction name="actionZoomIn"/>
|
<addaction name="actionZoomIn"/>
|
||||||
<addaction name="actionZoomOut"/>
|
<addaction name="actionZoomOut"/>
|
||||||
|
<addaction name="actionZoomOriginal"/>
|
||||||
|
<addaction name="actionZoomFitBest"/>
|
||||||
</widget>
|
</widget>
|
||||||
<action name="actionNew">
|
<action name="actionNew">
|
||||||
<property name="icon">
|
<property name="icon">
|
||||||
|
@ -1062,6 +1064,28 @@
|
||||||
<string>Edit pattern XML code</string>
|
<string>Edit pattern XML code</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionZoomOriginal">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="zoom-original"/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>ZoomOriginal</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
|
<action name="actionZoomFitBest">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset theme="zoom-fit-best"/>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>ZoomFitBest</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<layoutdefault spacing="6" margin="11"/>
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
|
|
After Width: | Height: | Size: 704 B |
After Width: | Height: | Size: 667 B |
After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 1.2 KiB |
|
@ -43,5 +43,11 @@
|
||||||
<file alias="16x16/actions/go-down.png">icons/win.icon.theme/16x16/actions/go-down.png</file>
|
<file alias="16x16/actions/go-down.png">icons/win.icon.theme/16x16/actions/go-down.png</file>
|
||||||
<file alias="24x24/actions/go-down.png">icons/win.icon.theme/24x24/actions/go-down.png</file>
|
<file alias="24x24/actions/go-down.png">icons/win.icon.theme/24x24/actions/go-down.png</file>
|
||||||
<file alias="32x32/actions/go-down.png">icons/win.icon.theme/32x32/actions/go-down.png</file>
|
<file alias="32x32/actions/go-down.png">icons/win.icon.theme/32x32/actions/go-down.png</file>
|
||||||
|
<file alias="16x16/actions/zoom-fit-best.png">icons/win.icon.theme/16x16/actions/zoom-fit-best.png</file>
|
||||||
|
<file alias="16x16/actions/zoom-original.png">icons/win.icon.theme/16x16/actions/zoom-original.png</file>
|
||||||
|
<file alias="24x24/actions/zoom-fit-best.png">icons/win.icon.theme/24x24/actions/zoom-fit-best.png</file>
|
||||||
|
<file alias="24x24/actions/zoom-original.png">icons/win.icon.theme/24x24/actions/zoom-original.png</file>
|
||||||
|
<file alias="32x32/actions/zoom-fit-best.png">icons/win.icon.theme/32x32/actions/zoom-fit-best.png</file>
|
||||||
|
<file alias="32x32/actions/zoom-original.png">icons/win.icon.theme/32x32/actions/zoom-original.png</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|
|
@ -43,7 +43,7 @@ VGraphicsSimpleTextItem::VGraphicsSimpleTextItem(QGraphicsItem * parent)
|
||||||
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true);
|
||||||
this->setAcceptHoverEvents(true);
|
this->setAcceptHoverEvents(true);
|
||||||
QFont font = this->font();
|
QFont font = this->font();
|
||||||
font.setPointSize(font.pointSize()+3);
|
font.setPointSize(font.pointSize()+20);
|
||||||
fontSize = font.pointSize();
|
fontSize = font.pointSize();
|
||||||
this->setFont(font);
|
this->setFont(font);
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,6 +158,33 @@ void VMainGraphicsView::ZoomOut()
|
||||||
emit NewFactor(1.0/1.1);
|
emit NewFactor(1.0/1.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VMainGraphicsView::ZoomOriginal()
|
||||||
|
{
|
||||||
|
QTransform trans = this->transform();
|
||||||
|
trans.setMatrix(1.0, trans.m12(), trans.m13(), trans.m21(), 1.0, trans.m23(), trans.m31(), trans.m32(),
|
||||||
|
trans.m33());
|
||||||
|
this->setTransform(trans);
|
||||||
|
VAbstractTool::NewSceneRect(this->scene(), this);
|
||||||
|
emit NewFactor(1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
void VMainGraphicsView::ZoomFitBest()
|
||||||
|
{
|
||||||
|
QRectF rect = this->scene()->itemsBoundingRect();
|
||||||
|
|
||||||
|
if (rect.isEmpty())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->fitInView(rect,Qt::KeepAspectRatio);
|
||||||
|
VAbstractTool::NewSceneRect(this->scene(), this);
|
||||||
|
QTransform trans = this->transform();
|
||||||
|
emit NewFactor(trans.m11());
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* @brief mousePressEvent handle mouse press events.
|
* @brief mousePressEvent handle mouse press events.
|
||||||
|
|
|
@ -52,6 +52,8 @@ public slots:
|
||||||
void animFinished();
|
void animFinished();
|
||||||
void ZoomIn();
|
void ZoomIn();
|
||||||
void ZoomOut();
|
void ZoomOut();
|
||||||
|
void ZoomOriginal();
|
||||||
|
void ZoomFitBest();
|
||||||
protected:
|
protected:
|
||||||
void wheelEvent ( QWheelEvent * event );
|
void wheelEvent ( QWheelEvent * event );
|
||||||
void mousePressEvent(QMouseEvent *mousePress);
|
void mousePressEvent(QMouseEvent *mousePress);
|
||||||
|
|