Exemple #1
0
void Read::engine()
{
    QElapsedTimer timer;
    timer.start();

    qDebug() << "Engine CreateTable" << myParent->name();

    //qDebug() << "Myparent->getParent() - " << myParent->getParent();
    QStandardItemModel *model = getTableModel();// myParent->getParent()->getTableData();
    QGraphicsScene *scene = getScene2D();
    model->clear();
    scene->clear();


    qDebug() << "Got data: " << model;

    QFile file(_file);
    //qDebug() << "File exists: " << file.exists() << &_file2 << _file2;

    if (file.open(QIODevice::ReadOnly | QIODevice::Text)) {
        QTextStream in(&file);

        int row = 0;
        QStandardItem *newItem = 0;
        if (!in.atEnd() && _headers)
        {
            QString line = in.readLine();
            QStringList list = line.simplified().split(_delimiter);
            model->setHorizontalHeaderLabels(list);
        }
        while ( !in.atEnd() )
        {
           QString line = in.readLine();
           QStringList list = line.simplified().split(_delimiter);
           if (!line.startsWith("#") && line.contains(_delimiter)) {
               list = line.simplified().split(_delimiter);
               for (int col = 0; col < list.length(); ++col){
                   if (list.at(col).length() > 0) {
                       newItem = new QStandardItem(list.at(col));
                   } else {
                       newItem = new QStandardItem("");
                   }
                   model->setItem(row, col, newItem);
               }
               row++;
           }
        }
        qDebug() << "Lugesin ridu: " << row;

    }
    else
    {
        model->clear();
        scene->clear();
    }
    file.close();

    qDebug() << "Read Node took: " << timer.elapsed() << "milliseconds";

}
Exemple #2
0
void frmBoxes::changebox(int index)
{
    int box = index;
    refreshboxgrid(frmCurBoxNum);
    frmCurBoxNum = index;
    frmCurBox = &(cursavblock->boxes[box]);

    for(int bslot = 0; bslot < 30; bslot++)
    {
        pix = QPixmap();
        if(cursavblock->boxes[box].pokemon[bslot].species != Species::NOTHING)
        {
            pix = getpkmicon(cursavblock->boxes[box].pokemon[bslot]);
        }

        QGraphicsScene * boxscene = boxgraphics[bslot]->scene();
        if (boxscene == NULL)
        {
            boxscene = new QGraphicsScene();
            boxgraphics[bslot]->setScene(boxscene);
            boxgraphics[bslot]->installEventFilter(mouseEventEater);
        }
        boxscene->clear();
        boxscene->addPixmap(pix);
    }
    if(ui->cbBoxes->currentIndex() != index)
    {
        ui->cbBoxes->setCurrentIndex(index);
    }
    if(ui->sbBoxIncrem->value() != index)
    {
        ui->sbBoxIncrem->setValue(index);
    }
    QPixmap wallpaperpixmap = getwallpaperimage(cursavblock->boxwallpapers[box]);
    QGraphicsScene * wallpaperscene = ui->pbPCBox->scene();
    if (wallpaperscene == NULL)
    {
        wallpaperscene = new QGraphicsScene;
        ui->pbPCBox->setScene(wallpaperscene);
        ui->pbPCBox->setSceneRect(0,0,192,160);
        ui->pbPCBox->fitInView(0,0,153,111);
    }

    wallpaperscene->clear();
    wallpaperscene->addPixmap(wallpaperpixmap);
    for(int box = 0; box < 24; box++)
    {
        boxpreviewgraphics[box]->setFrameStyle(0);
    }
    ui->saBoxes->verticalScrollBar()->setValue(index * 76);
    boxpreviewgraphics[index]->setFrameStyle(1);
}
void MainWindow::drawLines(std::vector<Point> points){

    QGraphicsScene * scene = this->ui->gv_Visualizer->scene();
    scene->clear();
    QRect geo = this->ui->gv_Visualizer->rect();
    scene->setBackgroundBrush(Qt::black);
    QPen pen;
    Point previous;
    for(std::vector<Point>::iterator it = points.begin(); it != points.end(); ++it){
        if(it == points.begin()){
            previous = *it;
        }else{
            int alpha = 255;
            if((previous.r || previous.g || previous.b)){
                pen = QPen(QColor(previous.r?255:0,previous.g?255:0,previous.b?255:0,alpha));
            }else{
                pen = QPen(QColor(0,255,0,70));
                pen.setStyle(Qt::DashDotDotLine);
            }
            scene->addLine(previous.x*geo.width()/65535,previous.y*geo.height()/65535,(*it).x*geo.width()/65535,(*it).y*geo.height()/65535,pen);
            previous = *it;
        }
    }
    this->ui->gv_Visualizer->setScene(scene);
    this->ui->gv_Visualizer->update();

}
void UIDebugVDP1::on_lwCommandList_itemSelectionChanged ()
{
   int cursel = lwCommandList->currentRow();
   char tempstr[1024];

   Vdp1DebugCommand(cursel, tempstr);
   pteCommandInfo->clear();
   pteCommandInfo->appendPlainText(QtYabause::translate(tempstr));
   pteCommandInfo->moveCursor(QTextCursor::Start);

   if (vdp1texture)
      free(vdp1texture);

   vdp1texture = Vdp1DebugTexture(cursel, &vdp1texturew, &vdp1textureh);
   pbSaveBitmap->setEnabled(vdp1texture ? true : false);

   // Redraw texture
   QGraphicsScene *scene = gvTexture->scene();
   QImage img((uchar *)vdp1texture, vdp1texturew, vdp1textureh, QImage::Format_ARGB32);
   QPixmap pixmap = QPixmap::fromImage(img.rgbSwapped());
   scene->clear();
   scene->addPixmap(pixmap);
   scene->setSceneRect(scene->itemsBoundingRect());
   gvTexture->fitInView(scene->sceneRect());
   gvTexture->invalidateScene();
}
Exemple #5
0
void frmBoxes::refreshboxgrid(int box)
{
    QImage grid = QImage(60,50,QImage::Format_RGB32);
    QPixmap gridpix;
    pokemon_obj * pkm_c;
    uint32 color_val = 0;
    for(int sloty = 0; sloty < 5; sloty++)
    {
        QGraphicsScene * gridscene = boxpreviewgraphics[box]->scene();
        if (gridscene == NULL)
        {
            gridscene = new QGraphicsScene;
            boxpreviewgraphics[box]->setScene(gridscene);
        }

        for(int slotx = 0; slotx < 6; slotx++)
        {
            pkm_c = &(sav->cur.boxes[box].pokemon[(sloty*6)+slotx]);
            color_val = getpkmcolor(pkm_c->species);
            for(int x = 0; x < 10; x++)
            {
                for(int y = 0; y < 10; y++)
                {
                    grid.setPixel((slotx * 10) + x,(sloty * 10) + y,color_val);
                }
            }
        }
        gridscene->clear();
        gridpix = QPixmap::fromImage(grid);
        gridscene->addPixmap(gridpix);
    }
}
Exemple #6
0
void UIDebugVDP2Viewer::on_cbScreen_currentIndexChanged ( int index )
{   
	if (!Vdp2Regs)
		return;

   if (vdp2texture)
      free(vdp2texture);

   vdp2texture = Vdp2DebugTexture(index, &width, &height);
   pbSaveAsBitmap->setEnabled(vdp2texture ? true : false);

   // Redraw screen
   QGraphicsScene *scene = gvScreen->scene();
#ifdef USE_RGB_555
   QImage img((uchar *)vdp2texture, width, height, QImage::Format_RGB555);
#elif USE_RGB_565
   QImage img((uchar *)vdp2texture, width, height, QImage::Format_RGB16);
#else
   QImage img((uchar *)vdp2texture, width, height, QImage::Format_ARGB32);
#endif
   QPixmap pixmap = QPixmap::fromImage(img.rgbSwapped());
   scene->clear();
   scene->addPixmap(pixmap);
   scene->setSceneRect(scene->itemsBoundingRect());
   gvScreen->fitInView(scene->sceneRect());
   gvScreen->invalidateScene();
}
Exemple #7
0
void SectionDialog::redraw() {
    QGraphicsScene *scene = sectionPreview->scene();
    assert(scene!=NULL);
    scene->clear();
    qreal w = widthSpin->value();
    qreal h = heightSpin->value();
    scene->addRect(0,0,w,h,QPen(Qt::black,1), QBrush(Qt::red,Qt::BDiagPattern));
}
Exemple #8
0
void FormView::showForm(AbstractForm * form)
{

    QGraphicsScene *s = scene();

    s->clear();
    resetTransform();

    if(form == 0){
        return;
    }
    if(form->get_number_of_points() <= 0) {
        return;
    }

    int factor = 100;

    QPolygonF polygon;
    for(int i=0; i<form->get_number_of_points(); ++i){
        Point point = form->get_point_at_index(i);
        polygon.push_back(QPointF(point.get_x()*factor, point.get_y()*factor));
    }



    s->addPolygon(polygon, QPen(), QBrush(Qt::SolidPattern));

    QRectF bound = polygon.boundingRect();

    s->setSceneRect(bound);



    float realwidth = container->width() - 50;
    float width = bound.width();
    float realheight = container->height() - 50;
    float height = bound.height();

    float relw = 1;
    if(width > 0){
        relw =  realwidth / width;
    }

    float relh = 1;
    if(height > 0){
        relh = realheight / height;
    }

    float rel = relw;
    if(relh < relw){
        rel = relh;
    }

    scale(rel,rel);



}
Exemple #9
0
void View::changeHeight (int n)
{
	g_heightValue = n;
	QGraphicsScene * scene = view()->scene();
	view()->setScene(0);

	scene->clear();
	m_mainWindow->populateScene();
	view()->setScene(scene);
	m_graphicsView->viewport()->update();
}
void SvgView::refresh(void)
{
    QGraphicsScene *s = scene();
    QPixmap Image(mSvgRenderer->defaultSize());
    QPainter Painter;

    Image.fill(Qt::transparent);

    qWarning() << "SVG refresh() zoom factor" << mZoomLevel;
    Painter.begin(&Image);
    mSvgRenderer->render(&Painter);
    Painter.end();
    s->clear();
    s->addPixmap(Image);
}
void MainWindow::on_recoverThread_updateStatus(const DdrescueStatus &status,  DdrescueLog const &log)
{
    ui->lblRescuedValue->setText(formatBytes(status.rescued()));
    ui->lblIposValue->setText(formatBytes(status.ipos()));
    ui->lblOposValue->setText(formatBytes(status.opos()));

    ui->lblErrsizeValue->setText(formatBytes(status.errsize()));
    ui->lblErrorsValue->setText(QString::number(status.errors()));

    ui->lblAvgRateValue->setText(formatBytes(status.averageRate()) + "/s");
    ui->lblCurrRateValue->setText(formatBytes(status.currentRate()) + "/s");

    ui->lblTimeFrom->setText(QString::number(status.timeFromLastSuccessfulRead()) + " s");

    ui->lblStatus->setText(status.status());

    QGraphicsScene *scene = ui->graph->scene();
    if (!scene) {
        scene = new QGraphicsScene();
        ui->graph->setScene(scene);
    }
    scene->clear();
    qreal width = ui->graph->width()-5;
    qreal height = ui->graph->height()-5;
    scene->addRect(0,0,width,height,QPen(QColor(Qt::blue)), QBrush(QColor(Qt::blue)));

    long long sizeTotal = 0;
    for (int i = 0; i < log.blocks().size(); i++) {
        sizeTotal += log.blocks().at(i).size;
    }
    qreal wfactor = sizeTotal / width;


    if (sizeTotal > 0) {
       for (int i = 0; i < log.blocks().size(); i++) {
           qreal x = log.blocks().at(i).pos/wfactor;
           qreal w = log.blocks().at(i).size/wfactor;

            scene->addRect(x,0
                         ,w,height
                         ,QPen(statusBlock2QColor(log.blocks().at(i).status))
                         , QBrush(statusBlock2QColor(log.blocks().at(i).status)));
        }
    }

    scene->addText(formatBytes(sizeTotal));
}
Exemple #12
0
void dController::printOverSide(int RowId)
{

    //TODO это должно быть в отдельном классе !!!
    QGraphicsScene *scene = new QGraphicsScene();

    bool page_orient= false;
   int  margin_top = MM_TO_POINT(15);
   int  margin_bottom=MM_TO_POINT(15);
    int margin_left=MM_TO_POINT(35);
    int margin_right=MM_TO_POINT(15);
    int page_width=210;
    int page_height=297;

    scene->clear();
    scene->setSceneRect(0, 0, MM_TO_POINT(page_width),MM_TO_POINT(page_height));

    QGraphicsRectItem *border_rect = new QGraphicsRectItem (QRectF(margin_left, margin_top, MM_TO_POINT(page_width)-margin_left-margin_right,MM_TO_POINT(page_height)-margin_top-margin_bottom));
    qDebug() <<"margin_rect"<< margin_left << margin_top << margin_left<<margin_right;
    border_rect->setPen(QPen(Qt::black,2,Qt::DotLine));
    border_rect->setBrush(QBrush(Qt::white));
    border_rect->setOpacity(0.5);
    border_rect->setZValue(0);
    //border_rect->setData(ObjectName, "Border");
    scene->addItem(border_rect);

	    SimpleItem* MBitem = new SimpleItem;
	    MBitem->setPos(MM_TO_POINT(5), MM_TO_POINT(280));
	    MBitem->setPrintFrame(false);
	    MBitem->setText(QStringList()<<QString("МБ №-%1"));
	    MBitem->setFlag(QGraphicsItem::ItemIsMovable);

	    MBitem->setParentItem(border_rect);
	    //scene->addItem(MBtem);
	scene->update();

    QPrinter printer;
    printer.setPrinterName(curPrinter); //Печать на реальный принтер
     //printer.setOutputFormat(QPrinter::PdfFormat);
     //printer.setOutputFileName("overside.pdf");
     //printer.setPageSize(QPrinter::A4);
     QPainter painter(&printer);
     scene->render(&painter);

     //emit sayMeGood();
}
Exemple #13
0
void DatastreamView::redrawStreams() {
    int x = view->horizontalScrollBar()->value();
    int y = view->verticalScrollBar()->value();
    QPoint p(x, y);

    QGraphicsScene* scene = view->scene();
    scene->clear();

    for (std::list<PortOutButton*>::iterator i = portOuts.begin(); i != portOuts.end(); i++) {
        PortOut* p = (*i)->getPortOut();
        if (p->getDestination() != NULL) {
            QPoint l1 = (*i)->getPosition();
            QPoint l2 = ports[p->getDestination()]->getPosition();
            QPen pen = QPen((*i)->getConnectionColor(), Qt::SolidLine);
            pen.setWidth(LINE_WIDTH);

            if ((*i)->getPortSide() != (l2.x()-l1.x() < 0)) {
                int xmid = l1.x() + ((l2.x() - l1.x()) / 2);
                QPoint l3(xmid, l1.y());
                scene->addLine(QLine(l1,l3), pen);
                QPoint l4(xmid, l2.y());
                scene->addLine(QLine(l3,l4),pen);
                scene->addLine(QLine(l4,l2),pen);
            } else {
                int y1 = (*i)->getModuleMiddle().y();
                int ymid =  y1 + ((ports[p->getDestination()]->getModuleMiddle().y() - y1) / 2);

                int space = ((*i)->getPortSide()) ? CONNECTION_LINE_SPACE : -CONNECTION_LINE_SPACE;
                QPoint l3(l1.x() + space, l1.y());
                scene->addLine(QLine(l1,l3), pen);
                QPoint l4(l1.x() + space, ymid);
                scene->addLine(QLine(l3,l4), pen);
                QPoint l5(l2.x() - space, ymid);
                scene->addLine(QLine(l4,l5), pen);
                QPoint l6(l2.x() - space, l2.y());
                scene->addLine(QLine(l5,l6), pen);
                scene->addLine(QLine(l6,l2), pen);
            }
        }
    }
}
Exemple #14
0
void SvgView::openFile(const QFile &file)
{
    if (!file.exists())
        return;

    QGraphicsScene *s = scene();

    bool drawBackground = (m_backgroundItem ? m_backgroundItem->isVisible() : true);
    bool drawOutline = (m_outlineItem ? m_outlineItem->isVisible() : false);

    s->clear();
    resetTransform();

    m_svgItem = new QGraphicsSvgItem(file.fileName());
    m_svgItem->setFlags(QGraphicsItem::ItemClipsToShape);
    m_svgItem->setCacheMode(QGraphicsItem::NoCache);
    m_svgItem->setZValue(0);

    m_backgroundItem = new QGraphicsRectItem(m_svgItem->boundingRect());
    m_backgroundItem->setBrush(Qt::white);
    m_backgroundItem->setPen(Qt::NoPen);
    m_backgroundItem->setVisible(drawBackground);
    m_backgroundItem->setZValue(-1);

    m_outlineItem = new QGraphicsRectItem(m_svgItem->boundingRect());
    QPen outline(Qt::black, 2, Qt::DashLine);
    outline.setCosmetic(true);
    m_outlineItem->setPen(outline);
    m_outlineItem->setBrush(Qt::NoBrush);
    m_outlineItem->setVisible(drawOutline);
    m_outlineItem->setZValue(1);

    s->addItem(m_backgroundItem);
    s->addItem(m_svgItem);
    s->addItem(m_outlineItem);

    // use the actual bounding box of the SVG template to avoid any scaling effect
    // when printing the drawing (#0000932)
    s->setSceneRect(m_outlineItem->boundingRect());
}
Exemple #15
0
void SvgView::openFile(const QFile &file)
{
    if (!file.exists()) {
        return;
    }

    QGraphicsScene *s = scene();

    bool drawBackground = (m_backgroundItem ? m_backgroundItem->isVisible() : false);
    bool drawOutline = (m_outlineItem ? m_outlineItem->isVisible() : true);

    s->clear();
    resetTransform();

    m_svgItem = new QGraphicsSvgItem(file.fileName());
    m_svgItem->setFlags(QGraphicsItem::ItemClipsToShape);
    m_svgItem->setCacheMode(QGraphicsItem::NoCache);
    m_svgItem->setZValue(0);

    m_backgroundItem = new QGraphicsRectItem(m_svgItem->boundingRect());
    m_backgroundItem->setBrush(Qt::white);
    m_backgroundItem->setPen(Qt::NoPen);
    m_backgroundItem->setVisible(drawBackground);
    m_backgroundItem->setZValue(-1);

//    m_outlineItem = new QGraphicsRectItem(m_svgItem->boundingRect());
//    QPen outline(Qt::black, 2, Qt::DashLine);
//    outline.setCosmetic(true);
//    m_outlineItem->setPen(outline);
//    m_outlineItem->setBrush(Qt::NoBrush);
//    m_outlineItem->setVisible(drawOutline);
//    m_outlineItem->setZValue(1);

    s->addItem(m_backgroundItem);
    s->addItem(m_svgItem);
//    s->addItem(m_outlineItem);

    s->setSceneRect(m_svgItem->sceneBoundingRect());
}
void QImage2MatDialog::qimageShow(QImage& qImage, QGraphicsView*& graphView)
{
	int imageWidth  = qImage.width();
	int imageHeight = qImage.height();
	int viewWidth   = ui->graphicsView_qimg->width();
	int viewHight   = ui->graphicsView_qimg->height();

	QPixmap pixMap;
	pixMap = pixMap.fromImage(qImage.scaled(viewWidth, 
		viewHight, 
		Qt::KeepAspectRatioByExpanding));

#if 0
	qDebug() << viewWidth << " " << viewHight;
#endif

	QGraphicsScene *graphicsViewScene = new QGraphicsScene();
	graphicsViewScene->setSceneRect(0, 0, viewWidth, viewHight);
	graphicsViewScene->clear();
	graphicsViewScene->addPixmap(pixMap);

	graphView->setScene(graphicsViewScene);
	graphView->show();
}
Exemple #17
0
bool ImageView::openFile(QString fileName)
{
#ifndef QT_NO_SVG
    bool isSvg = false;
#endif
    QByteArray format = QImageReader::imageFormat(fileName);

    // if it is impossible to recognize a file format - file will not be open correctly
    if (format.isEmpty())
        return false;

#ifndef QT_NO_SVG
    if (format.startsWith("svg"))
        isSvg = true;
#endif

    QGraphicsScene *s = scene();

    bool drawBackground = (d->backgroundItem ? d->backgroundItem->isVisible() : false);
    bool drawOutline = (d->outlineItem ? d->outlineItem->isVisible() : true);

    s->clear();
    resetTransform();

    // image
#ifndef QT_NO_SVG
    if (isSvg) {
        d->imageItem = new QGraphicsSvgItem(fileName);
    } else
#endif
    {
        QPixmap pixmap(fileName);
        QGraphicsPixmapItem *pixmapItem = new QGraphicsPixmapItem(pixmap);
        pixmapItem->setTransformationMode(Qt::SmoothTransformation);
        d->imageItem = pixmapItem;
    }
    d->imageItem->setCacheMode(QGraphicsItem::NoCache);
    d->imageItem->setZValue(0);

    // background item
    d->backgroundItem = new QGraphicsRectItem(d->imageItem->boundingRect());
    d->backgroundItem->setBrush(Qt::white);
    d->backgroundItem->setPen(Qt::NoPen);
    d->backgroundItem->setVisible(drawBackground);
    d->backgroundItem->setZValue(-1);

    // outline
    d->outlineItem = new QGraphicsRectItem(d->imageItem->boundingRect());
    QPen outline(Qt::black, 1, Qt::DashLine);
    outline.setCosmetic(true);
    d->outlineItem->setPen(outline);
    d->outlineItem->setBrush(Qt::NoBrush);
    d->outlineItem->setVisible(drawOutline);
    d->outlineItem->setZValue(1);

    s->addItem(d->backgroundItem);
    s->addItem(d->imageItem);
    s->addItem(d->outlineItem);

    // if image size is 0x0, then it is not loaded
    if (d->imageItem->boundingRect().height() == 0 && d->imageItem->boundingRect().width() == 0)
        return false;
    emitScaleFactor();

    return true;
}
Exemple #18
0
    void 
