diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index b7dd61c..bb62784 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -49,7 +49,6 @@ set(plaYUVer_App_SRCS PlaYUVerSubWindowHandle.cpp PlaYUVerMdiSubWindow.cpp SubWindowAbstract.cpp - Settings.cpp # Module Video VideoSubWindow.cpp ViewArea.cpp diff --git a/app/GridManager.cpp b/app/GridManager.cpp index c90a277..01ce3ad 100644 --- a/app/GridManager.cpp +++ b/app/GridManager.cpp @@ -33,7 +33,6 @@ #include #include "GridManager.h" -#include "Settings.h" namespace plaYUVer { @@ -44,6 +43,8 @@ namespace plaYUVer GridManager::GridManager() { m_nearPos = QPoint(); + m_uiHSpace = m_uiVSpace = 64; + m_cGridColor = QColor( Qt::white ); } //////////////////////////////////////////////////////////////////////////////// @@ -51,21 +52,21 @@ GridManager::GridManager() //////////////////////////////////////////////////////////////////////////////// void GridManager::drawGrid( QPixmap &image, const QRect& area, QPainter *painter ) { - Settings settings; - int offsetx = 0; // Grid offset doesn't applies to SCODE int offsety = 0; // project for now... int imageWidth = image.width(); int imageHeight = image.height(); - int hSpacing = settings.gridHSpacing(); - int vSpacing = settings.gridVSpacing(); - QColor color = settings.gridColor(); - Style style = settings.gridStyle(); + int hSpacing = m_uiHSpace; + int vSpacing = m_uiVSpace; + QColor color = m_cGridColor; + Style style = m_eGridStyle; // Set pen for solid line. QPen mainPen = QPen( color, 1, Qt::SolidLine ); + style = Solid; + hSpacing = vSpacing = 64; switch( style ) { case IntersectionDot: @@ -102,7 +103,7 @@ void GridManager::drawGrid( QPixmap &image, const QRect& area, QPainter *painter // Change pen to the dashed line mainPen.setStyle( Qt::DashLine ); } - default: // Solid: + default: // Solid: { painter->setPen( mainPen ); @@ -149,9 +150,8 @@ QRect GridManager::rectContains( int x, int y ) const int multiPosX; int multiPosY; - Settings settings; - int hSpacing = settings.gridHSpacing(); - int vSpacing = settings.gridVSpacing(); + int hSpacing = m_uiHSpace; + int vSpacing = m_uiVSpace; if( ( x < 0 ) || ( y < 0 ) ) { @@ -176,9 +176,8 @@ bool GridManager::contains( int x, int y ) int resX; int resY; - Settings settings; - int hSpacing = settings.gridHSpacing(); - int vSpacing = settings.gridVSpacing(); + int hSpacing = m_uiHSpace; + int vSpacing = m_uiVSpace; if( ( x < hSpacing ) || ( y < vSpacing ) || ( x < 0 ) || ( y < 0 ) ) return false; @@ -215,9 +214,8 @@ bool GridManager::isNear( int x, int y ) int multiPosX; int multiPosY; - Settings settings; - int hSpacing = settings.gridHSpacing(); - int vSpacing = settings.gridVSpacing(); + int hSpacing = m_uiHSpace; + int vSpacing = m_uiVSpace; if( ( x < 0 ) || ( y < 0 ) ) { @@ -270,4 +268,4 @@ bool GridManager::isNear( const QPoint &pos ) return isNear( pos.x(), pos.y() ); } -} // NameSpace plaYUVer +} // NameSpace plaYUVer diff --git a/app/GridManager.h b/app/GridManager.h index 5eebc14..27bf0fb 100644 --- a/app/GridManager.h +++ b/app/GridManager.h @@ -95,6 +95,10 @@ public: private: + UInt m_uiHSpace; + UInt m_uiVSpace; + QColor m_cGridColor; + Style m_eGridStyle; QPoint m_nearPos; }; diff --git a/app/Settings.cpp b/app/Settings.cpp deleted file mode 100644 index d44947c..0000000 --- a/app/Settings.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/* This file is a part of plaYUVer project - * Copyright (C) 2014-2015 by Luis Lucas (luisfrlucas@gmail.com) - * Joao Carreira (jfmcarreira@gmail.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -/** - * \file Settings.h - * \brief App settings - */ - -#include "Settings.h" - -namespace plaYUVer -{ - -Settings::Settings() -{ -} - -// - - - - - - - - - - - - - - Grid Settings - - - - - - - - - - - - - - - - - - - -GridManager::Style Settings::gridStyle() -{ - return ( GridManager::Style )m_settings.value( "Grid/style", 0 ).toInt(); -} - -void Settings::setGridStyle( GridManager::Style v ) -{ - m_settings.setValue( "Grid/style", v ); -} - -QColor Settings::gridColor() -{ - return m_settings.value( "Grid/color", QColor( Qt::white ) ).value(); -} - -Void Settings::setGridColor( const QColor & v ) -{ - m_settings.setValue( "Grid/color", v ); -} - -Int Settings::gridHSpacing() -{ - return m_settings.value( "Grid/hSpacing", 16 ).toInt(); -} - -Void Settings::setGridHSpacing( Int v ) -{ - m_settings.setValue( "Grid/hSpacing", v ); -} - -Int Settings::gridVSpacing() -{ - return m_settings.value( "Grid/vSpacing", 16 ).toInt(); -} - -Void Settings::setGridVSpacing( Int v ) -{ - m_settings.setValue( "Grid/vSpacing", v ); -} - -} // NAMESPACE diff --git a/app/Settings.h b/app/Settings.h deleted file mode 100644 index 65cb5a4..0000000 --- a/app/Settings.h +++ /dev/null @@ -1,62 +0,0 @@ -/* This file is a part of plaYUVer project - * Copyright (C) 2014-2015 by Luis Lucas (luisfrlucas@gmail.com) - * Joao Carreira (jfmcarreira@gmail.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -/** - * \file Settings.h - * \brief App settings - */ - -#ifndef __SETTINGS_H__ -#define __SETTINGS_H__ - -#include "config.h" -#include "PlaYUVerAppDefs.h" -#include -#include "GridManager.h" -#include "VideoSubWindow.h" - -namespace plaYUVer -{ - -class Settings -{ - -public: - Settings(); - - // - - - - - - - - - - - - Grid Settings - - - - - - - - - - - - - - - - GridManager::Style gridStyle(); - Void setGridStyle( GridManager::Style v ); - - QColor gridColor(); - Void setGridColor( const QColor &v ); - - Int gridHSpacing(); - Void setGridHSpacing( Int v ); - - Int gridVSpacing(); - Void setGridVSpacing( Int v ); - -private: - QSettings m_settings; -}; - -} // NAMESPACE - -#endif // __Settings_H__ diff --git a/app/ViewArea.cpp b/app/ViewArea.cpp index e809d12..36be7fe 100644 --- a/app/ViewArea.cpp +++ b/app/ViewArea.cpp @@ -67,8 +67,8 @@ ViewArea::ViewArea( QWidget *parent ) : m_visibleZoomRect = true; m_pStream = NULL; - m_zoomWinTimer.setSingleShot(true); - m_zoomWinTimer.setInterval(2000); + m_zoomWinTimer.setSingleShot( true ); + m_zoomWinTimer.setInterval( 2000 ); connect( &m_zoomWinTimer, SIGNAL( timeout() ), this, SLOT( update() ) ); } @@ -218,7 +218,13 @@ void ViewArea::setMaskColor( const QColor &color ) void ViewArea::setTool( eTool tool ) { + m_snapToGrid = tool == BlockSelectionTool; + if( tool == BlockSelectionTool ) + { + tool = NormalSelectionTool; + } m_tool = tool; + } void ViewArea::setMaskTool() @@ -291,42 +297,42 @@ void ViewArea::initZoomWinRect() int iMinX = 80; int iMinY = 80; - int iMaxX = iMinX*5; - int iMaxY = iMinY*5; + int iMaxX = iMinX * 5; + int iMaxY = iMinY * 5; double dSizeRatio, dWinZoomRatio; - int iHorizontalImg = (m_pixmap.width() > m_pixmap.height()) ? 1 : 0; + int iHorizontalImg = ( m_pixmap.width() > m_pixmap.height() ) ? 1 : 0; if( iHorizontalImg ) { - dSizeRatio = (double)m_pixmap.width()/(double)m_pixmap.height(); + dSizeRatio = ( double )m_pixmap.width() / ( double )m_pixmap.height(); } else { - dSizeRatio = (double)m_pixmap.height()/(double)m_pixmap.width(); + dSizeRatio = ( double )m_pixmap.height() / ( double )m_pixmap.width(); } - if( dSizeRatio > 5.0) + if( dSizeRatio > 5.0 ) { if( iHorizontalImg ) { - dWinZoomRatio = (double)(m_pixmap.width()*1024/iMaxX)/1000.0; + dWinZoomRatio = ( double )( m_pixmap.width() * 1024 / iMaxX ) / 1000.0; } else { - dWinZoomRatio = (double)(m_pixmap.height()*1024/iMaxY)/1000.0; + dWinZoomRatio = ( double )( m_pixmap.height() * 1024 / iMaxY ) / 1000.0; } } else { if( iHorizontalImg ) { - dWinZoomRatio = (double)(m_pixmap.height()*1024/iMinY)/1000.0; + dWinZoomRatio = ( double )( m_pixmap.height() * 1024 / iMinY ) / 1000.0; } else { - dWinZoomRatio = (double)(m_pixmap.width()*1024/iMinX)/1000.0; + dWinZoomRatio = ( double )( m_pixmap.width() * 1024 / iMinX ) / 1000.0; } } @@ -418,6 +424,7 @@ void ViewArea::paintEvent( QPaintEvent *event ) painter.drawPixmap( exposedRect, m_pixmap, exposedRect ); // Draw the Grid if it's visible. + //m_gridVisible = true; if( m_gridVisible ) { // Do we need to draw the whole grid? @@ -535,7 +542,6 @@ void ViewArea::paintEvent( QPaintEvent *event ) } } - // VISIBLE ZOOM RECT #if 0 if( m_visibleZoomRect && m_zoomWinTimer.isActive() ) @@ -565,14 +571,14 @@ void ViewArea::paintEvent( QPaintEvent *event ) cVisibleWinRect = cVisibleWinRect & cImgWinRect; if(cVisibleWinRect.left()<0) - cVisibleWinRect.moveLeft(0); + cVisibleWinRect.moveLeft(0); if(cVisibleWinRect.top()<0) - cVisibleWinRect.moveTop(0); + cVisibleWinRect.moveTop(0); if(cVisibleWinRect.width()<=0) - cVisibleWinRect.setWidth(1); + cVisibleWinRect.setWidth(1); if(cVisibleWinRect.height()<=0) - cVisibleWinRect.setHeight(1); + cVisibleWinRect.setHeight(1); painter.fillRect(cVisibleWinRect, QBrush(QColor(200, 200, 200, 128))); painter.setPen(QColor(255, 255, 255, 128)); @@ -757,7 +763,7 @@ void ViewArea::mousePressEvent( QMouseEvent *event ) { // Find if the cursor is near a grid intersection bool isNear = m_grid.isNear( m_lastPos ); - + isNear = true; if( isNear ) { // The grid 'near intersection' found when used isNear()