Exemple #1
0
void WheelUkrWord::draw() const
{
    QGraphicsScene * scene = _view->scene();

    int letterHeight = 30;
    qreal radius1 = 20, radius2 = radius1 + letterHeight, radius3 = 200, radius4 = radius3 + letterHeight;

    QPen pen;
    pen.setWidth(2);

    scene->addEllipse(-radius1,-radius1,2*radius1,2*radius1,pen);
    scene->addEllipse(-radius2,-radius2,2*radius2,2*radius2,pen);
    scene->addEllipse(-radius3,-radius3,2*radius3,2*radius3,pen);
    scene->addEllipse(-radius4,-radius4,2*radius4,2*radius4,pen);

    QVector<QPointF> surnamePoints;
    QVector<qreal> angles;

    for (uint i = 0; i < surnameLength(); ++i)
    {
        qreal phi = M_PI * (360 / surnameLength() * i) / 180;
        qreal x1 = radius1 * cos(phi), y1 = radius1 * sin(phi);
        qreal x2 = radius2 * cos(phi), y2 = radius2 * sin(phi);
        scene->addLine(x1,y1,x2,y2,pen);
        surnamePoints.push_back(QPointF(x2,y2));
        // TODO: avoid additional computations (i.e. unnecessary conversion from radians to degrees
        angles.push_back(phi * 180 / M_PI);
    }
    surnamePoints.push_back(surnamePoints[0]);
    angles.push_back(360);

    QVector<QPointF> aphorismPoints;

    for (int i = 0; i < aphorism().length(); ++i)
    {
        qreal phi = M_PI * (360 / aphorism().length() * i) / 180;
        qreal x1 = radius3 * qCos(phi), y1 = radius3 * qSin(phi);
        qreal x2 = radius4 * qCos(phi), y2 = radius4 * qSin(phi);
        scene->addLine(x1,y1,x2,y2,pen);
        aphorismPoints.push_back(QPointF(x1,y1));
    }

    aphorismPoints.push_back(aphorismPoints[0]);

    for (uint i = 0; i < surnameLength(); ++i)
    {
        qreal part = 0.5 * (angles[i] + angles[i+1]) / 360 * aphorism().length();
        //part = qFloor(phi);
        int ipart = part;
        scene->addLine(surnamePoints[i].x(),surnamePoints[i].y(),aphorismPoints[ipart].x(),aphorismPoints[ipart].y(),pen);
        scene->addLine(surnamePoints[i+1].x(),surnamePoints[i+1].y(),aphorismPoints[ipart+1].x(),aphorismPoints[ipart+1].y(),pen);
    }

}
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();

}
Exemple #3
0
void DrawGraphics::drawGraph()
{
    QGraphicsScene *scene = new QGraphicsScene(m_graphicsView);
    QPen pen(Qt::black);
    scene->addLine(0,90,180,90,pen);//x
    scene->addLine(90,0,90,180,pen);//y
    m_graphicsView->setScene(scene);
}
Exemple #4
0
void Street::drawRed(QGraphicsScene& scene)
{
    // Thick red pen
    QPen pen(QBrush(Qt::red), 2);

    // Draw line from A to B
    scene.addLine(A->getX() + CITYSIZE/2, A->getY() + CITYSIZE/2, B->getX() + CITYSIZE/2, B->getY() + CITYSIZE/2, pen);
}
Exemple #5
0
  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);
  }