ChartView::updateView()
{
    if(!m_block)
        return;
    QGraphicsScene * ChartViewScene = scene();

    if(!ChartViewScene)
        return;

    ChartViewScene->clear();


    int max_width = 0;
    int state_start = -1;
    int state_end = -1;
    int height = 0;
    int increment = 0;

    /* this scale factor decides the width each state on the ChartView*/
    double scale_factor;

    QTreeWidgetItemIterator iter(m_taskView);
    while(*iter){
        increment = m_taskView->visualItemRect(*iter).height();
        if(increment > 0) break;
    }

    m_rowHeight = increment;

    /* this is the initial value of the height, which is lined up
     * with the tasklist on the left-side. it will be incremented
     * as we traverse through the tasks*/
    height = 25;


    /*figure out the beginning and end of the Basic Block first*/
    for(unsigned i= 0; i < m_block->m_tasks.size(); i++){
        Task * task = m_block->m_tasks[i];
        if (state_end < task->m_endState)
            state_end= task->m_endState;
        if(state_start == -1 || state_start > task->m_beginState)
            state_start = task->m_beginState;
    }

    scale_factor = this->width() / (state_end + 1 - state_start);
    if(scale_factor > 50)
        scale_factor = 50; //upper bound
    else if(scale_factor < 25)
        scale_factor = 25; //lower bound
    max_width = scale_factor * (state_end + 1 - state_start);


    QPen pen;
    pen.setStyle(Qt::DotLine);
    pen.setWidth(1);
    pen.setBrush(Qt::gray);
    pen.setCapStyle(Qt::RoundCap);
    pen.setJoinStyle(Qt::RoundJoin);

    QList <BarGraphicsItem *> bars;

    for(unsigned i= 0; i < m_block->m_tasks.size(); i++){
        Task * task = m_block->m_tasks[i];
        ChartViewScene->addLine(0, height, max_width, height, pen);
        int x = (task->m_beginState - state_start) * scale_factor;
        int y = height;
        int x_offset = (task->m_endState + 1 - state_start) * scale_factor - x;
        int y_offset = m_rowHeight;
        height = height + y_offset;

        BarGraphicsItem *bar = new BarGraphicsItem(task);
        bar->setRect(x, y+1, x_offset, y_offset);
        ChartViewScene->addItem(bar);
        bars.push_back(bar);
    }

    //depending copy from task to corresponding bars
    for(int i = 0; i < (int)bars.size(); i++)
    {
        for(int j = 0; j < (int)bars.size(); j++)
        {
            if(i == j) continue;
            if(bars[i]->m_task->m_depending.contains(bars[j]->m_task))
                bars[i]->m_depending.push_back(bars[j]);
            if(bars[i]->m_task->m_dependent.contains(bars[j]->m_task))
                bars[i]->m_dependent.push_back(bars[j]);
        }
    }

    //add a line at the bottom
    ChartViewScene->addLine(0, height, max_width, height, pen);

    //add the column label
    int j = 0;
    for (int i = 0; i < max_width; i += scale_factor) {
        QGraphicsTextItem *textItem = new QGraphicsTextItem(
                QString::number(j+state_start));
        textItem->setPos(i, 0);
        ChartViewScene->addItem(textItem);
        ChartViewScene->addLine(i + scale_factor, 7, i + scale_factor, height, pen);
        j++;
    }

    setSceneRect(0, 0, max_width, height + m_rowHeight);


}
Exemple #19
0
void FormView::clear()
{
    QGraphicsScene *s = scene();
    s->clear();
}
Exemple #20
0
void FormView::showSetting(Setting setting)
{
    QGraphicsScene *s = scene();

    s->clear();
    resetTransform();


    int scale_fac = 10;
    int spacing = 20;
    int planeWidth = setting.get_problem()->get_plane_width()*scale_fac;
    int planeHeight = setting.get_problem()->get_plane_height()*scale_fac;
    QRectF bound;
    for (int i=0; i<setting.get_number_of_planes(); ++i)
    {
        int x_offset = i*(planeWidth+spacing)+(spacing/2);
        int y_offset = (spacing/2);
        QRectF plane(x_offset,y_offset,planeWidth, planeHeight);
        s->addRect(plane,QPen(), QBrush(QColor(188, 198, 204),Qt::SolidPattern));
        for (int j=0; j<setting.get_plane_at(i)->get_number_of_forms(); ++j)
        {
            QPolygonF polygon;
            Form form;
            setting.get_plane_at(i)->get_form_at(j, form);
            vector<Point>  points_of_current_form = *(form.get_points());
            for (int k=0; k<points_of_current_form.size(); ++k){
                Point point = points_of_current_form[k];
                polygon.push_back(QPointF(point.get_x()*scale_fac, point.get_y()*scale_fac));
            }

            QGraphicsPolygonItem * polyitem = s->addPolygon(polygon, QPen(QColor(Qt::red)), QBrush(Qt::SolidPattern));
            polyitem->setPos(x_offset, y_offset);
            bound = polygon.boundingRect();
        }
    }


    float realwidth = container->width() - 50;
    float width = setting.get_number_of_planes()*(planeWidth+spacing);
    float realheight = container->height() - 50;
    float height = planeHeight+spacing;
    s->setSceneRect(0,0,width,height);

    float relw = 1;
    if(width > 0){
        relw =  realwidth / width;
    }

    float relh = 1;
    if(height > 0){
        relh = realheight / height;
    }

    float rel = relw;
    if(relh < relw){
        rel = relh;
    }

    scale(rel,rel);

}
Exemple #21
0
void dController::printWithTemplate (int RowId)
{

    qDebug()<<Q_FUNC_INFO;
    //TODO это должно быть в отдельном классе !!!
    QGraphicsScene * scene = new QGraphicsScene();

    bool page_orient= false;
    int margin_top = MM_TO_POINT(15);
    int margin_bottom=MM_TO_POINT(15);
    int margin_left=MM_TO_POINT(35);
    int margin_right=MM_TO_POINT(15);

    int page_width=210;
    int page_height=297;
    scene->clear();
    scene->setSceneRect(0, 0, MM_TO_POINT(page_width),MM_TO_POINT(page_height));

QGraphicsRectItem *border_rect = new QGraphicsRectItem (QRectF(margin_left, margin_top, MM_TO_POINT(page_width)-margin_left-margin_right,MM_TO_POINT(page_height)-margin_top-margin_bottom));
    qDebug() <<"margin_rect"<< margin_left << margin_top << margin_left<<margin_right;
    border_rect->setPen(QPen(Qt::black,2,Qt::DotLine));
    border_rect->setBrush(QBrush(Qt::white));
    border_rect->setOpacity(0.5);
    border_rect->setZValue(0);
    //border_rect->setData(ObjectName, "Border");
    scene->addItem(border_rect);


	    SimpleItem* Gritem = new SimpleItem;
	    Gritem->setPos(MM_TO_POINT(180), MM_TO_POINT(0));
	    Gritem->setPrintFrame(false);
	    Gritem->setText(QStringList()<<QString("Секретно")<<QString("Пункт 12"));

	    Gritem->setFlag(QGraphicsItem::ItemIsMovable);

	    Gritem->setParentItem(border_rect);

	    SimpleItem* MBitem = new SimpleItem;
	    MBitem->setPos(MM_TO_POINT(5), MM_TO_POINT(280));
	    MBitem->setPrintFrame(false);
	    MBitem->setText(QStringList()<<QString("МБ №-%1"));//.arg(templ));
	    MBitem->setFlag(QGraphicsItem::ItemIsMovable);

	    scene->addItem(MBitem);//->setParentItem(border_rect);

	scene->update();

    QPrinter printer;
    QString with_t;
    with_t.append(spoolDIR).append("compl_teml2.pdf");

     printer.setOutputFormat(QPrinter::PdfFormat);
     printer.setOutputFileName(with_t);
     printer.setPageSize(QPrinter::A4);
     QPainter painter(&printer);
     scene->render(&painter);

     //QString in_file =mainPDF;
     //in_file.arg(QString(SID));
     qDebug() <<Q_FUNC_INFO<< mainPDF << outPDF;
     this->mergeTwoPDF(mainPDF,with_t,outPDF);
     // Рисуем последнюю страничку
     scene->clear();
    border_rect = new QGraphicsRectItem (QRectF(margin_left, margin_top, MM_TO_POINT(page_width)-margin_left-margin_right,MM_TO_POINT(page_height)-margin_top-margin_bottom));
    qDebug() <<"margin_rect"<< margin_left << margin_top << margin_left<<margin_right;
    border_rect->setPen(QPen(Qt::black,2,Qt::DotLine));
    border_rect->setBrush(QBrush(Qt::white));
    border_rect->setOpacity(0.5);
    border_rect->setZValue(0);
    //border_rect->setData(ObjectName, "Border");
    scene->addItem(border_rect);


	    SimpleItem* Lastitem = new SimpleItem;
	    Lastitem->setPos(MM_TO_POINT(40), MM_TO_POINT(200));
	    Lastitem->setPrintFrame(true);
	    Lastitem->setText(QStringList()<<QString("Секретно")
							 <<QString("Пункт 12")
							 <<QString("Исполнитель:ФИО исполнителя")
							 <<QString("Отпечатал:ФИО кто печатал")
							 <<QString("Телефон:2-63-15")
							 <<QString("Инв.№ 12/13")
							 <<QString("Дата: 09.09.09'")
							 <<QString("МБ №-%1"));//.arg(templ)
							//);

	    Lastitem->setFlag(QGraphicsItem::ItemIsMovable);

	    scene->addItem(Lastitem);//->setParentItem(border_rect);
     QPrinter printer2;

     printer2.setOutputFormat(QPrinter::PdfFormat);
     QString last_p;
     last_p.append(spoolDIR).append("last_page.pdf");
     printer2.setOutputFileName(last_p);
     printer2.setPageSize(QPrinter::A4);
     QPainter painter2(&printer2);
     scene->render(&painter2);

    // emit sayMeGood();
}
Exemple #22
0
// refresh ui elements
//
void BSplineVisDialog::renderScene(QGraphicsScene& scene, bool isPrinter) {
    scene.clear();

    if (ui.showCheckerboard->isChecked()) {
        RGBAImageType::Pointer image = ImageContainer::CreateBitmap(m_SrcImage, ui.imageOpacity->value());
        QPixmap qPixmap = ImageContainer::CreatePixmap(image);
        scene.addPixmap(qPixmap)->setZValue(-10);
    }

    if (ui.showWarpedCheckerboard->isChecked()) {
        RGBAImageType::Pointer image = ImageContainer::CreateBitmap(m_DstImage, ui.imageOpacity->value());
        QPixmap qPixmap = ImageContainer::CreatePixmap(image);
        scene.addPixmap(qPixmap)->setZValue(-10);
    }

    if (ui.showWarpedSlice->isChecked()) {
        RGBAImageType::Pointer image = ImageContainer::CreateBitmap(m_WarpedSlice, ui.imageOpacity->value());
        QPixmap qPixmap = ImageContainer::CreatePixmap(image);
        scene.addPixmap(qPixmap)->setZValue(-10);

    }

    if (m_RefImage.IsNotNull()) {
        const int gridRes = ui.gridResolution->value();
        QPen blackPen = QPen(QColor::fromRgbF(0,0,0,0.5));
        blackPen.setWidthF(.1);
        QPen linePen(QColor::fromRgbF(.5,.5,.5,ui.imageOpacity->value() / 255.0));
        if (ui.showCoordinateGrid->isChecked()) {
            QGraphicsGridItem* originalGrid = new QGraphicsGridItem();
            if (isPrinter) {
                // can printer have alpha value?
                originalGrid->SetPen(blackPen);
            } else {
                originalGrid->SetPen(linePen);
            }
            originalGrid->SetResolution(gridRes);
            originalGrid->SetGrid(gX, gY);
            scene.addItem(originalGrid);
            ui.bspView->fitInView(originalGrid, Qt::KeepAspectRatio);
        }
        if (ui.showWarpedCoordinateGrid->isChecked()) {
            QGraphicsGridItem* warpedGrid = new QGraphicsGridItem();
            if (isPrinter) {
                // can printer have alpha value?
                if (!ui.showNoImage->isChecked()) {
                    blackPen.setColor(QColor::fromRgbF(1, 1, 0));
                    blackPen.setWidthF(0.2);
                }
                warpedGrid->SetPen(blackPen);
            } else {
                warpedGrid->SetPen(linePen);
            }
            warpedGrid->SetResolution(gridRes);
            warpedGrid->SetGrid(tX, tY);
            scene.addItem(warpedGrid);
            ui.bspView->fitInView(warpedGrid, Qt::KeepAspectRatio);
        }
    }


    if (ui.showDetJacobian->isChecked() && m_DetJacobian.IsNotNull()) {
        RGBAImageType::Pointer image = ImageContainer::CreateBitmap(m_DetJacobian);
        QPixmap qDetPixmap = ImageContainer::CreatePixmap(image);
        scene.addPixmap(qDetPixmap);
    }


    if (m_Field.IsNotNull() && ui.showDisplacementField->isChecked()) {
        FieldIteratorType iter(m_Field, m_Field->GetBufferedRegion());
        for (iter.GoToBegin(); !iter.IsAtEnd(); ++iter) {
            DisplacementFieldType::IndexType idx = iter.GetIndex();
            DisplacementFieldType::PointType point;
            m_Field->TransformIndexToPhysicalPoint(idx, point);
            VectorType v = iter.Get();
            if (v.GetNorm() < 1) {
                continue;
            }
            DisplacementFieldType::PointType point2;
            point2[0] = point[0] + v[0];
            point2[1] = point[1] + v[1];
            scene.addLine(point[0], point[1], point2[0], point2[1], QPen(Qt::yellow));
        }

    }



    if (ui.showWarpedLandmarks->isChecked()) {
        double sz = ui.landmarkSize->value();
        for (int i = 0; i < m_WarpedLandmarks.rows(); i++) {
            double x = m_WarpedLandmarks[i][0];
            double y = m_WarpedLandmarks[i][1];
            QGraphicsItem* p = scene.addRect(x - sz, y - sz, sz*2, sz*2, QPen(Qt::yellow), QBrush(Qt::yellow, Qt::SolidPattern));
        }
    }


    // drawing order is important for correct pick up
    // only show when showLandmarks is checked
    //
    if (ui.showLandmarks->isChecked()) {
        double sz = ui.landmarkSize->value();
        for (int i = 0; i < m_VectorList.size(); i++) {
            QRectF& xy = m_VectorList[i];
            QPen linePen(Qt::yellow);
            QPen sourcePen(Qt::red);
            QBrush sourceBrush(Qt::red, Qt::SolidPattern);
            QPen targetPen(Qt::blue);
            QBrush targetBrush(Qt::blue, Qt::SolidPattern);
            linePen.setWidthF(sz * .5);
            if (isPrinter) {
                linePen.setWidthF(sz);
                linePen.setColor(QColor::fromRgbF(0.3, 0.6, 0.3));
            }
            scene.addLine(xy.left(), xy.top(), xy.right(), xy.bottom(), linePen);
            QGraphicsItem* dx = scene.addEllipse(xy.left() - sz, xy.top() - sz, sz*2, sz*2, sourcePen, sourceBrush);
            QGraphicsItem* dy = scene.addEllipse(xy.right() - sz, xy.bottom() - sz, sz*2, sz*2, targetPen, targetBrush);

            dx->setData(1, i);
            dy->setData(2, i);
            
        }
    }


}
Exemple #23
0
void MainWindow::drawinwindow()
{

    parsanddrow d;
    QGraphicsScene *scene = new QGraphicsScene(ui->graphicsView);
    scene->setSceneRect(0,0,725,575);//розмір сцені
    ui->graphicsView->setAlignment(Qt::AlignLeft|Qt::AlignTop );
    if(d.count(openfil())!=0)
    {
    QPixmap pcc;
    QPixmap modem;
    QPixmap sw;
    QPainterPath path;
    QFont font;
    font.setPixelSize(50);
    //pcc.load("C:/Users/Igro/build-vns_kma-Desktop_Qt_5_1_1_MinGW_32bit-Debug/pc.png");
    pcc.load("pc.png");
    modem.load("modem.png");
    sw.load("sw.png");
    QString l; //назва приладу
    QDebug qd= qDebug();
    int dd; //кілкість приладів
    dd=d.count(openfil());//кілкість рядків на 4 властивості отримаємо кілкість приладів
    d.cord(openfil());//заповнення масивік кординатами та іменами (and mac)
    if(dd)
    for(int h=0; h<dd; h++) //малювання
    {
        l=d.getdev(h);
                if(l=="sw")
                {
                    QGraphicsPixmapItem * a=scene->addPixmap(sw);
                    a->moveBy(d.getx(h),d.gety(h));
                    QFont font;
                    QPainterPath path;
                    a->setZValue(1);
                    font.setPixelSize(20);
                    font.setBold(false);
                    font.setFamily("Calibri");
                    path.addText(d.getx(h)-2,d.gety(h)+63,font,d.getname(h));
                    scene->addPath(path, QPen(QBrush(Qt::black), 1), QBrush(Qt::black));
                }
                if(l=="pc")
                {
                    QGraphicsPixmapItem * b=scene->addPixmap(pcc);
                    b->moveBy(d.getx(h),d.gety(h));
                    b->setZValue(1);
                    QFont font;
                    QPainterPath path;
                    font.setPixelSize(20);
                    font.setBold(false);
                    font.setFamily("Calibri");
                    path.addText(d.getx(h)-2,d.gety(h)+63,font,d.getname(h));
                    scene->addPath(path, QPen(QBrush(Qt::black), 1), QBrush(Qt::black));
                }
                if(l=="modem")
                {
                  QGraphicsPixmapItem * bc=scene->addPixmap(modem);
                  bc->moveBy(d.getx(h),d.gety(h));
                  bc->setZValue(1);
                  QFont font;
                  QPainterPath path;
                  font.setPixelSize(20);
                  font.setBold(false);
                  font.setFamily("Calibri");
                  path.addText(d.getx(h)-2,d.gety(h)+63,font,d.getname(h));
                  scene->addPath(path, QPen(QBrush(Qt::black), 1), QBrush(Qt::black));
                }
                if(l=="con")
                {   int xpoch[dd];
                    int ypoch[dd];
                    int xend[dd];
                    int yend[dd];
                    bool fir=false;
                    bool sec=false;
                    for(int i=0; dd>i;i++)
                    {
                        if(d.gatmacconnect1(h)==d.getmac(i))
                        {
                            xpoch[h]=d.getx(i);
                            ypoch[h]=d.gety(i);
                            fir=true;
                        }
                        else
                        if(d.gatmacconnect2(h)==d.getmac(i))
                        {
                            xend[h]=d.getx(i);
                            yend[h]=d.gety(i);
                            sec=true;
                        }

                    }
                    if(fir==false || sec==false)
                        {
                            d.delate(openfil(),h);
                        }

                    if(fir!=false && sec!=false)
                    scene->addLine(QLineF(xpoch[h]+15, ypoch[h]+15, xend[h]+15, yend[h]+15), QPen(Qt::blue, 2));
                }
                if((l!="modem")|(l!="sw")|(l!="pc"))
                {
                   qd<<l;
                }

     }
   // d.deletemas();
    }
    else
    {
        scene->clear();
    }

    ui->graphicsView->setScene(scene);
    ui->graphicsView->show();
    ui->graphicsView->scene()->installEventFilter(this);
}
Exemple #24
0
void VideoWidget::SetSceneControl(BaseSceneController *sceneControlIn)
{
    //Remove previous scene button controls
    while(this->ui->annotationTools->count()>0)
    {
        //This item usually corresponds to the widget generated by the control factory
        QLayoutItem *item = this->ui->annotationTools->itemAt(0);
        QWidget *custom = item->widget();
        assert(custom!=NULL);
        cout << custom->metaObject()->className() << endl;

        //Also iterate through to get child widgets and directly close and remove them
        QLayout *wlayout = custom->layout();
        assert(wlayout!=NULL);
        while(wlayout->count())
        {
            int test = wlayout->count();
            QLayoutItem *citem = wlayout->itemAt(0);
            QWidget *childw = citem->widget();
            assert(childw!=NULL);
            childw->close();
            wlayout->removeItem(citem);
            delete childw;
        }

        custom->close();
        this->ui->annotationTools->removeItem(item);
        delete custom;
    }

    //Remove previous menu controls

    //Clear previous scene
    QGraphicsScene *oldScene = this->ui->graphicsView->scene();
    if(oldScene!=NULL) oldScene->clear();

    //Activate new scene button controls
    this->sceneControl = sceneControlIn;
    if(this->sceneControl!=NULL)
    {
        MouseGraphicsScene *scene = this->sceneControl->GetScene();
        if(scene != NULL)
        {
            this->ui->graphicsView->setScene(scene);
            this->sceneControl->Redraw();
            this->SetRawScale(0.3);
        }
        else
            this->ui->graphicsView->setScene(NULL);

        QWidget *controls = this->sceneControl->ControlsFactory(this);
        if(controls!=NULL)
            this->ui->annotationTools->addWidget(controls);
    }
    else
    {
        this->ui->graphicsView->setScene(NULL);
        this->SetSceneControl(new class LogoSceneController(this));
    }

}
//------------------------------------------------------------------------------------------------
void CalibrationWidget::showImage(const QModelIndex& currentIndex)
{
    QGraphicsScene* scene = calibrationWidget->graphicsView->scene();

    // delete all items in the scene (currentImage)
    scene->clear();

    const int row = currentIndex.row();
    if (row < 0)
        return;
    
    const auto filePath = QString::fromStdString(imgModel->getImageData(row).filePath);


    if (!QFile::exists(filePath))
    {
        errorDialog->setText(
            trUtf8("Das Angeforderte Bild existiert nicht mehr im Dateisystem: ") + filePath);
        errorDialog->show();
        return;
    }

    switch (calibrationWidget->comboBox_ansicht->currentIndex())
    {
    case 0:
    {
        QImage img(filePath);

        if (img.isNull())
        {
            showError(trUtf8("Das Bild konnte nicht geöffnet werden."));
            return;
        }

        currentImage = new QGraphicsPixmapItem(QPixmap::fromImage(img));
        break;
    }
    case 1:
    {
        if (!calibTool.isCalibrationDataAvailable())
        {
            showError(trUtf8(
                "Für diese Funktion müssen erst Kameraparameter berechnet oder geladen werden."));
            return;
        }

        cv::Mat cvImg = cv::imread(filePath.toStdString(), CV_LOAD_IMAGE_COLOR);
        cv::Mat imgUndist;
        cv::undistort(cvImg, imgUndist, calibTool.getCameraMatrix(), calibTool.getDistCoeffs());

        currentImage = new QGraphicsPixmapItem(qtOpenCvConversions::cvMatToQPixmap(imgUndist));
        break;
    }
    case 2:
    {
        if (!calibTool.isCalibrationDataAvailable())
        {
            showError(trUtf8("Für diese Funktion müssen erst Kameraparameter geladen werden."));
            return;
        }

        try
        {
            if (!imgModel->getImageData(currentIndex.row()).found)
                currentImage = new QGraphicsPixmapItem(0);
            else
            {
                cv::Mat cvImg = cv::imread(filePath.toStdString(), CV_LOAD_IMAGE_COLOR);
                cv::drawChessboardCorners(cvImg, calibTool.getChessboardSize(),
                    imgModel->getImageData(currentIndex.row()).boardCornersImg, true);
                currentImage = new QGraphicsPixmapItem(qtOpenCvConversions::cvMatToQPixmap(cvImg));
            }
        }
        catch (const std::out_of_range& e)
        {
            showError(trUtf8("out_of_range exception. Dieses Bild existiert nicht mehr"));
            errorDialog->show();
            currentImage = new QGraphicsPixmapItem(0);
        }
        break;
    }
    }

    calibrationWidget->graphicsView->fitInView(currentImage, Qt::KeepAspectRatio);
    scene->addItem(currentImage);
}