Example #1
0
void Ui::openDiffDialog()
{
    diffDialog = new QDialog(this); // set as child of Ui, to be sure that it will be deleted in the end.
    QVBoxLayout *diffDialogLayout = new QVBoxLayout; // create vertical layout

    QVTKWidget *dialogVisualizer = new QVTKWidget; // create qvtk widget
    dialogViewer = new pcl::visualization::PCLVisualizer("Dialog Viewer", false);
    dialogVisualizer->SetRenderWindow(dialogViewer->getRenderWindow()); // set as render window the render window of the dialog visualizer
    dialogViewer->setupInteractor(dialogVisualizer->GetInteractor(), dialogVisualizer->GetRenderWindow()); // tells the visualizer what interactor is using now and for what window
    dialogViewer->getInteractorStyle()->setKeyboardModifier(pcl::visualization::INTERACTOR_KB_MOD_SHIFT); // ripristina input system of original visualizer (shift+click for points)
    pcl::PointCloud<pcl::PointXYZRGB>::Ptr regCloud = motor->getRegisteredCloud();
    pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB> rgb(regCloud);
    pcl::PointCloud<pcl::PointXYZRGB>::Ptr diffCloud = motor->getSourceDiffCloud();
    pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZRGB> green(diffCloud, 0, 255, 0);
    pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZRGB> red(diffCloud, 255, 0, 0);
    int v1(0); int v2(0);
    dialogViewer->createViewPort(0.0, 0.0, 0.5, 1.0, v1);
    dialogViewer->setBackgroundColor(0.5, 0.5, 0.5, v1);
    dialogViewer->addText("TARGET CLOUD", 30, 20,"TARGET CLOUD",v1);
    dialogViewer->createViewPort(0.5, 0.0, 1.0, 1.0, v2);
    dialogViewer->setBackgroundColor(0.5, 0.5, 0.5, v2);
    dialogViewer->addText("SOURCE CLOUD", 30, 20,"SOURCE CLOUD",v2);
    dialogViewer->addPointCloud<pcl::PointXYZRGB>(motor->getTargetCloud(), rgb, "targetCloud", v1);
    dialogViewer->addPointCloud<pcl::PointXYZRGB>(diffCloud, red, "targetDiffCloud", v1);
    dialogViewer->addPointCloud<pcl::PointXYZRGB>(regCloud, rgb, "sourceCloud", v2);
    dialogViewer->addPointCloud<pcl::PointXYZRGB>(diffCloud, green, "sourceDiffCloud", v2);
    dialogViewer->initCameraParameters();
    dialogViewer->resetCamera();
    componentCallbackConnection = dialogViewer->registerPointPickingCallback(&pointPickCallback, this); // callback standard non segmenta nulla

    QHBoxLayout *dialogControlsLayout = new QHBoxLayout;

    QVBoxLayout *numbersBox = new QVBoxLayout;
    QLineEdit *segDiffBox = new QLineEdit("0.5");
    segDiffBox->setReadOnly(true);
    segDiffBox->setObjectName("segdiffbox");
    segDiffBox->setMaxLength(5);
    segDiffBox->setMaximumWidth(50);
    numbersBox->addWidget(segDiffBox);

    QVBoxLayout *slidersBox = new QVBoxLayout;
    QSlider *setSegDiffThresholdBar = new QSlider(Qt::Horizontal);
    setSegDiffThresholdBar->setRange(0, 5000);
    setSegDiffThresholdBar->setValue(500);
    motor->setSegDiffThreshold(500);
    setSegDiffThresholdBar->setObjectName("sliderSegDiff");
    connect(setSegDiffThresholdBar, SIGNAL(sliderReleased()), this, SLOT(setSegDiffThreshold()));
    slidersBox->addWidget(setSegDiffThresholdBar);

    dialogControlsLayout->addLayout(numbersBox);
    dialogControlsLayout->addLayout(slidersBox);

    QPushButton *segmentDiffButton = new QPushButton("Segment differences");
    segmentDiffButton->setDefault(true); // default button, pressed if enter is pressed
    connect(segmentDiffButton, SIGNAL(clicked()), this, SLOT(segmentDiff()));

    diffDialogLayout->addWidget(dialogVisualizer);
    diffDialogLayout->addLayout(dialogControlsLayout);
    diffDialogLayout->addWidget(segmentDiffButton);
    diffDialog->setLayout(diffDialogLayout);

    diffDialogLayout->deleteLater(); // delete dialog layout when the control returns to the event loop from which deleteLater() was called (after exec i guess)
    diffDialog->resize(800,600);
    diffDialog->exec();
    componentCallbackConnection.disconnect(); // disconnect the callback function from the viewer
    delete dialogViewer; // finita l'esecuzione, deallocare il viewer (deallocare altra eventuale memoria non indirizzata nel QObject tree).
}
Example #2
0
void Ui::openComponentDialog()
{
    addComponentDialog = new QDialog(this); // set as child of Ui, to be sure that it will be deleted in the end.
    QVBoxLayout *dialogLayout = new QVBoxLayout; // create vertical layout

    QVTKWidget *dialogVisualizer = new QVTKWidget; // create qvtk widget
    dialogViewer = new pcl::visualization::PCLVisualizer("Dialog Viewer", false);
    dialogVisualizer->SetRenderWindow(dialogViewer->getRenderWindow()); // set as render window the render window of the dialog visualizer
    dialogViewer->setupInteractor(dialogVisualizer->GetInteractor(), dialogVisualizer->GetRenderWindow()); // tells the visualizer what interactor is using now and for what window
    dialogViewer->getInteractorStyle()->setKeyboardModifier(pcl::visualization::INTERACTOR_KB_MOD_SHIFT); // ripristina input system of original visualizer (shift+click for points)
    pcl::PointCloud<pcl::PointXYZRGB>::Ptr temp = motor->getTargetCloud();
    pcl::visualization::PointCloudColorHandlerRGBField<pcl::PointXYZRGB> rgb(temp);
    dialogViewer->addPointCloud<pcl::PointXYZRGB>(temp, rgb, "cloud");
    dialogViewer->setBackgroundColor(0.5, 0.5, 0.5);
    dialogViewer->initCameraParameters();
    dialogViewer->resetCamera();
    componentCallbackConnection = dialogViewer->registerPointPickingCallback(&pointPickCallback, this); // callback standard non segmenta nulla

    QLineEdit *addComponentDialogName  = new QLineEdit("Insert Component Name");
    addComponentDialogName->setObjectName("componentname");

    QHBoxLayout *dialogControlsLayout = new QHBoxLayout;

    QVBoxLayout *buttonsBox = new QVBoxLayout;
    QPushButton *selectPointButton = new QPushButton("Select Component");
    connect(selectPointButton, SIGNAL(clicked()), this, SLOT(setComponentDialogCallback()));
    QPushButton *resetButton = new QPushButton("Reset Selection");
    connect(resetButton, SIGNAL(clicked()), this, SLOT(resetComponentDialogCallback()));
    buttonsBox->addWidget(selectPointButton);
    buttonsBox->addWidget(resetButton);

    QVBoxLayout *numbersBox = new QVBoxLayout;
    QColor *selectedColor = new QColor(0, 0, 0, 255); // initialize color at black
    QPushButton *colorBox = new QPushButton("+-100");
    colorBox->setObjectName("colorbox");
    colorBox->setStyleSheet(colorToStyleSheet(selectedColor));
    colorBox->setMaximumWidth(50);
    QLineEdit *clusterBox = new QLineEdit("1");
    clusterBox->setReadOnly(true);
    clusterBox->setObjectName("clusterbox");
    clusterBox->setMaxLength(5);
    clusterBox->setMaximumWidth(50);
    numbersBox->addWidget(clusterBox);
    numbersBox->addWidget(colorBox);

    QVBoxLayout *slidersBox = new QVBoxLayout;
    QSlider *setCluThresholdBar = new QSlider(Qt::Horizontal);
    setCluThresholdBar->setRange(0,5000);
    setCluThresholdBar->setValue(1000);
    motor->setClusterSegThreshold(1000);
    setCluThresholdBar->setObjectName("sliderCluster");
    connect(setCluThresholdBar, SIGNAL(sliderReleased()), this, SLOT(setClusterThreshold()));
    QSlider *setColThresholdBar = new QSlider(Qt::Horizontal);
    setColThresholdBar->setRange(0,255);
    setColThresholdBar->setValue(100);
    motor->setColorSegThreshold(100);
    setColThresholdBar->setObjectName("sliderColor");
    connect(setColThresholdBar, SIGNAL(sliderReleased()), this, SLOT(setColorThreshold()));
    slidersBox->addWidget(setCluThresholdBar);
    slidersBox->addWidget(setColThresholdBar);

    QPushButton *showSegButton = new QPushButton("Segment!");
    connect(showSegButton, SIGNAL(clicked()), this, SLOT(segmentComponent()));

    dialogControlsLayout->addLayout(buttonsBox);
    dialogControlsLayout->addLayout(numbersBox);
    dialogControlsLayout->addLayout(slidersBox);
    dialogControlsLayout->addWidget(showSegButton);

    QPushButton *saveComponent = new QPushButton("Save to component list");
    saveComponent->setDefault(true); // default button, pressed if enter is pressed
    connect(saveComponent, SIGNAL(clicked()), this, SLOT(saveComponent()));

    dialogLayout->addWidget(dialogVisualizer);
    dialogLayout->addWidget(addComponentDialogName);
    dialogLayout->addLayout(dialogControlsLayout);
    dialogLayout->addWidget(saveComponent);
    addComponentDialog->setLayout(dialogLayout);

    // DIALOG EXECUTION
//    addComponentDialog->deleteLater(); // delete dialog when the control returns to the event loop from which deleteLater() was called (after exec i guess)
//    causa seg fault se viene attivata la callback

    dialogLayout->deleteLater(); // delete dialog layout when the control returns to the event loop from which deleteLater() was called (after exec i guess)
    addComponentDialog->resize(800,600);
    addComponentDialog->exec();
    componentCallbackConnection.disconnect(); // disconnect the callback function from the viewer
    delete dialogViewer; // finita l'esecuzione, deallocare il viewer (deallocare altra eventuale memoria non indirizzata nel QObject tree).
}
Example #3
0
void Ui::openCheckDialog()
{
    addCheckDialog = new QDialog(this); // set as child of Ui, to be sure that it will be deleted in the end.
    QVBoxLayout *dialogLayout = new QVBoxLayout;
    QTabWidget *tabWidget = new QTabWidget();

    QWidget *presence = new QWidget();
    QVBoxLayout *presenceLayout = new QVBoxLayout();
    QLineEdit *presenceName = new QLineEdit(QString("Insert check name"));
    QComboBox *presenceComp = new QComboBox();
    QLineEdit *presenceThreshold = new QLineEdit(QString("Insert error threshold (number of points difference)"));
    QPushButton *presenceAdd = new QPushButton(QString("Add Check"));
    //connect
    presenceLayout->addWidget(presenceName);
    presenceLayout->addWidget(presenceComp);
    presenceLayout->addWidget(presenceThreshold);
    presenceLayout->addWidget(presenceAdd);
    presence->setLayout(presenceLayout);

    QWidget *planarity = new QWidget();
    QVBoxLayout *planarityLayout = new QVBoxLayout();
    QLineEdit *planarityName = new QLineEdit(QString("Insert check name"));
    QComboBox *planarityComp = new QComboBox();
    QLineEdit *planarityThreshold = new QLineEdit(QString("Insert error threshold (angular inclination)"));
    QPushButton *planarityAdd = new QPushButton(QString("Add Check"));
    //connect
    planarityLayout->addWidget(planarityName);
    planarityLayout->addWidget(planarityComp);
    planarityLayout->addWidget(planarityThreshold);
    planarityLayout->addWidget(planarityAdd);
    planarity->setLayout(planarityLayout);

    QWidget *pose = new QWidget();
    QVBoxLayout *poseLayout = new QVBoxLayout();
    QLineEdit *poseName = new QLineEdit(QString("Insert check name"));
    QComboBox *poseComp = new QComboBox();
    QLineEdit *poseThreshold = new QLineEdit(QString("Insert error threshold (angular inclination)"));
    QPushButton *poseAdd = new QPushButton(QString("Add Check"));
    //connect
    poseLayout->addWidget(poseName);
    poseLayout->addWidget(poseComp);
    poseLayout->addWidget(poseThreshold);
    poseLayout->addWidget(poseAdd);
    pose->setLayout(poseLayout);

    QWidget *color = new QWidget();
    QVBoxLayout *colorLayout = new QVBoxLayout();
    QLineEdit *colorName = new QLineEdit(QString("Insert check name"));
    QComboBox *colorComp = new QComboBox();
    QLineEdit *colorThreshold = new QLineEdit(QString("Insert error threshold (color difference in r g b values)"));
    QPushButton *colorAdd = new QPushButton(QString("Add Check"));
    //connect
    colorLayout->addWidget(colorName);
    colorLayout->addWidget(colorComp);
    colorLayout->addWidget(colorThreshold);
    colorLayout->addWidget(colorAdd);
    color->setLayout(colorLayout);

    QWidget *distance = new QWidget();
    QVBoxLayout *distanceLayout = new QVBoxLayout();
    QLineEdit *distanceName = new QLineEdit(QString("Insert check name"));
    QComboBox *distanceComp = new QComboBox();
    QComboBox *distanceComp2 = new QComboBox();
    QLineEdit *distanceThreshold = new QLineEdit(QString("Insert error threshold (distance difference)"));
    QPushButton *distanceAdd = new QPushButton(QString("Add Check"));
    //connect
    distanceLayout->addWidget(distanceName);
    distanceLayout->addWidget(distanceComp);
    distanceLayout->addWidget(distanceComp2);
    distanceLayout->addWidget(distanceThreshold);
    distanceLayout->addWidget(distanceAdd);
    distance->setLayout(distanceLayout);

    QWidget *height = new QWidget();
    QVBoxLayout *heightLayout = new QVBoxLayout();
    QLineEdit *heightName = new QLineEdit(QString("Insert check name"));
    QComboBox *heightComp = new QComboBox();
    QLineEdit *heightThreshold = new QLineEdit(QString("Insert error threshold (height difference)"));
    QPushButton *heightAdd = new QPushButton(QString("Add Check"));
    //connect
    heightLayout->addWidget(heightName);
    heightLayout->addWidget(heightComp);
    heightLayout->addWidget(heightThreshold);
    heightLayout->addWidget(heightAdd);
    height->setLayout(heightLayout);

    QWidget *circleRadius = new QWidget();
    QVBoxLayout *circleLayout = new QVBoxLayout();
    QLineEdit *circleRadiusName = new QLineEdit(QString("Insert check name"));
    QComboBox *circleRadiusComp = new QComboBox();
    QLineEdit *circleRadiusThreshold = new QLineEdit(QString("Insert error threshold (circle radius difference)"));
    QPushButton *circleRadiusAdd = new QPushButton(QString("Add Check"));
    //connect
    circleLayout->addWidget(circleRadiusName);
    circleLayout->addWidget(circleRadiusComp);
    circleLayout->addWidget(circleRadiusThreshold);
    circleLayout->addWidget(circleRadiusAdd);
    circleRadius->setLayout(circleLayout);

    QWidget *cable = new QWidget();
    QVBoxLayout *cableLayout = new QVBoxLayout();
    QLineEdit *cableName = new QLineEdit(QString("Insert check name"));
    QComboBox *cableComp = new QComboBox();
    QLineEdit *cableLengthThreshold = new QLineEdit(QString("Insert error threshold (cable length difference)"));
    //definire punti di routing e connessione, forse servirebbe un visualizzatore in questo caso
    QPushButton *cableAdd = new QPushButton(QString("Add Check"));
    //connect
    cableLayout->addWidget(cableName);
    cableLayout->addWidget(cableComp);
    cableLayout->addWidget(cableLengthThreshold);
    cableLayout->addWidget(cableAdd);
    cable->setLayout(cableLayout);

    tabWidget->addTab(presence, QString("Presence"));
    tabWidget->addTab(planarity, QString("Planarity"));
    tabWidget->addTab(pose, QString("Pose"));
    tabWidget->addTab(color, QString("Color"));
    tabWidget->addTab(distance, QString("Distance"));
    tabWidget->addTab(height, QString("Height"));
    tabWidget->addTab(circleRadius, QString("Circle Radius"));
    tabWidget->addTab(cable, QString("Cable"));

    dialogLayout->addWidget(tabWidget);
    addCheckDialog->setLayout(dialogLayout);
    addCheckDialog->deleteLater(); // delete dialog when the control returns to the event loop from which deleteLater() was called (after exec i guess)
    dialogLayout->deleteLater(); // delete dialog layout when the control returns to the event loop from which deleteLater() was called (after exec i guess)
    addCheckDialog->resize(640, 240);
    addCheckDialog->exec();
}