Zoom all follows mouse position.
This commit is contained in:
1 parent
bb42e04dbf
commit
691db321f7
7 files changed
+49
-37
No files matched your search
@@ -58,12 +58,6 @@ Void SubWindowHandle::setMainWidget( QWidget *widget )
|
||||
m_cScrollArea->setWidget( widget );
|
||||
}
|
||||
|
||||
Void SubWindowHandle::processZoomChange( Double scale, QPoint center )
|
||||
{
|
||||
adjustScrollBarByScale( scale, center );
|
||||
emit zoomChangedOnSubWindow();
|
||||
}
|
||||
|
||||
QSize SubWindowHandle::getScrollSize()
|
||||
{
|
||||
return QSize( m_cScrollArea->viewport()->size().width() - 5, m_cScrollArea->viewport()->size().height() - 5 );
|
||||
|
||||
@@ -47,8 +47,6 @@ private:
|
||||
UInt m_uiCategory;
|
||||
QString m_cWindowName;
|
||||
|
||||
Void adjustScrollBarByScale( Double scale, QPoint center );
|
||||
|
||||
public:
|
||||
enum SubWindowCategories
|
||||
{
|
||||
@@ -98,12 +96,12 @@ protected:
|
||||
QSize getScrollSize();
|
||||
|
||||
Q_SIGNALS:
|
||||
void zoomChangedOnSubWindow();
|
||||
void scrollBarMoved( const QPoint );
|
||||
void zoomFactorChanged_SWindow( const double, const QPoint );
|
||||
void scrollBarMoved_SWindow( const QPoint );
|
||||
void updateStatusBar( const QString& );
|
||||
|
||||
public Q_SLOTS:
|
||||
void processZoomChange( double factor, QPoint center );
|
||||
void adjustScrollBarByScale( double scale, QPoint center );
|
||||
void adjustScrollBarByOffset( QPoint Offset );
|
||||
void updateLastScrollValue();
|
||||
|
||||
|
||||
+19
-4
@@ -83,9 +83,11 @@ VideoSubWindow::VideoSubWindow( QWidget * parent, Bool isModule ) :
|
||||
|
||||
// Create a new interface to show images
|
||||
m_cViewArea = new ViewArea( this );
|
||||
connect( m_cViewArea, SIGNAL( zoomFactorChanged( double , QPoint) ), this, SLOT( processZoomChange( double, QPoint ) ) );
|
||||
connect( m_cViewArea, SIGNAL( moveScroll( QPoint ) ), this, SLOT( adjustScrollBarByOffset( QPoint ) ) );
|
||||
connect( m_cViewArea, SIGNAL( moveScroll( QPoint ) ), this, SIGNAL( scrollBarMoved( QPoint ) ) );
|
||||
connect( m_cViewArea, SIGNAL( zoomFactorChanged( double , QPoint) ), this, SLOT( adjustScrollBarByScale( double, QPoint ) ) );
|
||||
connect( m_cViewArea, SIGNAL( zoomFactorChanged( double , QPoint) ), this, SIGNAL( zoomFactorChanged_SWindow( double, QPoint ) ) );
|
||||
|
||||
connect( m_cViewArea, SIGNAL( scrollBarMoved( QPoint ) ), this, SLOT( adjustScrollBarByOffset( QPoint ) ) );
|
||||
connect( m_cViewArea, SIGNAL( scrollBarMoved( QPoint ) ), this, SIGNAL( scrollBarMoved_SWindow( QPoint ) ) );
|
||||
|
||||
connect( m_cViewArea, SIGNAL( selectionChanged( QRect ) ), this, SLOT( updateSelectedArea( QRect ) ) );
|
||||
connect( m_cViewArea, SIGNAL( positionChanged( const QPoint & ) ), this, SLOT( updatePixelValueStatusBar( const QPoint & ) ) );
|
||||
@@ -343,7 +345,10 @@ Void VideoSubWindow::normalSize()
|
||||
Double factor = 1.0;
|
||||
Double curFactor = getScaleFactor() ;
|
||||
if( factor != curFactor )
|
||||
{
|
||||
m_cViewArea->scaleZoomFactor( factor/curFactor, QPoint() );
|
||||
adjustScrollBarByScale( factor/curFactor, QPoint() );
|
||||
}
|
||||
}
|
||||
|
||||
Void VideoSubWindow::zoomToFit()
|
||||
@@ -357,13 +362,20 @@ Void VideoSubWindow::zoomToFactor( Double factor , QPoint center )
|
||||
Double curFactor;
|
||||
curFactor = getScaleFactor() ;
|
||||
if( factor != curFactor )
|
||||
{
|
||||
m_cViewArea->scaleZoomFactor( factor/curFactor, center );
|
||||
adjustScrollBarByScale( factor/curFactor, center );
|
||||
}
|
||||
}
|
||||
|
||||
Void VideoSubWindow::scaleView( Double scale , QPoint center )
|
||||
{
|
||||
Q_ASSERT( m_cViewArea->image() );
|
||||
m_cViewArea->scaleZoomFactor( scale, center );
|
||||
if(scale!=1.0)
|
||||
{
|
||||
m_cViewArea->scaleZoomFactor( scale, center );
|
||||
adjustScrollBarByScale( scale, center );
|
||||
}
|
||||
}
|
||||
|
||||
Void VideoSubWindow::scaleView( const QSize & size, QPoint center )
|
||||
@@ -391,7 +403,10 @@ Void VideoSubWindow::scaleView( const QSize & size, QPoint center )
|
||||
|
||||
Double curFactor = getScaleFactor() ;
|
||||
if( factor != curFactor )
|
||||
{
|
||||
m_cViewArea->scaleZoomFactor( factor/curFactor, center );
|
||||
adjustScrollBarByScale( factor/curFactor, center );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+7
-6
@@ -109,17 +109,17 @@ Void ViewArea::setZoomFactor( Double f )
|
||||
update();
|
||||
}
|
||||
|
||||
Void ViewArea::scaleZoomFactor( Double scale, QPoint center )
|
||||
int ViewArea::scaleZoomFactor( Double scale, QPoint center )
|
||||
{
|
||||
Double zoomFactor;
|
||||
Double maxZoom = 100.0;
|
||||
Double minZoom = 0.01; //( 1.0 / m_pixmap.width() );
|
||||
|
||||
if( ( m_zoomFactor == minZoom ) && ( scale < 1 ) )
|
||||
return;
|
||||
return 1;
|
||||
|
||||
if( ( m_zoomFactor == maxZoom ) && ( scale > 1 ) )
|
||||
return;
|
||||
return 1;
|
||||
|
||||
zoomFactor = m_zoomFactor * scale;
|
||||
|
||||
@@ -131,7 +131,7 @@ Void ViewArea::scaleZoomFactor( Double scale, QPoint center )
|
||||
|
||||
setZoomFactor( zoomFactor );
|
||||
|
||||
emit zoomFactorChanged( scale, center );
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ViewArea::setMode( ViewMode mode )
|
||||
@@ -554,7 +554,8 @@ void ViewArea::wheelEvent( QWheelEvent *event )
|
||||
else
|
||||
scale=0.8;
|
||||
|
||||
scaleZoomFactor( scale , event->pos() );
|
||||
if(scaleZoomFactor( scale , event->pos() ) == 0)
|
||||
emit zoomFactorChanged( scale, event->pos() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -660,7 +661,7 @@ void ViewArea::mouseMoveEvent( QMouseEvent *event )
|
||||
if( tool() == NavigationTool )
|
||||
{
|
||||
QPoint offset = m_lastWindowPos - event->pos();
|
||||
emit moveScroll( offset );
|
||||
emit scrollBarMoved( offset );
|
||||
}
|
||||
|
||||
updateRect = viewToWindow( m_selectedArea );
|
||||
|
||||
+4
-3
@@ -115,7 +115,8 @@ public:
|
||||
void setInputStream( PlaYUVerStream *stream );
|
||||
PlaYUVerStream* getInputStream();
|
||||
|
||||
Void scaleZoomFactor(Double scale, QPoint center);
|
||||
// Scale function. Return 0 when scale is performed. Return 1 otherwise
|
||||
int scaleZoomFactor(Double scale, QPoint center);
|
||||
|
||||
void setTool( eTool tool );
|
||||
|
||||
@@ -124,8 +125,8 @@ public:
|
||||
Q_SIGNALS:
|
||||
void selectionChanged( const QRect &rect );
|
||||
void positionChanged( const QPoint &pos );
|
||||
void moveScroll( QPoint offset );
|
||||
void zoomFactorChanged( double factor , QPoint center);
|
||||
void scrollBarMoved( QPoint offset );
|
||||
void zoomFactorChanged( const double factor , const QPoint center);
|
||||
|
||||
public Q_SLOTS:
|
||||
void setNormalMode();
|
||||
|
||||
+15
-12
@@ -195,8 +195,9 @@ Void plaYUVerApp::loadFile( QString fileName, PlaYUVerStreamInfo* pStreamInfo )
|
||||
connect( videoSubWindow->getViewArea(), SIGNAL( selectionChanged( QRect ) ), m_appModuleVideo, SLOT( updateSelectionArea( QRect ) ) );
|
||||
|
||||
connect( subWindow, SIGNAL( updateStatusBar( const QString& ) ), this, SLOT( updateStatusBar( const QString& ) ) );
|
||||
connect( subWindow, SIGNAL( zoomChangedOnSubWindow() ), this, SLOT( updateZoomFactorSBox() ) );
|
||||
connect( subWindow, SIGNAL( scrollBarMoved( const QPoint ) ), this, SLOT( moveAllScrollBars( const QPoint ) ) );
|
||||
connect( subWindow, SIGNAL( zoomFactorChanged_SWindow( const double, const QPoint ) ), this, SLOT( updateZoomFactorSBox() ) );
|
||||
connect( subWindow, SIGNAL( zoomFactorChanged_SWindow( const double, const QPoint ) ), this, SLOT( zoomToFactorAll( double, QPoint ) ) );
|
||||
connect( subWindow, SIGNAL( scrollBarMoved_SWindow( const QPoint ) ), this, SLOT( moveAllScrollBars( const QPoint ) ) );
|
||||
|
||||
videoSubWindow->zoomToFit();
|
||||
videoSubWindow->getViewArea()->setTool( m_appTool );
|
||||
@@ -417,8 +418,13 @@ Void plaYUVerApp::zoomToFitAll()
|
||||
updateZoomFactorSBox();
|
||||
}
|
||||
|
||||
Void plaYUVerApp::zoomToFactorAll( double factor )
|
||||
Void plaYUVerApp::zoomToFactorAll( const double scale, const QPoint center )
|
||||
{
|
||||
qDebug() << scale << center;
|
||||
double factor;
|
||||
if( m_pcCurrentSubWindow )
|
||||
factor = m_pcCurrentSubWindow->getScaleFactor();
|
||||
|
||||
SubWindowHandle *subWindow;
|
||||
for( Int i = 0; i < mdiArea->subWindowList().size(); i++ )
|
||||
{
|
||||
@@ -426,7 +432,9 @@ Void plaYUVerApp::zoomToFactorAll( double factor )
|
||||
if( m_pcCurrentSubWindow == subWindow )
|
||||
continue;
|
||||
else
|
||||
subWindow->zoomToFactor(factor);
|
||||
{
|
||||
subWindow->zoomToFactor( factor , center );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -446,21 +454,16 @@ Void plaYUVerApp::zoomFromSBox( double zoom )
|
||||
{
|
||||
activeSubWindow()->zoomToFactor( factor );
|
||||
}
|
||||
|
||||
zoomToFactorAll( factor );
|
||||
}
|
||||
|
||||
Void plaYUVerApp::updateZoomFactorSBox()
|
||||
Void plaYUVerApp::updateZoomFactorSBox( )
|
||||
{
|
||||
Double factor;
|
||||
if( m_pcCurrentSubWindow )
|
||||
{
|
||||
Double factor = m_pcCurrentSubWindow->getScaleFactor();
|
||||
factor = m_pcCurrentSubWindow->getScaleFactor();
|
||||
m_pcZoomFactorSBox->setValue( factor * 100 );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pcZoomFactorSBox->setValue( 0.0 );
|
||||
}
|
||||
}
|
||||
|
||||
Void plaYUVerApp::moveAllScrollBars( const QPoint offset )
|
||||
|
||||
+1
-1
@@ -89,7 +89,7 @@ private Q_SLOTS:
|
||||
void normalSize();
|
||||
void zoomToFit();
|
||||
void zoomToFitAll();
|
||||
void zoomToFactorAll( double factor );
|
||||
void zoomToFactorAll( const double factor, const QPoint center = QPoint() );
|
||||
|
||||
void setTool( int idxTool );
|
||||
|
||||
|
||||
Reference in new issue
Block a user