void COscScaler::scaleX( const QPoint & at ) { int dx = at.x() - m_pd->m_at.x(); int sz = m_pd->xBottom->size().width(); qreal rel = 1.0 - (qreal)dx / (qreal)sz; qreal xMin = ( ( m_pd->xMaxBase + m_pd->xMinBase ) - rel * ( m_pd->xMaxBase - m_pd->xMinBase ) ) * 0.5; qreal xMax = ( ( m_pd->xMaxBase + m_pd->xMinBase ) + rel * ( m_pd->xMaxBase - m_pd->xMinBase ) ) * 0.5; m_pd->m_plot->setAxisScale( QwtPlot::xBottom, xMin, xMax ); emit scaleXChanged( xMin, xMax ); if ( m_pd->m_equalScales || m_keyEqualScales ) { qreal ratio = (qreal)m_pd->m_plot->canvas()->height() / (qreal)m_pd->m_plot->canvas()->width(); rel *= ratio; qreal yMin = ( ( m_pd->yMaxBase + m_pd->yMinBase ) - rel * ( m_pd->xMaxBase - m_pd->xMinBase ) ) * 0.5; qreal yMax = ( ( m_pd->yMaxBase + m_pd->yMinBase ) + rel * ( m_pd->xMaxBase - m_pd->xMinBase ) ) * 0.5; m_pd->m_plot->setAxisScale( QwtPlot::yLeft, yMin, yMax ); emit scaleYChanged( yMin, yMax ); } else { int dy = at.y() - m_pd->m_at.y(); sz = m_pd->yLeft->size().height(); qreal rel = 1.0 + (qreal)dy / (qreal)sz; qreal yMin = ( ( m_pd->yMaxBase + m_pd->yMinBase ) - rel * ( m_pd->yMaxBase - m_pd->yMinBase ) ) * 0.5; qreal yMax = ( ( m_pd->yMaxBase + m_pd->yMinBase ) + rel * ( m_pd->yMaxBase - m_pd->yMinBase ) ) * 0.5; m_pd->m_plot->setAxisScale( QwtPlot::yLeft, yMin, yMax ); emit scaleYChanged( yMin, yMax ); } m_pd->m_plot->replot(); }
void ModelDataModel::setScaleY(float arg) { if (m_scaleY == arg) return; m_scaleY = arg; if(m_model!=NULL) m_model->setScale(Vector3f(m_scaleX, m_scaleY, m_scaleZ)); emit scaleYChanged(arg); }
void COscScaler::onResizeRescale( const QSize & size, const QSize & oldSize ) { if ( m_pd->m_saveScales ) { qreal xMinBase = m_pd->m_plot->axisScaleDiv( QwtPlot::xBottom )->lowerBound(); qreal xMaxBase = m_pd->m_plot->axisScaleDiv( QwtPlot::xBottom )->upperBound(); qreal rel; if ( xMinBase < xMaxBase ) { if ( ( size.width() > 0 ) && ( oldSize.width() > 0 ) ) { rel = (qreal)size.width() / (qreal)oldSize.width(); qreal xMin = ( ( xMinBase + xMaxBase ) - rel * ( xMaxBase - xMinBase ) ) * 0.5; qreal xMax = ( ( xMinBase + xMaxBase ) + rel * ( xMaxBase - xMinBase ) ) * 0.5; if ( xMin != xMax ) { m_pd->m_plot->setAxisScale( QwtPlot::xBottom, xMin, xMax ); emit scaleXChanged( xMin, xMax ); } } } qreal yMinBase = m_pd->m_plot->axisScaleDiv( QwtPlot::yLeft )->lowerBound(); qreal yMaxBase = m_pd->m_plot->axisScaleDiv( QwtPlot::yLeft )->upperBound(); if ( yMinBase < yMaxBase ) { if ( ( size.height() > 0 ) && ( oldSize.height() > 0 ) ) { rel = (qreal)size.height() / (qreal)oldSize.height(); qreal yMin = ( ( yMinBase + yMaxBase ) - rel * ( yMaxBase - yMinBase ) ) * 0.5; qreal yMax = ( ( yMinBase + yMaxBase ) + rel * ( yMaxBase - yMinBase ) ) * 0.5; if ( yMin != yMax ) { m_pd->m_plot->setAxisScale( QwtPlot::yLeft, yMin, yMax ); emit scaleYChanged( yMin, yMax ); } } } m_pd->m_plot->replot(); } }
DefaultToolTransformWidget::DefaultToolTransformWidget( KoInteractionTool* tool, QWidget* parent ) : QMenu(parent) { m_tool = tool; setupUi( this ); setUnit( m_tool->canvas()->unit() ); connect( m_tool->canvas()->resourceManager(), SIGNAL( canvasResourceChanged( int, const QVariant& ) ), this, SLOT( resourceChanged( int, const QVariant& ) ) ); connect( rotateButton, SIGNAL( clicked() ), this, SLOT( rotationChanged() ) ); connect( shearXButton, SIGNAL( clicked() ), this, SLOT( shearXChanged() ) ); connect( shearYButton, SIGNAL( clicked() ), this, SLOT( shearYChanged() ) ); connect( scaleXButton, SIGNAL( clicked() ), this, SLOT( scaleXChanged() ) ); connect( scaleYButton, SIGNAL( clicked() ), this, SLOT( scaleYChanged() ) ); connect( scaleAspectCheckBox, SIGNAL( toggled( bool ) ), scaleYSpinBox, SLOT( setDisabled( bool ) ) ); connect( scaleAspectCheckBox, SIGNAL( toggled( bool ) ), scaleYButton, SLOT( setDisabled( bool ) ) ); connect( resetButton, SIGNAL( clicked() ), this, SLOT( resetTransformations() ) ); }
void COscScaler::dragXY( const QPoint & at ) { int dx = at.x() - m_pd->m_at.x(); int sz = m_pd->xBottom->size().width(); qreal rel = (qreal)dx / (qreal)sz; rel *= ( m_pd->xMaxBase - m_pd->xMinBase ); qreal xMin = m_pd->xMinBase - rel; qreal xMax = m_pd->xMaxBase - rel; m_pd->m_plot->setAxisScale( QwtPlot::xBottom, xMin, xMax ); emit scaleXChanged( xMin, xMax ); int dy = at.y() - m_pd->m_at.y(); sz = m_pd->yLeft->size().height(); rel = (qreal)dy / (qreal)sz; rel *= ( m_pd->yMaxBase - m_pd->yMinBase ); qreal yMin = m_pd->yMinBase + rel; qreal yMax = m_pd->yMaxBase + rel; m_pd->m_plot->setAxisScale( QwtPlot::yLeft, yMin, yMax ); emit scaleYChanged( yMin, yMax ); m_pd->m_plot->replot(); }
void COscScaler::mouseWheel( QEvent * e ) { QWheelEvent * we = reinterpret_cast< QWheelEvent * >( e ); int numDegrees = we->delta() / 8; int numSteps = numDegrees / 15; qreal zoom = (qreal)numSteps; zoom = ( zoom < 0.0 ) ? m_pd->wheelRatio : (1.0 / m_pd->wheelRatio); const QPoint & pt = we->pos(); QPointF at = QPointF( m_pd->m_plot->invTransform( QwtPlot::xBottom, pt.x() ), m_pd->m_plot->invTransform( QwtPlot::yLeft, pt.y() ) ); // Для оси Ox. qreal boundLow = m_pd->m_plot->axisScaleDiv( QwtPlot::xBottom )->lowerBound() - at.x(); qreal boundHigh = m_pd->m_plot->axisScaleDiv( QwtPlot::xBottom )->upperBound() - at.x(); if ( m_pd->wheelZoomX ) { boundLow *= zoom; boundHigh *= zoom; qreal xMin = boundLow + at.x(); qreal xMax = boundHigh + at.x(); m_pd->m_plot->setAxisScale( QwtPlot::xBottom, xMin, xMax ); emit scaleXChanged( xMin, xMax ); } // То же для оси Oy. if ( m_pd->wheelZoomY ) { boundLow = m_pd->m_plot->axisScaleDiv( QwtPlot::yLeft )->lowerBound() - at.y(); boundHigh = m_pd->m_plot->axisScaleDiv( QwtPlot::yLeft )->upperBound() - at.y(); boundLow *= zoom; boundHigh *= zoom; qreal yMin = boundLow + at.y(); qreal yMax = boundHigh + at.y(); m_pd->m_plot->setAxisScale( QwtPlot::yLeft, yMin, yMax ); emit scaleYChanged( yMin, yMax ); } m_pd->m_plot->replot(); }
void Square::scaleY(double scaleY) { leftDownTriangle.scaleY(scaleY); rightUpTriangle.scaleY(scaleY); emit scaleYChanged(scaleY); }