NodeStatInspector::NodeStatInspector(QWidget* parent) : QWidget(parent) { setWindowFlags(Qt::Tool); QGraphicsScene* scene = new QGraphicsScene(); scene->addEllipse(70,10,16,16,QPen(),QBrush(DrawingCursor::white)); scene->addEllipse(70,60,16,16,QPen(),QBrush(DrawingCursor::blue)); scene->addRect(32,100,12,12,QPen(),QBrush(DrawingCursor::red)); QPolygonF poly; poly << QPointF(78,100) << QPointF(78+8,100+8) << QPointF(78,100+16) << QPointF(78-8,100+8); scene->addPolygon(poly,QPen(),QBrush(DrawingCursor::green)); scene->addEllipse(110,100,16,16,QPen(),QBrush(DrawingCursor::white)); QPen pen; pen.setStyle(Qt::DotLine); pen.setWidth(0); scene->addLine(78,26,78,60,pen); scene->addLine(78,76,38,100,pen); scene->addLine(78,76,78,100,pen); scene->addLine(78,76,118,100,pen); scene->addLine(135,10,145,10); scene->addLine(145,10,145,110); scene->addLine(145,60,135,60); scene->addLine(145,110,135,110); nodeDepthLabel = scene->addText("0"); nodeDepthLabel->setPos(150,20); subtreeDepthLabel = scene->addText("0"); subtreeDepthLabel->setPos(150,75); choicesLabel = scene->addText("0"); choicesLabel->setPos(45,57); solvedLabel = scene->addText("0"); solvedLabel->setPos(78-solvedLabel->document()->size().width()/2,120); failedLabel = scene->addText("0"); failedLabel->setPos(30,120); openLabel = scene->addText("0"); openLabel->setPos(110,120); QGraphicsView* view = new QGraphicsView(scene); view->setRenderHints(view->renderHints() | QPainter::Antialiasing); view->show(); scene->setBackgroundBrush(Qt::white); boxLayout = new QVBoxLayout(); boxLayout->setContentsMargins(0,0,0,0); boxLayout->addWidget(view); setLayout(boxLayout); setWindowTitle("Gist node statistics"); setAttribute(Qt::WA_QuitOnClose, false); setAttribute(Qt::WA_DeleteOnClose, false); }
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); }
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); }