Beispiel #1
0
void Ruler::createPlugin(QObject *parent, QString idParent,plugin::PluginsManager *manager)
{
    if(idParent == "Main")
    {
        mainWin = MAINWINDOW(parent);
        if(mainWin!=0)
        {
            painter = PAINTWIDGETINTERFACE(mainWin->getPaintWidget());

            realPainter = RPWINTEFACE(painter->getRealPaintWidget());
            selection = GSRINTEFACE(realPainter->getSelection());
            connect(selection,SIGNAL(moved(qreal,qreal)),this,SLOT(moveSelection(qreal,qreal)));

            // добавление линеек
            painter->mySetViewportMargins(RULER_BREADTH,RULER_BREADTH,0,0);
            QGridLayout* gridLayout = new QGridLayout();
            gridLayout->setSpacing(0);
            gridLayout->setMargin(0);
            mHorzRuler = new QDRuler(QDRuler::Horizontal,this);
            mVertRuler = new QDRuler(QDRuler::Vertical,this);
            QWidget* fake = new QWidget();
            fake->setBackgroundRole(QPalette::Window);
            fake->setFixedSize(RULER_BREADTH,RULER_BREADTH);
            gridLayout->addWidget(fake,0,0);
            gridLayout->addWidget(mHorzRuler,0,1);
            gridLayout->addWidget(mVertRuler,1,0);
            gridLayout->addWidget(painter->viewport(),1,1);
            painter->setLayout(gridLayout);

            for(int i=0; i<W_COUNT; i++)
            {
                WayLine *w = new WayLine(painter->viewport());
                w->setVisible(false);
                waylines.append(w);
            }

            // сигналы из внешнего мира
            connect(painter,SIGNAL(mouseMoveEvent(QPoint,QPoint,qreal)),this,SLOT(mouseMoveCoords(QPoint,QPoint,qreal)));
            connect(painter,SIGNAL(paintEvent(QPoint)),this,SLOT(mouseMoveOrigin(QPoint)));
            connect(painter,SIGNAL(zoomEvent(qreal)),this,SLOT(zoomEvent(qreal)));

            // коннекты для направляющих
            connect(mHorzRuler,SIGNAL(rulerClick(QPoint)),this,SLOT(rulerClickedH(QPoint)));
            connect(mVertRuler,SIGNAL(rulerClick(QPoint)),this,SLOT(rulerClickedV(QPoint)));

            manager->addPlugins(this, "Scale");
        }
    }
}
Beispiel #2
0
bool PaintWidget::reset()
{
    emit zoomEvent(scaleVal = 1);

    setFrame(0.0, false);
    if( !painter.isEnabled() ) return false;

    setViewportColor( QColor( 100, 100, 100 ) );

    BACKGROUND( painter.background )->reset();

    setViewportType( fixedViewport );
    setViewportFixedSize( QSize( 640, 480 ) );

    for(int i=0; i<painter.layers.size(); i++)
    {
        while( painter.layers[i]->countObjects() > 0 )
                delete painter.layers[i]->remove( 0 );
        delete painter.layers[i];
    }
    painter.layers.clear();

    painter.addLayer(true, false, tr("Layer ") + "0");
    painter.selection.reset();
    painter.inKeyPressedHandler = false;
    painter.inSelectionMode = false;
    update();

    emit figureSelected( 0, -1);
    emit allLayersChanged();
    emit countFramesChanged( countFrames() );

    return true;
}
Beispiel #3
0
// масштабирование
void PaintWidget::scale( qreal s )
{
    qreal k = (scaleVal+s)/scaleVal;
    scaleVal += s;

    setViewportFixedSize( QSize( painter.size.width()*k, painter.size.height()*k ) );

    // масштабируем фигуры
    QPointF center = QPointF( 0,0 );
    for(int i = 0; i<painter.layers.size(); i++ )
    {
        painter.layers[i]->scale( k, k, center );
    }

    // масштабируем лист

    painter.selection.reset();
    painter.update();

    emit zoomEvent(scaleVal);
    emit StateChanged("Scale viewport");
}