Exemple #6
0
MainWindow::MainWindow(QWidget *parent)
    : QWidget(parent)
{
    // create a scene with items,
    // use the view to show the scene
    QGraphicsScene *scene = new QGraphicsScene();
    QGraphicsView *gv = new QGraphicsView(this);
    gv->setScene(scene);
    if (gv->scene())
    {
        printf("renc: scene is not null.\n");

        // these two lines are at scene origin pos.
        scene->addLine(0, 0, 100, 0, QPen(Qt::red));
        scene->addLine(0, 0, 0, 100, QPen(Qt::green));

        /*QGraphicsRectItem *rect = */
        scene->addRect(QRectF(0,0,50,50), QPen(Qt::red), QBrush(Qt::green));

        // svg image
        QGraphicsSvgItem *svgItem = new QGraphicsSvgItem(svgFile2);
        scene->addItem((svgItem));
        svgItem->setPos(400, 0);
        bool rValid1 = svgItem->renderer()->isValid();
        printf("--%d--\n", rValid1);

        // QWidget to scene
        QPushButton *btn = new QPushButton("button 1");// at (0,0) by default.
        QGraphicsProxyWidget *btnWidget = scene->addWidget(btn);
        btnWidget->setPos(0, 400);

        //
        {
            SvgPushButton *btn2 = new SvgPushButton(svgFile1);
            QGraphicsProxyWidget *btnWidget2 = scene->addWidget(btn2);
            btnWidget2->setPos(400, 400);
        }
    }
    else
        printf("renc: scene is null.\n");

    //setCentralWidget(gv); setWindowTitle("Demo: graphics view");//QMainWindow
    setStyleSheet("background-color: rgb(100,120,50);");
}
void ImageViewWidget::updateView()
{

    QGraphicsScene *scene = new QGraphicsScene;
    scene->addPixmap(QPixmap::fromImage(im));
    if(showXhair&&false){

        QPoint xhair = imageToCompCoord(this->crosshair);
        QPen xPen(QColor(255,255,255));
        xPen.setWidth(3);
        xPen.setCapStyle(Qt::FlatCap);
        scene->addLine(xhair.x()-15,xhair.y(),xhair.x()-1,xhair.y(),xPen);
        scene->addLine(xhair.x(),xhair.y()-15,xhair.x(),xhair.y()-1,xPen);
        scene->addLine(xhair.x()+1,xhair.y(),xhair.x()+15,xhair.y(),xPen);
        scene->addLine(xhair.x(),xhair.y()+1,xhair.x(),xhair.y()+15,xPen);
    }
    setScene(scene);
    repaint();
}
Exemple #8
0
SEXP
scene_addSegments(SEXP scene, SEXP x1, SEXP y1, SEXP x2, SEXP y2, SEXP lwd)
{
    QGraphicsScene* s = unwrapQObject(scene, QGraphicsScene);
    int nlwd = length(lwd);
    int i, n = length(x1);
    for (i = 0; i < n; i++) {
	QGraphicsLineItem *item = s->addLine(REAL(x1)[i], REAL(y1)[i], REAL(x2)[i], REAL(y2)[i], 
					     QPen(Qt::black, REAL(lwd)[(i-1) % nlwd]));
	// 	    item->setFlags(QGraphicsItem::ItemIsSelectable | 
	// 			   QGraphicsItem::ItemIgnoresTransformations);
    }
    return R_NilValue;
}
Exemple #9
0
ItemBook::ItemBook(QString Title)
{
    dragging = false;
    this->Title = Title;

    QGraphicsScene scene;
    scene.setParent(this);
    scene.addText(this->Title);
    QPen pen(QColor(0,0,0));
    scene.addLine(QLineF(0,0,1,2));
    this->resize(64,64*1.5);
    this->setScene(&scene);

    QGraphicsSimpleTextItem text;
    text.setText("Hello world");
    scene.addItem(&text);
}
Exemple #10
0
Seperator::Seperator(bool hasArrow, int height, QWidget *parent) :
QGraphicsView(parent)
{
	QGraphicsScene *sc = new QGraphicsScene();
	sc->setBackgroundBrush(Qt::transparent);
	sc->setSceneRect(-18, 0, 40, height);
	setScene(sc);
	UI::init(this, false);
	this->setMinimumSize(40, height);

	sc->addLine(0, 0, 0, height, QPen(QColor(100, 149, 199), 3));
	if (hasArrow) {
		QGraphicsPixmapItem * arrow =
				new QGraphicsPixmapItem(QPixmap("./data/makeAndBreak/BlueNext.png"));
		arrow->setPos(-18, height / 2 - 20);
		sc->addItem(arrow);
	}
}
Exemple #11
0
int main(int argc, char **argv)
{
    QApplication app(argc, argv);


    QGraphicsScene scene;
    scene.setSceneRect(0,0, 100, 100);
    scene.addRect(QRectF(0,0, 100, 100));
    scene.addLine(QLineF(0,0, 100, 100));
    scene.addLine(QLineF(0,100, 100, 0));

    QGraphicsView* view = new QGraphicsView(&scene);
    CGAL::Qt::GraphicsViewNavigation navigation;
    view->installEventFilter(&navigation);
    view->viewport()->installEventFilter(&navigation);
    view->setRenderHint(QPainter::Antialiasing);

    view->show();
    return app.exec();
}
Exemple #12
0
void MainWindow::graf(){
	
    QGraphicsScene *scene = new QGraphicsScene(ui->graphicsView);
    QPen pen(Qt::red);




    scene->addLine( -180,250,250,250,pen);
    scene->addLine(250,250,245,245,pen);
    scene->addLine(250,250,245,255,pen);
    scene->addLine(250,230,245,240,pen);
    scene->addLine(245,230,247.5,236,pen);
    scene->addLine(-180,250,-180,0,pen);
    scene->addLine(-180,0,-185,5,pen);
    scene->addLine(-180,0,-175,5,pen);
    scene->addLine(-172,2,-168,10,pen);
    scene->addLine(-168,3,-172,10,pen);


    ui->graphicsView->setScene(scene);
}
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);
            }
        }
    }
}
void ServiceSystemUI::on_startAutoButton_clicked()
{
    QGraphicsScene * scene = new QGraphicsScene(ui->graphicsView);
    QPen pen(Qt::red);
    pen.setWidth(2);

    ServiceSystem::Results res;

    double p0 = 0, p1 = 0, diff = 0, precision = 0.1;
    int N = 10;

    struct result
    {
        double x, y;
        result()
            : x(0), y(0)
        {}
        result(double x_, double y_)
            : x(x_), y(y_)
        {}
    };

    std::vector<result> results;

    ui->max_y->setText("1");

    do
    {
        ServiceSystem s_system(ui->srcAmountText->text().toUInt(),
                               ui->buffSizeText->text().toUInt(),
                               ui->rcvAmountText->text().toUInt(),
                               ui->srcLambda->text().toDouble(),
                               ui->rcvLambda->text().toDouble());
        p0 = p1;
        //scene->clear();
        Coordinates crds(0, N, 0, 1);
        crds.draw(scene);
        pen.setColor(QColor(255 * N / 11000, 255 - 255 * N / 11000, 0));
        int step = std::round(N / 300);
        if (step == 0) {
            step = 1;
        }
        for (int i = 0; i < N; ++i)
        {
            s_system.make_step();
            ServiceSystem::Results lres = s_system.get_results();
            double p = 0;
            switch (ui->graphList->currentIndex())
            {
                case 0:
                {
                    p = 1. - ((double)lres.accepted / (double)lres.generated);
                    break;
                }
                case 1:
                {
                    p = lres.downtime / (ui->rcvAmountText->text().toUInt() * lres.final_time);
                    break;
                }
            }

            int px = std::round(i * crds.get_x_prop());
            int py = std::round(p * crds.get_y_prop());
            if (i % step == 0) {
                scene->addLine(px, py, px, py, pen);
            }
        }
        ui->graphicsView->setScene(scene);
        ui->graphicsView->update();

        res = s_system.get_results();
        switch (ui->graphList->currentIndex())
        {
            case 0:
            {
                p1 = 1. - ((double)res.accepted / (double)res.generated);
                break;
            }
            case 1:
            {
                p1 = res.downtime / (ui->rcvAmountText->text().toUInt() * res.final_time);
                break;
            }
        }
        results.push_back(result(N, p1));

        std::cout << "N = " << N << std::endl;
        std::cout << "P_0 = " << p0 << std::endl;
        std::cout << "P_1 = " << p1 << std::endl;
        if (p1 == 0) {
            break;
        }
        N = std::round((1.643 * 1.643 * (1 - p1)) / (p1 * precision * precision));
        if (N > 20000) {
            N = 20000;
        }
        std::cout << "New N = " << N << std::endl;
        diff = std::abs(p0 - p1);
    }
    while (diff >= precision * p0);

    Coordinates crds(0, N, 0, 1);
    pen.setWidth(10);
    int px = std::round(N * crds.get_x_prop());
    int py = std::round(p1 * crds.get_y_prop());
    scene->addLine(px, py, px, py, pen);
    scene->addLine(0, py, 0, py, pen);
    ui->graphicsView->setScene(scene);
    ui->max_x->setText(QString::number(N));

    ui->finalValue->setText("Refusal: " +
                            QString::number(1. - (double)res.accepted / (double)res.generated)
                            + "\nError: " + QString::number(std::abs(p0 - p1))
                            + "\nDowntime: " +
                            QString::number(res.downtime / (ui->rcvAmountText->text().toUInt()*res.final_time))
                            + "\nFinal time: " + QString::number(res.final_time));

    ui->finalValue->setStyleSheet("color: rgb(" + QString::number(pen.color().red())
                                  + "," + QString::number(pen.color().green())
                                  + "," + QString::number(pen.color().blue()) + ");");
}
Exemple #15
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);


}
void ChartPage::DrawChart()
{
    // create a scene and add it your view
    QGraphicsScene* scene = new QGraphicsScene();
    ui->graphicsView->setScene(scene);

    static int height = 300;
    static int width = 1000;

    boost::filesystem::path pathDebug = GetDataDir() / "debugblc.log";
    int line = CountLine(pathDebug.string().c_str());

    double *rawdata = new double[line * 2];
    double *drawdata = new double[line * 2 + 4]{0};
    int lineDraw = 1;
    int max;
    double maxdb;

    GetRawMiningDataFromFile(rawdata, (char*)pathDebug.string().c_str());
    GetDrawInfo(line, height, width, &lineDraw, &maxdb, &max, rawdata, drawdata);

    QPen pen(Qt::green, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen pen2(Qt::black, 1, Qt::DashLine, Qt::RoundCap, Qt::RoundJoin);
    QPen pen3(Qt::red, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);

    //draw horizontal line
    for (int y = 60; y <= height + 60; y += 60)
    {
        scene->addLine(0, -y, width, -y, pen2);
        if(y != 0 && y != 360)
        {
            QGraphicsTextItem * item;
            item = ui->graphicsView->scene()->addText (QString::number(maxdb * (y / 60) / 5 / COIN));
            item->setPos(0, -y - 20);
        }
    }
    QGraphicsTextItem * item;
    item = ui->graphicsView->scene()->addText ("0");
    item->setPos(0, -20);

    scene->addLine(0, 0, width, 0, pen3);
    scene->addLine(0, 0, 0, -height - 60, pen3);

    item = ui->graphicsView->scene()->addText ("24h");
    item->setPos(0, 0);
    //draw vertical line
    for (int x = 125; x < width; x+=125)
    {
        if(x != width)
            scene->addLine(x, 0, x, -height - 60, pen2);
        QGraphicsTextItem * item;
        item = ui->graphicsView->scene()->addText (QString::number((8 - x / 125) * 3) + "h");
        item->setPos(x, 0);
    }

    //draw chart
    for (int x = 0; x < lineDraw - 1; x++)
    {
        int x1 = drawdata[x * 2];
        int y1 = -drawdata[x * 2 + 1];
        int x2 = drawdata[x * 2 + 2];
        int y2 = -drawdata[x * 2 + 3];
        scene->addLine(x1, y1, x2, y2, pen);
    }

    ui->graphicsView->fitInView(scene->itemsBoundingRect());//,Qt::KeepAspectRatio);
    delete(rawdata);
    delete(drawdata);
}
Exemple #17
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 #18
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    QList<double> listX;
    QList<double> listY;


//    listX <<	0.45689999999999997
//             <<	1.4893000000000001
//             <<	2.7387999999999999
//             <<	3.8527999999999998
//             <<	5.0213000000000001
//             <<	6.1910999999999996
//             <<	7.3179999999999996
//             <<	8.5601000000000003
//             <<	9.8018000000000001
//             <<	11.041600000000001
//             <<	12.426399999999999
//             <<	13.5808
//             <<	14.8553;

//    listY 			<<	1203.3999999999999
//            <<	1084.4000000000001
//            <<	1135.3
//            <<	1201.8
//            <<	1139.4000000000001
//            <<	1140.6999999999998
//            <<	1183.5000000000005
//            <<	1211.7000000000005
//            <<	1306.799999999999
//            <<	1230.8000000000004
//            <<	1146.3999999999999
//            <<	1239.4999999999995
//            <<	1348.9000000000005;

    for(int i = 0; i < 20; i++)
    {
        listX.append(i*10);
        listY.append(rand()%500);
    }

    QGraphicsScene* scene = new QGraphicsScene;
    ui->graphicsView->setScene(scene);
    ui->graphicsView->setRenderHint(QPainter::Antialiasing);

    double x, y;
    for(int i = 0; i < listX.size(); i++)
    {
        x = listX.at(i);
        y = listY.at(i);
        scene->addEllipse(x, y, 3, 3, QPen(Qt::black), QBrush(Qt::black));
    }

    double appK = approxKoef(&listX, &listY);
    double appAddK = approxAddKoef(&listX, &listY);

    int f = 0;

    ui->label->setText(QString::number(appK));
    ui->label_2->setText(QString::number(appAddK));
    double n = 0;


    scene->addLine(listX.first(), appK*listX.at(0) + appAddK, listX.last(),appK*listX.last() + appAddK);
    scene->addEllipse(0,0,10,10, QPen(Qt::red), QBrush(Qt::red));
}
void CWinMainView::init()
{
	qDebug() << "#### CWinMainControler::init" << endl;

	m_tabWidgetCentral = new QTabWidget(); //Pas de parent, setCentralWidget l'attribura à la fenêtre
    QHBoxLayout* layoutGlobal = new QHBoxLayout(); 
    layoutGlobal->setContentsMargins ( 0, 0, 0, 0 );
    layoutGlobal->addWidget(m_tabWidgetCentral);
    
    this->setLayout(layoutGlobal);
	//setCentralWidget(m_tabWidgetCentral);

	//***HISTOGRAMME
	QGraphicsScene* scene = new QGraphicsScene();
#if !defined(RES_640_480)// || defined(MULTI_STREAM)
	scene->setSceneRect(0,0,SCENE_WIDTH, SCENE_HEIGHT);
#endif
	QPen pen(Qt::lightGray, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
	QColor color(Qt::lightGray);
	color.setAlpha(200);
	QBrush brush(color);
	for(int i=0; i<SCENE_HEIGHT-1; i=i+10)
	{
		scene->addLine(0,i,SCENE_WIDTH-15, i, pen);
		/*scene->addText(QString::number(i))->setPos(-10,i-5);	*/		
	}
	pen.setColor(Qt::black);
	scene->addLine(0,SCENE_HEIGHT,SCENE_WIDTH-15, SCENE_HEIGHT, pen);
	m_lblMesureGraph = new QLabel("                            ");
	scene->addWidget(m_lblMesureGraph)->setPos(0,-20);
	m_lblConcentrationMax = new QLabel("1000");
	m_lblConcentrationMax->setObjectName("lblGraphUnit");
	m_lblConcentrationMin = new QLabel("0");
	m_lblConcentrationMin->setObjectName("lblGraphUnit");
	m_lblConcentrationMoy = new QLabel("500");
	m_lblConcentrationMoy->setObjectName("lblGraphUnit");
	QLabel* lblInfo = new QLabel();
	lblInfo->setObjectName("lblGraphInfo");
	
	scene->addWidget(m_lblConcentrationMax)->setPos(SCENE_WIDTH-23,-10);
	scene->addWidget(m_lblConcentrationMoy)->setPos(SCENE_WIDTH-13,(SCENE_HEIGHT/2)-10);
	scene->addWidget(m_lblConcentrationMin)->setPos(SCENE_WIDTH-13,SCENE_HEIGHT-10);
	QGraphicsProxyWidget* proxyLblInfo= new QGraphicsProxyWidget();
	proxyLblInfo->setWidget(lblInfo);
	//proxyLblInfo = scene->addWidget(lblInfo)
	proxyLblInfo->resize(100, 60);
	proxyLblInfo->setPos(SCENE_WIDTH - 140, -20);
	proxyLblInfo->setVisible(false);
	
	int i;
    for(int j=0; j<m_pModel->getNbStream(); ++j)
    {
        QList<CGraphicsRectItem*> list;
	    for(i=0; i<SCENE_WIDTH-20; i=i+10)
	    {
            if(j==0)
            {
		        if(i%4==0 || i==0)
		        {
			        scene->addLine(i,SCENE_HEIGHT+3, i,SCENE_HEIGHT-3, pen);
			        m_listGraphicsRectItem.append(new CGraphicsRectItem(i, SCENE_HEIGHT, 20, 0, proxyLblInfo));//, proxyLblMesure));
			        m_listGraphicsRectItem.last()->setBrush(brush);
			        m_listGraphicsRectItem.last()->setPen(color);
			        scene->addItem(m_listGraphicsRectItem.last());
		        }
		        else
			        scene->addLine(i,SCENE_HEIGHT, i,SCENE_HEIGHT-3, pen);
            }
            if(i%4==0 || i==0)
            {
                list.append(new CGraphicsRectItem(i, SCENE_HEIGHT, 20, 0, proxyLblInfo));//, proxyLblMesure));
                list.last()->setBrush(brush);
                list.last()->setPen(color);
            }
    			
	    }
        m_listDataGraph.append(list);
    }
	scene->addLine(i,SCENE_HEIGHT+3, i,SCENE_HEIGHT-3, pen);
	pen.setColor(Qt::green);
	scene->addItem(proxyLblInfo);
	QGraphicsView* view= new QGraphicsView(scene);
	QHBoxLayout* graphLayout = new QHBoxLayout();
	graphLayout->addWidget(view);
    graphLayout->setContentsMargins ( 0, 0, 0, 0 );
   
	QWidget* widgetGraph = new QWidget();
	widgetGraph->setLayout(graphLayout);
	//FIN HISTGRAMME

	
    
	qDebug() << "#### CWinMainControler::init 0" << endl;
    
	QVBoxLayout* centralLayout = new QVBoxLayout();
	for(int i=0; i<m_pModel->getNbStream(); ++i)
	{

        QList<QLabel*> listLblMesure;
        QList<QLabel*> listLblValMesure;
        qDebug() << "#### CWinMainControler::init 1 " << i <<endl;
        m_mesureLayout = new QGridLayout(); //Pas de parent, setLayout affect m_groupBoxCentral en parent
        //m_mesureLayout->setHorizontalSpacing(1);

        CPushButton* btDetail = new CPushButton(i);
        btDetail->setObjectName("btDetail");
        m_listBtDetail.append(btDetail);

        QLabel* lblStatusVoie = new QLabel("0000000000");
        lblStatusVoie->setObjectName("lblStatusWaterFailure");
        m_listLblStatusVoie.append(lblStatusVoie);
        
		for(int j=0; j<m_pModel->getNbMeasure(i); ++j)
		{
			qDebug() << "#### CWinMainControler::init 2 " << j <<endl;
            QLabel* lblMesure = new QLabel(QString(" ")+ m_pModel->getMesureValueLbl(i, j));
			lblMesure->setObjectName("lblMesure");
			listLblMesure.append(lblMesure);
			
            QLabel* lblNumVoie = new QLabel(QString("_") +QString::number(i+1));
			lblNumVoie->setObjectName("lblMesure");
            
			QLabel* lblValMesure = new QLabel(m_pModel->getMesureValue(i, j) + m_pModel->getMesureValueUnit(i, j));
			lblValMesure->setObjectName("lblValMesure");
			listLblValMesure.append(lblValMesure);
		
            int row = i+j;
            int col = 0;

#ifdef MULTI_MEASURE
            if(j==0) //Afficher le bouton de détail uniquement pour la première mesure.
            {
                m_mesureLayout->addWidget(btDetail,row, col++, Qt::AlignLeft);

            }
            else
                col++;
			m_mesureLayout->addWidget(lblMesure,row, col++,  Qt::AlignLeft);//m_lblValMesure);
			m_mesureLayout->addWidget(lblValMesure,row, col++,  Qt::AlignLeft);
#ifdef MULTI_STREAM
            if(j==0) 
            m_mesureLayout->addWidget(lblStatusVoie,row, col++,  Qt::AlignRight);
#endif
			 m_mesureLayout->setColumnStretch ( col, 1 );
#else
			if(j==0)
			{
				m_mesureLayout->addWidget(btDetail,row, col++, Qt::AlignLeft);
				m_mesureLayout->addWidget(lblMesure,row, col++,  Qt::AlignLeft);//m_lblValMesure);
				m_mesureLayout->addWidget(lblValMesure,row, col++,  Qt::AlignLeft);
#ifdef MULTI_STREAM
				m_mesureLayout->addWidget(lblStatusVoie,row, col++,  Qt::AlignRight);
#endif
				m_mesureLayout->setColumnStretch ( col, 1 );
			}
#endif
            
#ifdef MAGNESIUM
			++j; //ne pas afficher la deuxième mesure
#endif      
           
		}
        m_listLblValMesure.append(listLblValMesure);
		m_listLblMesure.append(listLblMesure);

		centralLayout->addLayout(m_mesureLayout); 
	}

	//m_lblMesure = new QLabel(tr("MESURE"));
	//m_lblMesure->setObjectName("lblMesure");
	//m_lblValMesure = new QLabel("VAL MESURE");
	//m_lblValMesure->setObjectName("lblValMesure");
	//m_btDetail = new QPushButton();
	//m_btDetail->setObjectName("btDetail");
	//QHBoxLayout* mesureLayout = new QHBoxLayout(); //Pas de parent, setLayout affect m_groupBoxCentral en parent
	//mesureLayout->addWidget(m_btDetail,0, Qt::AlignLeft);
	//mesureLayout->addWidget(m_lblMesure,0, Qt::AlignLeft);//m_lblValMesure);
	//mesureLayout->addWidget(m_lblValMesure,50 , Qt::AlignLeft);


	//info du cycle
	m_lblStatusAnalyseur = new QLabel("INITIALISATION");
	m_lblStatusAnalyseur->setObjectName("lblStatusAnalyseur");
	m_lblStatusWaterFailure= new QLabel;
	m_lblStatusWaterFailure->setObjectName("lblStatusWaterFailure");
	m_lblStatusSeuil= new QLabel;
	m_lblStatusSeuil->setObjectName("lblStatusSeuil");
	m_lblCurrentStream = new QLabel;
	m_lblCurrentStream->setObjectName("lblCurrentStream");
	m_lblCurrentStep = new QLabel;
	m_lblCurrentStep->setObjectName("lblCurrentStep");
	m_lblTotalStep = new QLabel;
	m_lblTotalStep->setObjectName("lblTotalStep");
	m_lblNameStep = new QLabel;
	m_lblNameStep->setObjectName("lblNameStep");
	m_lblDateHeure = new QLabel;
	m_lblDateHeure->setObjectName("lblDateHeure");

	QHBoxLayout* horizontalLayout = new QHBoxLayout();
	horizontalLayout->setObjectName("horizontalLayout");
	//horizontalLayout->addWidget(m_lblStatusAnalyseur, 40); //40%
	horizontalLayout->addWidget(m_lblCurrentStream, 30);
	horizontalLayout->addWidget(m_lblCurrentStep, 15); 
	horizontalLayout->addWidget(m_lblTotalStep, 15); 

	
	QVBoxLayout* verticalTmpLayout = new QVBoxLayout();
	verticalTmpLayout->addStretch();
#if defined(RES_640_480) && defined(MULTI_STREAM)
	
	verticalTmpLayout->addWidget(m_lblStatusAnalyseur);
#elif defined(RES_640_480)
    if(m_pModel->getNbStream() < 2) //pour test
	{
		verticalTmpLayout->addWidget(m_lblStatusWaterFailure);
		verticalTmpLayout->addWidget(m_lblStatusSeuil);
	}
	verticalTmpLayout->addWidget(m_lblStatusAnalyseur);
#else
	QHBoxLayout* layoutTmpH = new QHBoxLayout();
	QVBoxLayout* layoutTmpV = new QVBoxLayout();
	layoutTmpV->addWidget(m_lblStatusWaterFailure);
	layoutTmpV->addWidget(m_lblStatusSeuil);
	layoutTmpH->addWidget(m_lblStatusAnalyseur);
	layoutTmpH->addLayout(layoutTmpV);
	verticalTmpLayout->addLayout(layoutTmpH);
#endif
	verticalTmpLayout->addLayout(horizontalLayout);
	verticalTmpLayout->addWidget(m_lblNameStep); 
	verticalTmpLayout->addWidget(m_lblDateHeure);


	//QVBoxLayout* horizontalBottomTmpLayout = new QVBoxLayout();
	//horizontalBottomTmpLayout->addWidget(m_lblNameStep); 
	//horizontalBottomTmpLayout->addWidget(m_lblDateHeure);

	//QVBoxLayout* verticalTmpLayout = new QVBoxLayout();
	//verticalTmpLayout->addWidget(m_lblStatusAnalyseur);
	//verticalTmpLayout->addLayout(horizontalLayout);
	//verticalTmpLayout->addLayout(horizontalBottomTmpLayout);


	//Assemblage m_groupBoxCentral et m_groupBoxInfo
	
#if defined(RES_640_480) && !defined(MULTI_STREAM) && !defined(MULTI_MEASURE)
	centralLayout->addWidget(widgetGraph);
#endif
	centralLayout->addLayout(verticalTmpLayout); //5%

	//Bouttons de droite
	m_btAlarm = new QPushButton();
	m_btAlarm->setObjectName("btAlarm");
	m_btAlarm->setCheckable(true);
	m_btPlayPause = new QPushButton();
	m_btPlayPause->setObjectName("btPlayPause");
	m_btStop = new QPushButton();
	m_btStop->setObjectName("btStop");
	m_btStopEndCycle = new QPushButton();
	m_btStopEndCycle->setObjectName("btStopEndCycle");
	m_btNext = new QPushButton();
	m_btNext->setObjectName("btNext");

	QVBoxLayout* verticalLayout = new QVBoxLayout();
	verticalLayout->addStretch();
	verticalLayout->addWidget(m_btAlarm);
	verticalLayout->addWidget(m_btPlayPause);
	verticalLayout->addWidget(m_btStop);
	verticalLayout->addWidget(m_btStopEndCycle);
#if defined(RES_640_480)
	verticalLayout->addWidget(m_btNext);
#endif

	//Assemblage m_groupBoxRight et centralLayout
	QHBoxLayout* topLayout = new QHBoxLayout();
	topLayout->addLayout(centralLayout, 90); //95%
	//topLayout->addWidget(m_groupBoxRight, 10); //5%
	topLayout->addLayout(verticalLayout, 10); //5%
	
	QWidget* widgetMain = new QWidget();
	widgetMain->setLayout(topLayout);
	
	m_tabWidgetCentral->addTab(widgetMain, tr("MESURE"));
//	m_tabWidgetCentral->setLayout(mainLayout);
	

	//*** Page Diagnostique
	QWidget* widgetDiag = new QWidget();
	
	//Utilisation des boutons pour l'affichage seul (pour ne pas refaire le CSS), ils ne sont pas connectés
	m_btTemperatureCuve = new QPushButton;
	m_btTemperatureCuve->setObjectName("btLineEdit");
	m_btPressionEau = new QPushButton;
	m_btPressionEau->setObjectName("btLineEdit");
	m_btMesureOptique = new QPushButton;
	m_btMesureOptique->setObjectName("btLineEdit");
	m_btOpticalGain = new QPushButton;
	m_btOpticalGain->setObjectName("btLineEdit");
	m_btOpticalMeasurement = new QPushButton;
	m_btOpticalMeasurement->setObjectName("btLineEdit");
	m_btZeroOpticalMeasurement = new QPushButton;
	m_btZeroOpticalMeasurement->setObjectName("btLineEdit");
    m_btAbsorbanceValue = new QPushButton;
	m_btAbsorbanceValue->setObjectName("btLineEdit");
	QGridLayout* gridLayout = new QGridLayout();
    int row =0;
    gridLayout->addWidget(new QLabel(m_pModel->getOpticalGainLbl()), row,0);
	gridLayout->addWidget(m_btOpticalGain, row, 1);
	gridLayout->addWidget(new QLabel(m_pModel->getOpticalGainUnit()), row++,2);
#ifndef CYANURE
    gridLayout->addWidget(new QLabel(m_pModel->getZeroOpticalMeasurementLbl()), row,0);
	gridLayout->addWidget(m_btZeroOpticalMeasurement, row, 1);
	gridLayout->addWidget(new QLabel(m_pModel->getZeroOpticalMeasurementUnit()), row++,2);
    gridLayout->addWidget(new QLabel(m_pModel->getOpticalMeasurementLbl()), row,0);
	gridLayout->addWidget(m_btOpticalMeasurement, row, 1);
	gridLayout->addWidget(new QLabel(m_pModel->getOpticalMeasurementUnit()), row++,2);
#endif
    gridLayout->addWidget(new QLabel(m_pModel->getAbsorbanceValueLbl()), row,0);
	gridLayout->addWidget(m_btAbsorbanceValue, row, 1);
	gridLayout->addWidget(new QLabel(m_pModel->getAbsorbanceValueUnit()), row++,2);
#ifdef SONDE
	gridLayout->addWidget(new QLabel(tr("Mesure électrode")), row,0);
#else
	gridLayout->addWidget(new QLabel(tr("Mesure optique direct")), row,0);
#endif
	gridLayout->addWidget(m_btMesureOptique, row, 1);
	gridLayout->addWidget(new QLabel(tr("Pts")), row++,2);
#ifndef COULEUR
	gridLayout->addWidget(new QLabel(tr("Température Cuve")), row,0);
	gridLayout->addWidget(m_btTemperatureCuve, row, 1);
	gridLayout->addWidget(new QLabel(tr("°C")), row++,2);
#endif
	gridLayout->addWidget(new QLabel(tr("Capteur de pression d'eau")), row,0);
	gridLayout->addWidget(m_btPressionEau, row, 1);
	gridLayout->addWidget(new QLabel(tr("V")), row++,2);
	
	m_lblCurrentStreamDiag = new QLabel;
	m_lblCurrentStreamDiag->setObjectName("lblCurrentStream");
	m_lblCurrentStepDiag = new QLabel;
	m_lblCurrentStepDiag->setObjectName("lblCurrentStep");
	m_lblTotalStepDiag = new QLabel;
	m_lblTotalStepDiag->setObjectName("lblTotalStep");
	m_lblNameStepDiag = new QLabel;
	m_lblNameStepDiag->setObjectName("lblNameStep");
	

	QHBoxLayout* horizontalLayoutDiag = new QHBoxLayout();
	horizontalLayoutDiag->setObjectName("horizontalLayout");
	horizontalLayoutDiag->addWidget(m_lblCurrentStreamDiag, 30);
	horizontalLayoutDiag->addWidget(m_lblCurrentStepDiag, 15); 
	horizontalLayoutDiag->addWidget(m_lblTotalStepDiag, 15); 
    
    QVBoxLayout* verticalLayoutDiag = new QVBoxLayout();
    verticalLayoutDiag->addStretch();
    verticalLayoutDiag->addLayout(gridLayout);
    verticalLayoutDiag->addStretch();
#if defined(RES_640_480)
    verticalLayoutDiag->addLayout(horizontalLayoutDiag);
    verticalLayoutDiag->addWidget(m_lblNameStepDiag);
#endif

	

	widgetDiag->setLayout(verticalLayoutDiag);
	//: Nom de l'onglet à laisser en maj pour toutes les trads
	m_tabWidgetCentral->addTab(widgetDiag, tr("DIAGNOSTIC"));

	//***Menu outils

	//Groupe des boutons 
	//Colonne 1 
	m_btMaintenance = new QPushButton();
	m_btMaintenance->setObjectName("btMaintenance");
	QLabel* lblMaintenance = new QLabel(tr("Maintenance"));
	lblMaintenance->setObjectName("lblOutils");
	m_btSequenceur = new QPushButton();
	m_btSequenceur->setObjectName("btSequenceur");
	QLabel* lblSequenceur = new QLabel(tr("Options"));
	lblSequenceur->setObjectName("lblOutils");
	m_btCopyLogFiles = new QPushButton();
	m_btCopyLogFiles->setObjectName("btCopyLogFiles");
	QLabel* lblCopyLogFiles = new QLabel(tr("Copie des fichiers log"));
	lblCopyLogFiles->setObjectName("lblOutils");
	/*m_btHelp = new QPushButton("");
	m_btHelp->setObjectName("btHelp");
	QLabel* lblHelp = new QLabel("Aide");
	lblHelp->setObjectName("lblOutils");*/
		//Colonne 2
	m_btMeasureCard = new QPushButton();
	m_btMeasureCard->setObjectName("btMeasureCard");
	QLabel* lblMeasureCard = new QLabel(tr("Test électrique"));
	lblMeasureCard->setObjectName("lblOutils");
	/*m_btSave = new QPushButton("");
	m_btSave->setObjectName("btSave");
	QLabel* lblSave = new QLabel("Sauvegarde");
	lblSave->setObjectName("lblOutils");
	m_btInformation = new QPushButton("");
	m_btInformation->setObjectName("btInformation");
	QLabel* lblInformation = new QLabel("Information");
	lblInformation->setObjectName("lblOutils");*/
		//Colonne 3
	/*m_btExternalCard = new QPushButton();
	m_btExternalCard->setObjectName("btExternalCard");
	QLabel* lblExternalCard = new QLabel(tr("Carte externe"));
	lblExternalCard->setObjectName("lblOutils");*/
	/*m_btParameter = new QPushButton();
	m_btParameter->setObjectName("btParameter");
	QLabel* lblParameter = new QLabel("Pramètres");
	lblParameter->setObjectName("lblOutils");
	m_btExplorer = new QPushButton();
	m_btExplorer->setObjectName("btExplorer");
	QLabel* lblExplorer = new QLabel("Exploreur");
	lblExplorer->setObjectName("lblOutils");*/
		//Colonne 4
	/*m_btEvPump = new QPushButton();
	m_btEvPump->setObjectName("btEvPump");
	QLabel* lblEvPump = new QLabel(tr("EV/Pompe"));
	lblEvPump->setObjectName("lblOutils");*/
	/*m_btAnalyseur = new QPushButton();
	m_btAnalyseur->setObjectName("btAnalyseur");
	QLabel* lblAnalyseur = new QLabel("Analyseur");
	lblAnalyseur->setObjectName("lblOutils");*/
	m_btSwitchConfig = new QPushButton();
	connect(m_btSwitchConfig, SIGNAL(clicked()), m_pControler, SLOT(btSwitchConfigPressed()));
	m_btSwitchConfig->setObjectName("btSwitchConfig");
	QLabel* lblSwitchConfig = new QLabel(tr("Switch config"));
	lblSwitchConfig->setObjectName("lblOutils");
	m_btHistorique = new QPushButton();
	m_btHistorique->setObjectName("btHistorique");
	QLabel* lblHistorique = new QLabel(tr("Historique"));
	lblHistorique->setObjectName("lblOutils");

	QGridLayout *gridLayoutBt = new QGridLayout();
	
	gridLayoutBt->addWidget(m_btMaintenance, 0, 0, Qt::AlignHCenter);
	gridLayoutBt->addWidget(lblMaintenance, 1, 0, Qt::AlignTop|Qt::AlignHCenter);
	gridLayoutBt->addWidget(m_btSequenceur, 2, 0, Qt::AlignHCenter);
	gridLayoutBt->addWidget(lblSequenceur, 3, 0, Qt::AlignTop|Qt::AlignHCenter);
#if defined(RES_640_480) //pas de copie de fichier pour le petit panel/ni d'historique
	gridLayoutBt->addWidget(m_btCopyLogFiles, 4, 0, Qt::AlignHCenter);
	gridLayoutBt->addWidget(lblCopyLogFiles, 5, 0, Qt::AlignTop|Qt::AlignHCenter);

	gridLayoutBt->addWidget(m_btHistorique, 2, 3, Qt::AlignHCenter);
	gridLayoutBt->addWidget(lblHistorique, 3, 3, Qt::AlignTop|Qt::AlignHCenter);
#if !defined(RES_640_480)
	gridLayoutBt->addWidget(m_btSwitchConfig, 4, 3, Qt::AlignHCenter);
	gridLayoutBt->addWidget(lblSwitchConfig, 5, 3, Qt::AlignTop|Qt::AlignHCenter);
#endif
#else
	gridLayoutBt->addWidget(m_btSwitchConfig, 2, 3, Qt::AlignHCenter);
	gridLayoutBt->addWidget(lblSwitchConfig, 3, 3, Qt::AlignTop|Qt::AlignHCenter);
#endif
	
	/*gridLayoutBt->addWidget(m_btHelp, 4, 0, Qt::AlignHCenter);
	gridLayoutBt->addWidget(lblHelp, 5, 0, Qt::AlignTop|Qt::AlignHCenter);*/
	gridLayoutBt->addWidget(m_btMeasureCard, 0, 3, Qt::AlignHCenter);
	gridLayoutBt->addWidget(lblMeasureCard, 1, 3, Qt::AlignTop|Qt::AlignHCenter);
	/*gridLayoutBt->addWidget(m_btSave, 2, 1, Qt::AlignHCenter);
	gridLayoutBt->addWidget(lblSave, 3, 1, Qt::AlignTop|Qt::AlignHCenter);
	gridLayoutBt->addWidget(m_btInformation, 4, 1, Qt::AlignHCenter);
	gridLayoutBt->addWidget(lblInformation, 5, 1, Qt::AlignTop|Qt::AlignHCenter);*/
	/*gridLayoutBt->addWidget(m_btExternalCard, 2, 3, Qt::AlignHCenter);
	gridLayoutBt->addWidget(lblExternalCard, 3, 3, Qt::AlignTop|Qt::AlignHCenter);*/
	/*gridLayoutBt->addWidget(m_btParameter, 2, 2, Qt::AlignHCenter);
	gridLayoutBt->addWidget(lblParameter, 3, 2, Qt::AlignTop|Qt::AlignHCenter);
	gridLayoutBt->addWidget(m_btExplorer, 4, 2, Qt::AlignHCenter);
	gridLayoutBt->addWidget(lblExplorer, 5, 2, Qt::AlignTop|Qt::AlignHCenter);*/
	/*gridLayoutBt->addWidget(m_btEvPump, 4, 3, Qt::AlignHCenter);
	gridLayoutBt->addWidget(lblEvPump, 5, 3, Qt::AlignTop|Qt::AlignHCenter);*/
	/*gridLayoutBt->addWidget(m_btAnalyseur, 2, 3, Qt::AlignHCenter);
	gridLayoutBt->addWidget(lblAnalyseur, 3, 3, Qt::AlignTop|Qt::AlignHCenter);*/
	
	

	QWidget* widgetMenuTools = new QWidget();
	widgetMenuTools->setLayout(gridLayoutBt);

	m_tabWidgetCentral->addTab(widgetMenuTools, tr("OUTILS"));

    //*** Onglet HISTOGRAMME
    m_btNextGraph  = new QPushButton();
    m_btNextGraph->setObjectName("btNextBig");
    m_btPrevGraph = new QPushButton();
    m_btPrevGraph->setObjectName("btPrevBig");
    m_btPrevGraph->setEnabled(false);;
    m_lblInfoGraph = new QLabel("INFO GRAPH");
    m_lblInfoGraph->setObjectName("lblNameStep");
#if !defined(RES_640_480) || defined(MULTI_STREAM) || defined(MULTI_MEASURE)
	
    {
        
        QVBoxLayout* layoutMenuGraph = new QVBoxLayout();
        layoutMenuGraph->setContentsMargins ( 0, 0, 0, 0 );
        layoutMenuGraph->addStretch();
	    layoutMenuGraph->addWidget(m_btPrevGraph);
	    layoutMenuGraph->addWidget(m_btNextGraph);
        
        QVBoxLayout* layoutGraph = new QVBoxLayout();
        layoutGraph->addWidget(widgetGraph);
    #ifdef MULTI_STREAM
        layoutGraph->addWidget(m_lblInfoGraph);
    #endif
        QHBoxLayout* layoutMain = new QHBoxLayout();
	    layoutMain->addLayout(layoutGraph);
    #ifdef MULTI_STREAM
        layoutMain->addLayout(layoutMenuGraph);
    #endif
        QWidget* widgetGraphTool = new QWidget();
        widgetGraphTool->setLayout(layoutMain);
#if !defined(MULTI_MEASURE) &&  !defined(MULTI_STREAM)
#ifndef CERIUM
	    m_tabWidgetCentral->addTab(widgetGraphTool, tr("HISTOGRAMME"));
#endif
#endif
    }
	//**** Onglet des choses en plus pas importante
		
	//Groupe des boutons 
#endif

	/*m_btSequenceur = new QPushButton();
	m_btSequenceur->setObjectName("btSequenceur");
	QLabel* lblSequenceur = new QLabel(tr("Séquenceur"));
	lblSequenceur->setObjectName("lblOutils");*/
	m_btSave = new QPushButton("");
	m_btSave->setObjectName("btSave");
	QLabel* lblSave = new QLabel(tr("Restaurer"));
	lblSave->setObjectName("lblOutils");
	m_btInformation = new QPushButton("");
	m_btInformation->setObjectName("btInformation");
	QLabel* lblInformation = new QLabel(tr("Information"));
	lblInformation->setObjectName("lblOutils");
	m_btParameter = new QPushButton();
	m_btParameter->setObjectName("btParameter");
	QLabel* lblParameter = new QLabel(tr("Paramètres"));
	lblParameter->setObjectName("lblOutils");
	m_btExplorer = new QPushButton();
	m_btExplorer->setObjectName("btExplorer");
	QLabel* lblExplorer = new QLabel(tr("Exploreur"));
	lblExplorer->setObjectName("lblOutils");
	m_btQuit = new QPushButton();
	m_btQuit->setObjectName("btExit");
	QLabel* lblQuit = new QLabel(tr("Quitter"));
	lblQuit->setObjectName("lblOutils");
	/*m_btAnalyseur = new QPushButton();
	m_btAnalyseur->setObjectName("btAnalyseur");
	QLabel* lblAnalyseur = new QLabel("Analyseur");
	lblAnalyseur->setObjectName("lblOutils");*/
	/*m_btHelp = new QPushButton("");
	m_btHelp->setObjectName("btHelp");
	QLabel* lblHelp = new QLabel("Aide");
	lblHelp->setObjectName("lblOutils");*/

	QGridLayout *gridLayoutBtPlus = new QGridLayout();
	
	//gridLayoutBtPlus->addWidget(m_btSequenceur, 0, 1, Qt::AlignHCenter);
	//gridLayoutBtPlus->addWidget(lblSequenceur, 1, 1, Qt::AlignTop|Qt::AlignHCenter);
	/*gridLayoutBtPlus->addWidget(m_btParameter, 0, 1, Qt::AlignHCenter);
	gridLayoutBtPlus->addWidget(lblParameter, 1, 1, Qt::AlignTop|Qt::AlignHCenter);*/
	
	gridLayoutBtPlus->addWidget(m_btExplorer, 0, 0, Qt::AlignHCenter);
	gridLayoutBtPlus->addWidget(lblExplorer, 1, 0, Qt::AlignTop|Qt::AlignHCenter);
	gridLayoutBtPlus->addWidget(m_btSave, 2, 0, Qt::AlignHCenter);
	gridLayoutBtPlus->addWidget(lblSave, 3, 0, Qt::AlignTop|Qt::AlignHCenter);
	gridLayoutBtPlus->addWidget(m_btInformation, 4, 0, Qt::AlignHCenter);
	gridLayoutBtPlus->addWidget(lblInformation, 5, 0, Qt::AlignTop|Qt::AlignHCenter);
	gridLayoutBtPlus->addWidget(m_btQuit, 4, 1, Qt::AlignTop|Qt::AlignHCenter);
	gridLayoutBtPlus->addWidget(lblQuit, 5, 1, Qt::AlignTop|Qt::AlignHCenter);
	/*gridLayoutBtPlus->addWidget(m_btHelp, 4, 0, Qt::AlignHCenter);
	gridLayoutBtPlus->addWidget(lblHelp, 5, 0, Qt::AlignTop|Qt::AlignHCenter);*/
	/*gridLayoutBtPlus->addWidget(m_btAnalyseur, 2, 3, Qt::AlignHCenter);
	gridLayoutBtPlus->addWidget(lblAnalyseur, 3, 3, Qt::AlignTop|Qt::AlignHCenter);*/
	
	QWidget* widgetPlus = new QWidget();
	widgetPlus->setLayout(gridLayoutBtPlus);

	m_tabWidgetCentral->addTab(widgetPlus, " + ");
	
	setConnexion();
	qDebug() << "#### FIN CWinMainControler::CWinMainView" << endl;
}
void skeletonVisualization::updateImage()
{
    if (ready)
    {

    QGraphicsScene *newScene = new QGraphicsScene;

    // draw image
    if (drawImage)
    {
        QPixmap newPixmap = QPixmap::fromImage(image);
        if (scale != 1)
            newPixmap = newPixmap.scaled(newPixmap.size() * scale,
                                         Qt::KeepAspectRatio,
                                         Qt::SmoothTransformation);
        newScene->addPixmap(newPixmap);
    }

    // draw image
    if (drawContours)
    {
        QPen pen(Qt::blue, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);

        for (uint i = 0; i < skeleton.contours.size(); i++)
        {
            for (uint j = 0; j < skeleton.contours[i].corners.size() - 1; j++)
                newScene->addLine(
                            scale * skeleton.contours[i].corners[j].x,
                            scale * skeleton.contours[i].corners[j].y,
                            scale * skeleton.contours[i].corners[j + 1].x,
                            scale * skeleton.contours[i].corners[j + 1].y,
                            pen);

            newScene->addLine(
                        scale * skeleton.contours[i].corners[0].x,
                        scale * skeleton.contours[i].corners[0].y,
                        scale * skeleton.contours[i].corners
                                [skeleton.contours[i].corners.size() - 1].x,
                        scale * skeleton.contours[i].corners
                                [skeleton.contours[i].corners.size() - 1].y,
                        pen);
        }
    }

    // draw skeleton (bones & circles)
    for (uint i = 0; i < skeleton.components.size(); i++)
    {
        // draw bones
        if (drawBones)
        {
            QPen pen(Qt::red, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);

            for (uint j = 0; j < skeleton.components[i].bones.size(); j++)
                newScene->addLine(
                            scale * skeleton.components[i].nodes
                                [skeleton.components[i].bones[j].i].x + 1,
                            scale * skeleton.components[i].nodes
                                [skeleton.components[i].bones[j].i].y + 1,
                            scale * skeleton.components[i].nodes
                                [skeleton.components[i].bones[j].j].x + 1,
                            scale * skeleton.components[i].nodes
                                [skeleton.components[i].bones[j].j].y + 1,
                            pen);
        }

        // draw circles
        if (drawCircles)
        {
            QPen pen(Qt::green, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);

            for (uint j = 0; j < skeleton.components[i].nodes.size(); j++)
                newScene->addEllipse(scale * (skeleton.components[i].nodes[j].x
                                              + 1 - skeleton.components[i].
                                              nodes[j].r),
                                     scale * (skeleton.components[i].nodes[j].y
                                              + 1 - skeleton.components[i].
                                              nodes[j].r),
                                     2*scale*skeleton.components[i].nodes[j].r,
                                     2*scale*skeleton.components[i].nodes[j].r,
                                     pen);
        }
    }

    ui.imageView->setScene(newScene);
    if (scene)
        delete scene;
    scene = newScene;

    }
}
Exemple #21
0
int main (int argc, char * argv[])
{
	QApplication app( argc, argv );
	
	//  Create QGraphicsScene
	QGraphicsScene scene;
	scene.setSceneRect( -600, -250, 1200, 500 );
	scene.setItemIndexMethod( QGraphicsScene::NoIndex );
	
	//  Draw road
	scene.addLine( -350, -150, -350, -100 );
	scene.addLine( -500, -100, -350, -100 );
	scene.addLine( -500, -50, -350, -50 );
	scene.addLine( -350, 150, -350, -50 );
	scene.addLine( -300, 150, -300, -50 );
	scene.addLine( -300, -150, -300, -100 );

	scene.addLine( -300, -100, 300, -100 );
	scene.addLine( -300, -50, 300, -50 );

	scene.addLine( 350, -150, 350, -100 );
	scene.addLine( 500, -100, 350, -100 );
	scene.addLine( 500, -50, 350, -50 );
	scene.addLine( 350, 150, 350, -50 );
	scene.addLine( 300, 150, 300, -50 );
	scene.addLine( 300, -150, 300, -100 );
	
	scene.addLine( -325, -100, -325, -150 );
	scene.addLine( -325, -50, -325, 150 );
	scene.addLine( 325, -100, 325, -150 );
	scene.addLine( 325, -50, 325, 150 );
	scene.addLine( -475, -75, -350, -75 );
	scene.addLine( -300, -75, 300, -75 );
	scene.addLine( 475, -75, 350, -75 );
	
	//  Road notation
	QGraphicsItem* ptext = scene.addText( "BSN" );
	ptext->setPos( -340, -180 );

	ptext = scene.addText( "BSS" );
	ptext->setPos( -340, 150 );

	ptext = scene.addText( "TBN" );
	ptext->setPos( 310, -180 );
	
	ptext = scene.addText( "TBS" );
	ptext->setPos( 310, 150 );
	
	ptext = scene.addText( "RHW" );
	ptext->setPos( -550, -85 );

	ptext = scene.addText( "RHE" );
	ptext->setPos( 510, -85 );

	//  Draw traffic lights

	//  Add cars to scene
	//Car *car = new Car;
	CarGenerator *pcargen = new CarGenerator( eBSN, -337.5, -150, Qt::blue );
	scene.addItem( pcargen );
	//car->setStartPos();


	//  Create QGraphicsView
	QGraphicsView view( &scene );
	view.setViewportUpdateMode( QGraphicsView::BoundingRectViewportUpdate );
	view.setWindowTitle( QT_TRANSLATE_NOOP(QGraphicsVIew, "Traffic simulation") );

	view.show();


	//  Set Timer
	QTimer timer;
	QObject::connect( &timer, SIGNAL(timeout()), &scene, SLOT(advance()) );
	timer.start( 1000/20 );
	
	return app.exec();
}
Exemple #22
0
void MainWindow::drawnewconnect(int xxend, int yyend)
{
    QGraphicsScene *scene = new QGraphicsScene(ui->graphicsView);
    scene->setSceneRect(0,0,725,575);//розмір сцені
    ui->graphicsView->setAlignment(Qt::AlignLeft|Qt::AlignTop );
    connects u;
    parsanddrow d;
    QDebug qd= qDebug();
    qApp->applicationDirPath() +"C:/Users/Igro/build-vns_kma-Desktop_Qt_5_1_1_MinGW_32bit-Debug/24.jpeg";
    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; //назва приладу
    int xbeg;
    int ybeg;
    int xend;
    int yend;
    xend=xxend;
    yend=yyend;
    int dd; //кілкість приладів
    if(d.count(openfil())!=0)
    {
    dd=d.count(openfil());//кілкість рядків на 4 властивості отримаємо кілкість приладів
    d.cord(openfil());//заповнення масивік кординатами та іменами (and mac)

    for(int i=0;i<dd;i++)
    {
        if(d.getmac(i)==u.getbegin())
        {
            xbeg=d.getx(i);
            ybeg=d.gety(i);
        }
    }
    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];
                    for(int i=0; dd>i;i++)
                    {
                        if(d.gatmacconnect1(h)==d.getmac(i))
                        {
                            xpoch[h]=d.getx(i);
                            ypoch[h]=d.gety(i);

                        }
                        else
                        if(d.gatmacconnect2(h)==d.getmac(i))
                        {
                            xend[h]=d.getx(i);
                            yend[h]=d.gety(i);

                        }
                    }
                    scene->addLine(QLineF(xpoch[h]+15, ypoch[h]+15, xend[h]+15, yend[h]+15), QPen(Qt::blue, 2));
                }
    scene->addLine(QLineF(xbeg+15, ybeg+15, xend, yend), QPen(Qt::blue, 2));
    }
    }
    ui->graphicsView->setScene(scene);
    ui->graphicsView->show();
    ui->graphicsView->scene()->installEventFilter(this);
    d.deletemas();
}
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 Graphe::paint(QGraphicsScene &scene,int wi,int he,QStringList *LesChaineADN)
{

    /*QLine ligne(50, 50, 200, 200);
    scene.addLine(ligne);*/

   int nbSequence=LesChaineADN->size();

   int plusLongSequence=LesChaineADN->at(0).size();

   for(int i=1;i<LesChaineADN->size();i++)
   {
       if(LesChaineADN->at(i).size()>plusLongSequence)
           plusLongSequence=LesChaineADN->at(i).size();
   }


   int distanct_w=5; // 5 pixel
   int distanct_h=5;

   if( nbSequence*5 < (he-espaceLibre) )
   {
       // on lesse 20 pixel de haut et 40 de bas
       distanct_h= (he-espaceLibre)/nbSequence;
   }

   if(plusLongSequence*5 < (wi-espaceLibre))
   {
       distanct_w= (wi-espaceLibre)/plusLongSequence;
   }


   /// calculer les score de chaque colone
    QList<int> listScorColon;
    score(listScorColon,LesChaineADN,plusLongSequence);

    QList<int> listPointScorY;

    int scoreMax=( fact(nbSequence)/(2*fact(nbSequence-2)) ) * scoreSimilarite;

    /// le point 0 = he - espaceLibre_B
    /// score max                       --------> he-(espaceLibre+10)
    /// score X (listScorColon.at(i))   --------> y
    /// y= listScorColon.at(i)* (he-(espaceLibre+20)) / score max
    /// 20 la posision de valMax avant la fine de flache
    /// pour inverser les point y on doit faire y=(he-espaceLibre_B)-y;

    qDebug("he : %d",he);
    qDebug("max : %d",he-(he-(espaceLibre+20)));
    qDebug("max : %d",espaceLibre_H+20);

    for(int i=0;i<listScorColon.size();i++)
    {                                                                           // scor max
        listPointScorY.append((he-espaceLibre_B)-((listScorColon.at(i)*(he-(espaceLibre+20))) / scoreMax));

        qDebug("le poit at: %d == %d",i,listPointScorY.at(i));
    }

    /////////// dessiner la line x
    scene.addLine(espaceLibre_L,he-espaceLibre_B,wi-espaceLibre_R,he-espaceLibre_B);
    scene.addLine(wi-espaceLibre_R-5,he-espaceLibre_B-5,wi-espaceLibre_R,he-espaceLibre_B);
    scene.addLine(wi-espaceLibre_R-5,he-espaceLibre_B+5,wi-espaceLibre_R,he-espaceLibre_B);


    /////////// dessiner la line y
    scene.addLine(espaceLibre_L,he-espaceLibre_B,espaceLibre_L,espaceLibre_H);
    scene.addLine(espaceLibre_L-5,espaceLibre_H+5,espaceLibre_L,espaceLibre_H);
    scene.addLine(espaceLibre_L+5,espaceLibre_H+5,espaceLibre_L,espaceLibre_H);


    /////////// score max
    scene.addLine(espaceLibre_L-3,espaceLibre_H+20,espaceLibre_L+3,espaceLibre_H+20,QPen(Qt::blue));

   ////////////// ajouter text
    QGraphicsTextItem *text_H=new QGraphicsTextItem("Taux d'alignement");
    QGraphicsTextItem *text_B=new QGraphicsTextItem("N=° colonne");
    scene.addItem(text_H);
    scene.addItem(text_B);

     text_H->setDefaultTextColor(Qt::red);
     text_B->setDefaultTextColor(Qt::red);

    text_H->setPos(10,0);
    text_B->setPos(wi-(espaceLibre_R*4),he-espaceLibre_B+2);



    int colone=espaceLibre_L;
    int colone2=distanct_w+ colone;

    for(int i=0;i < plusLongSequence-1;i++)
    {
        scene.addLine(colone,listPointScorY.at(i),colone2,listPointScorY.at(i+1),QPen(Qt::red));


        /////////// score x
        scene.addLine(espaceLibre_L-3,listPointScorY.at(i),espaceLibre_L+3,listPointScorY.at(i),QPen(Qt::blue));

        ////////// n=° colone
        scene.addLine(colone2,he-espaceLibre_B-3,colone2,he-espaceLibre_B+3,QPen(Qt::blue));

       colone=colone2;
       colone2+=distanct_w;




    }
}
Exemple #25
0
void shape_cd::draw ( draw_vars& dr, stack&, QGraphicsScene& sc)
{
  shapes* prev = get_prev();
  if(prev && prev->type()== QString("shape_e") && dr.drawAsHorisontal())
  {
    return;
  }
    if ( is_current() ) dr.draw_marker ( sc );

    int nSegments = get_n_segment();

    for ( int i = 0 ; i < nSegments; ++i )
    {
        draw_point p_start = dr.get_p_otn();   //Начальная точка сегмента дуги.
        draw_point delta_p = get_delta_p ( i ) * dr.get_masht() ;
        qreal C = abs ( get_c ( i ) );   //Значение параметра кривизны.
        qreal C_sign = get_c ( i ) / C; //Знак параметра кривизны.
        dr.move_coords ( delta_p );
        draw_point p_end = dr.get_p_otn();    //Конечная точка сегмента дуги.

        if (dr.drawWhisOutPenUpMovement() && !dr.get_pero()) ;
        else if ( get_c ( i ) != 0 )
        {
            qreal D = p_start.dist ( p_end );  //Расстояние между конечными точками сегмента.
            qreal H = C * D / qreal ( 2 ) / qreal ( 127 );   //Высота сегмента.
            qreal R = D * D / ( H * qreal ( 8 ) ) + H / qreal ( 2 ); //Радиус дуги.

            qreal ang = p_start.agnle ( p_end );
            draw_point p_mid_hord = p_start.polar ( ang, D / qreal ( 2 ) );
            draw_point p_center = p_mid_hord.polar ( ang + C_sign * M_PI / qreal ( 2 ), R - H );

            draw_point p_radius ( R, R );
            qreal ang_start = draw_point::rtd ( p_center.agnle ( p_start ) );
            qreal ang_4 = draw_point::rtd ( atan2 ( H, D / qreal ( 2 ) ) );
            qreal ang_number = C_sign * ang_4 * qreal ( 4 );
            if ( is_current() )
            {
                QPen pen( QBrush
                          ( QColor ( draw_vars::s_color_cur ), Qt::SolidPattern ),
                          qreal ( draw_vars::s_width_cur ) ,
                          Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin );
                pen.setCosmetic ( true );
                if ( i == get_current())
                    pen.setColor(QColor ( draw_vars::s_color_9d));
                else
                    pen.setColor(QColor ( draw_vars::s_color_cur));
                {
                    QPainterPath path;
                    path.arcMoveTo ( p_center.x - p_radius.x , p_center.y - p_radius.y , p_radius.x * 2, p_radius.y * 2,  -ang_start );
                    path.arcTo ( p_center.x - p_radius.x , p_center.y - p_radius.y , p_radius.x * 2, p_radius.y * 2,  -ang_start , -ang_number );
                    QGraphicsPathItem *pathItem = new QGraphicsPathItem ( path );
                    pathItem->setPen ( pen );
                    sc.addItem ( pathItem );
                }
            }
            else if ( dr.get_pero() )
            {
                QPen pen ( QBrush
                           ( QColor ( draw_vars::s_color_pen_down ), Qt::SolidPattern ),
                           qreal ( draw_vars::s_width_pen_down ) ,
                           Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin );

                pen.setCosmetic ( true );
                {
                    QPainterPath path;
                    path.arcMoveTo ( p_center.x - p_radius.x , p_center.y - p_radius.y , p_radius.x * 2, p_radius.y * 2,  -ang_start );
                    path.arcTo ( p_center.x - p_radius.x , p_center.y - p_radius.y , p_radius.x * 2, p_radius.y * 2,  -ang_start , -ang_number );
                    QGraphicsPathItem *pathItem = new QGraphicsPathItem ( path );
                    pathItem->setPen ( pen );
                    sc.addItem ( pathItem );
                }
            }
            else
            {
                QPen pen ( QBrush
                           ( QColor ( draw_vars::s_color_pen_up ), Qt::SolidPattern ),
                           qreal ( draw_vars::s_width_pen_up ) ,
                           Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin );

                pen.setCosmetic ( true );
                {
                    QPainterPath path;
                    path.arcMoveTo ( p_center.x - p_radius.x , p_center.y - p_radius.y , p_radius.x * 2, p_radius.y * 2,  -ang_start );
                    path.arcTo ( p_center.x - p_radius.x , p_center.y - p_radius.y , p_radius.x * 2, p_radius.y * 2,  -ang_start , -ang_number );
                    QGraphicsPathItem *pathItem = new QGraphicsPathItem ( path );
                    pathItem->setPen ( pen );
                    sc.addItem ( pathItem );
                }
            }

        }
        else
        {
            if ( dr.get_pero() )
            {
                QPen pen ( QBrush
                           ( QColor ( draw_vars::s_color_pen_down ), Qt::SolidPattern ),
                           qreal ( draw_vars::s_width_pen_down ) ,
                           Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin );
                pen.setCosmetic ( true );

                sc.addLine ( p_start.x, p_start.y, p_end.x, p_end.y, pen );
            }
            else
            {
                QPen pen ( QBrush
                           ( QColor ( draw_vars::s_color_pen_up ), Qt::SolidPattern ),
                           qreal ( draw_vars::s_width_pen_up ) ,
                           Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin );
                pen.setCosmetic ( true );

                sc.addLine ( p_start.x, p_start.y, p_end.x, p_end.y, pen );
            }
        }
    }
}
Exemple #26
0
StatisticWidget::StatisticWidget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::StatisticWidget)
{
    ui->setupUi(this);
    QList<unsigned int> corrects;
    QList<unsigned int> mistakes;
    QList<QDate> dates;
    QList<QString> lessons;
    QMap<QChar, QPair<unsigned int, unsigned int> > stats;
    QMap<unsigned int, QPair<unsigned int, unsigned int> > fingerStats;

    int statsCounter = 0;
    QSettings settings("settings.ini", QSettings::IniFormat);
    if (settings.contains("statsCounter"))
    {
        statsCounter = settings.value("statsCounter").toInt();
    }
    for (int i=0; i<statsCounter; i++)
    {
        QString path = QString("stats")+QDir::separator()+QString::number(i, 10)+QString(".stats");
        QFile in(path);
        if (!in.exists())
        {
            qDebug() << "file" << path << "does not exist";
            continue;
        }
        if (!in.open(QIODevice::ReadOnly))
        {
            qDebug() << "file" << path << "not openable";
            continue;
        }
        unsigned int lineCounter = 0;
        while (true)
        {
            QByteArray bytes = in.readLine();
            if (bytes.size() == 0)
            {
                break;
            }
            QString line(bytes);
            line.remove("\n");
            line.remove("\r");
            QDate date;
            switch (lineCounter)
            {
                case 0:
                    date = QDate::fromString(line);
                    dates.append(date);
                    break;
                case 1:
                    lessons.append(line);
                    break;
                case 2:
                    corrects.append(line.toInt());
                    break;
                case 3:
                    mistakes.append(line.toInt());
                    break;
                default:
                    QStringList sl = line.split(" ");
                    unsigned int successes = sl.at(0).toInt();
                    unsigned int mistakes = sl.at(1).toInt();
                    QString key;
                    for (int i=2; i<sl.size(); i++)
                    {
                        key += QChar(sl.at(i).toInt());
                    }
                    if (key.length() == 1)
                    {
                        if (stats.contains(key.at(0)))
                        {
                            successes += stats.value(key.at(0)).first;
                            mistakes += stats.value(key.at(0)).second;
                        }
                        stats.insert(key.at(0), qMakePair(successes, mistakes));
                    }
                    break;
            }
            lineCounter++;
        }
        in.close();
    }

    QSettings s("settings.ini", QSettings::IniFormat);
    QList<QChar> keys = stats.keys();
    for (int i=0; i<keys.size(); i++)
    {
        int finger = mapCharToFinger(keys.at(i).toLatin1());
        if (finger != -1)
        {
            unsigned int success = stats.value(keys.at(i)).first;
            unsigned int mistakes = stats.value(keys.at(i)).second;
            success += fingerStats.value(finger).first;
            mistakes += fingerStats.value(finger).second;
            fingerStats.insert(finger, qMakePair(success, mistakes));
        }
        else
        {
            qDebug() << "unknown key" << keys.at(i);
        }
    }

    float minA = 10000;
    float maxA = 0;
    for (int i=0; i<corrects.size(); i++)
    {
        float a = (float)(corrects.at(i)+mistakes.at(i))/5;
        if (a < minA)
        {
            minA = a;
        }
        if (a > maxA)
        {
            maxA = a;
        }
    }
    int goodLineA = s.value("goodLineA").toInt();
    int badLineA = s.value("badLineA").toInt();
    QList<float> points;
    for (int i=0; i<corrects.size(); i++)
    {
        float a = (float)(corrects.at(i)+mistakes.at(i))/5;
        points.append(((a-minA)/(maxA-minA))*200);
    }
    QGraphicsScene* scene = new QGraphicsScene(0,0,5*(corrects.size()-1),200);
    if (maxA > goodLineA)
    {
        QGraphicsRectItem* rect = new QGraphicsRectItem(0, 200-200, (points.size()-1)*5, 200);
        rect->setBrush(QBrush(QColor("green")));
        scene->addItem(rect);
    }
    if (maxA > badLineA && minA < goodLineA)
    {
        QGraphicsRectItem* rect = new QGraphicsRectItem(0, 200-((goodLineA-minA)/(maxA-minA))*200, (points.size()-1)*5, 200);
        rect->setBrush(QBrush(QColor("orange")));
        scene->addItem(rect);
    }
    if (minA < badLineA)
    {
        QGraphicsRectItem* rect = new QGraphicsRectItem(0, 200-((badLineA-minA)/(maxA-minA))*200, (points.size()-1)*5, 200);
        rect->setBrush(QBrush(QColor("red")));
        scene->addItem(rect);
    }
    for (int i=0; i<points.size()-1; i++)
    {
        scene->addLine(i*5, 200-points.at(i), (i+1)*5, 200-points.at(i+1));
    }
    this->ui->plot->setScene(scene);

    float goodLineE = s.value("goodLineE").toFloat();
    float badLineE = s.value("badLineE").toFloat();
    points.clear();
    QGraphicsScene* scene2 = new QGraphicsScene(0,0,5*(corrects.size()-1),200);
    minA = 100;
    maxA = 0;
    for (int i=0; i<corrects.size(); i++)
    {
        float a = (float)mistakes.at(i)*100/(corrects.at(i)+mistakes.at(i));
        if (a < minA)
        {
            minA = a;
        }
        if (a > maxA)
        {
            maxA = a;
        }
    }
    for (int i=0; i<corrects.size(); i++)
    {
        float a = (float)mistakes.at(i)*100/(corrects.at(i)+mistakes.at(i));
        points.append(((a-minA)/(maxA-minA))*200);
    }
    if (maxA > badLineE)
    {
        QGraphicsRectItem* rect = new QGraphicsRectItem(0, 200-200, (points.size()-1)*5, 200);
        rect->setBrush(QBrush(QColor("red")));
        scene2->addItem(rect);
    }
    if (maxA > goodLineE && minA < badLineE)
    {
        QGraphicsRectItem* rect = new QGraphicsRectItem(0, 200-((badLineE-minA)/(maxA-minA))*200, (points.size()-1)*5, 200);
        rect->setBrush(QBrush(QColor("orange")));
        scene2->addItem(rect);
    }
    if (minA < goodLineE)
    {
        QGraphicsRectItem* rect = new QGraphicsRectItem(0, 200-((goodLineE-minA)/(maxA-minA))*200, (points.size()-1)*5, 200);
        rect->setBrush(QBrush(QColor("green")));
        scene2->addItem(rect);
    }
    for (int i=0; i<points.size()-1; i++)
    {
        scene2->addLine(i*5, 200-points.at(i), (i+1)*5, 200-points.at(i+1));
    }
    this->ui->plot2->setScene(scene2);

    for (int i=0; i<9; i++)
    {
        if (fingerStats.contains(i))
        {
            float f = (float)fingerStats.value(i).second*100 / (fingerStats.value(i).second+fingerStats.value(i).first);
            char tmp[16];
            sprintf(tmp, "%.1f %%", f);
            QString str = QString(tmp);
            switch (i)
            {
                case 0:
                    this->ui->finger0->setText(str);
                    break;
                case 1:
                    this->ui->finger1->setText(str);
                    break;
                case 2:
                    this->ui->finger2->setText(str);
                    break;
                case 3:
                    this->ui->finger3->setText(str);
                    break;
                case 4:
                    this->ui->finger4->setText(str);
                    break;
                case 5:
                    this->ui->finger5->setText(str);
                    break;
                case 6:
                    this->ui->finger6->setText(str);
                    break;
                case 7:
                    this->ui->finger7->setText(str);
                    break;
                case 8:
                    this->ui->finger8->setText(str);
                    break;
            }
        }
        else
        {

            switch (i)
            {
                case 0:
                    this->ui->finger0->setText("0.0 %");
                    break;
                case 1:
                    this->ui->finger1->setText("0.0 %");
                    break;
                case 2:
                    this->ui->finger2->setText("0.0 %");
                    break;
                case 3:
                    this->ui->finger3->setText("0.0 %");
                    break;
                case 4:
                    this->ui->finger4->setText("0.0 %");
                    break;
                case 5:
                    this->ui->finger5->setText("0.0 %");
                    break;
                case 6:
                    this->ui->finger6->setText("0.0 %");
                    break;
                case 7:
                    this->ui->finger7->setText("0.0 %");
                    break;
                case 8:
                    this->ui->finger8->setText("0.0 %");
                    break;
            }
        }
    }
    connect((QObject*)this->ui->plot->horizontalScrollBar(), SIGNAL(valueChanged(int)), (QObject*)this->ui->plot2->horizontalScrollBar(), SLOT(setValue(int)));
    connect((QObject*)this->ui->plot2->horizontalScrollBar(), SIGNAL(valueChanged(int)), (QObject*)this->ui->plot->horizontalScrollBar(), SLOT(setValue(int)));
}
Exemple #27
0
void GraphicsWorker::run()
{
    qDebug() << "Starting graphics worker...";



    //Create scene with new keyword from heap so it does not disappear from the stack
    QGraphicsScene *scene = new QGraphicsScene();


    //If scene ref exists, delete old, else set a scene ref.
    if(!this->sceneRef)
    {
        this->sceneRef = scene;
    }
    else
    {
        delete this->sceneRef;
        this->sceneRef = scene;
    }


    QPainterPath *path = new QPainterPath(QPointF(0, 0));
    QPainter *painter = new QPainter();

    QPen pen = QPen(Qt::DashLine);


    //Draw axis
    scene->addLine(-100, 0, 100, 0, pen);
    scene->addLine(0, -100, 0, 100, pen);

    //


    //Access wavFile data
    if(wavFile.hexFormatChunkIdText != "fmt ")
    {
        //qDebug() << "error";
        //qDebug() << wavFile.hexFormatChunkIdText;
        exit(-1);
    }

    if (wavFile.formatAudioFormat != 1)
    {
        //qDebug() << "error, unsupported audio format.";
        exit(-1);
    }

    //continue
    //qDebug() << "good";
    int i;


    for(i=0;i<wavFile.hexDataChunk.size();i+= wavFile.formatBlockAlign*2)
    {
        // read signal


        if(wavFile.formatNumChannels == 1 && wavFile.formatBitsPerSample == 8)
        {
            bool ok;
            QByteArray sample = wavFile.hexDataChunk.mid(i, 2);
            int sampleValue = sample.toInt(&ok, 16);

            path->lineTo(i, sampleValue);
        }
        else if(wavFile.formatNumChannels == 1 && wavFile.formatBitsPerSample == 16)
        {
            QByteArray sample = wavFile.hexDataChunk.mid(i, 4);
            bool ok;
            int sampleValue = sample.toInt(&ok, 16);

            //2's complement
            if(sampleValue > 32767)
            {
                sampleValue = (sampleValue - 65535);
            }

            path->lineTo(i, sampleValue);

        }
        else if(wavFile.formatNumChannels == 2 && wavFile.formatBitsPerSample == 8)
        {
            QByteArray leftSample = wavFile.hexDataChunk.mid(i, 2);
            QByteArray rightSample = wavFile.hexDataChunk.mid(i+2, 2);
        }
        else if(wavFile.formatNumChannels == 2 && wavFile.formatBitsPerSample == 16)
        {
            QByteArray leftSample = wavFile.hexDataChunk.mid(i, 4);
            QByteArray rightSample = wavFile.hexDataChunk.mid(i+4, 4);
        }
    }

    painter->fillPath(*path, Qt::blue);

    scene->addPath(*path);



    //Change scene owner to mainThread
    scene->moveToThread(QApplication::instance()->thread());


    emit sceneReady(scene);

    delete path;
    delete painter;
}
Exemple #28
0
void Street::draw(QGraphicsScene& scene)
{
    // Draw line from A to B
    scene.addLine(A->getX() + CITYSIZE/2, A->getY() + CITYSIZE/2, B->getX() + CITYSIZE/2, B->getY() + CITYSIZE/2);
}