Example #1
2
int main(int argc, char **argv)
{
    QApplication app(argc, argv);
    Q3DSurface *graph = new Q3DSurface();
    QWidget *container = QWidget::createWindowContainer(graph);

    QSize screenSize = graph->screen()->size();
    container->setMinimumSize(QSize(screenSize.width() / 2, screenSize.height() / 1.6));
    container->setMaximumSize(screenSize);
    container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    container->setFocusPolicy(Qt::StrongFocus);

    QWidget *widget = new QWidget;
    QHBoxLayout *hLayout = new QHBoxLayout(widget);
    QVBoxLayout *vLayout = new QVBoxLayout();
    hLayout->addWidget(container, 1);
    hLayout->addLayout(vLayout);
    vLayout->setAlignment(Qt::AlignTop);

    widget->setWindowTitle(QStringLiteral("Interpolation"));

    QGroupBox *modelGroupBox = new QGroupBox(QStringLiteral("Mode"));

    QRadioButton *InitPlotModelRB = new QRadioButton(widget);
    InitPlotModelRB->setText(QStringLiteral("Initial plot"));
    InitPlotModelRB->setChecked(false);

    QRadioButton *InterpModelRB = new QRadioButton(widget);
    InterpModelRB->setText(QStringLiteral("Interpolating plot"));
    InterpModelRB->setChecked(false);

    QRadioButton *InitInterpModelRB = new QRadioButton(widget);
    InitInterpModelRB->setText(QStringLiteral("Initial and Interpolating plots"));
    InitInterpModelRB->setChecked(false);

    QRadioButton *ResidModelRB = new QRadioButton(widget);
    ResidModelRB->setText(QStringLiteral("Residual norm plot"));
    ResidModelRB->setChecked(false);

    QVBoxLayout *modelVBox = new QVBoxLayout;
    modelVBox->addWidget(InitPlotModelRB);
    modelVBox->addWidget(InterpModelRB);
    modelVBox->addWidget(InitInterpModelRB);
    modelVBox->addWidget(ResidModelRB);
    modelGroupBox->setLayout(modelVBox);

    QSlider *axisMinSliderX = new QSlider(Qt::Horizontal, widget);
    axisMinSliderX->setMinimum(0);
    axisMinSliderX->setTickInterval(1);
    axisMinSliderX->setEnabled(true);
    QSlider *axisMaxSliderX = new QSlider(Qt::Horizontal, widget);
    axisMaxSliderX->setMinimum(1);
    axisMaxSliderX->setTickInterval(1);
    axisMaxSliderX->setEnabled(true);
    QSlider *axisMinSliderZ = new QSlider(Qt::Horizontal, widget);
    axisMinSliderZ->setMinimum(0);
    axisMinSliderZ->setTickInterval(1);
    axisMinSliderZ->setEnabled(true);
    QSlider *axisMaxSliderZ = new QSlider(Qt::Horizontal, widget);
    axisMaxSliderZ->setMinimum(1);
    axisMaxSliderZ->setTickInterval(1);
    axisMaxSliderZ->setEnabled(true);

    QLabel *countN = new QLabel(widget);
    QLabel *countM = new QLabel(widget);

    vLayout->addWidget(modelGroupBox);
    vLayout->addWidget(new QLabel(QStringLiteral("Column range")));
    vLayout->addWidget(axisMinSliderX);
    vLayout->addWidget(axisMaxSliderX);
    vLayout->addWidget(new QLabel(QStringLiteral("Row range")));
    vLayout->addWidget(axisMinSliderZ);
    vLayout->addWidget(axisMaxSliderZ);
    vLayout->addWidget(new QLabel(QStringLiteral("Points at X axis")));
    vLayout->addWidget(countN);
    vLayout->addWidget(new QLabel(QStringLiteral("Points at Z axis")));
    vLayout->addWidget(countM);
    vLayout->addWidget(new QLabel(QStringLiteral("Press 1 to change the plot\n"
                                                 "Press 2 to increase number of points at X axis\n"
                                                 "Press 3 to decrease number of points at X axis\n"
                                                 "Press 4 to increase number of points at Z axis\n"
                                                 "Press 5 to decrease number of points at Z axis")));

    widget->show();

    SurfaceGraph *modifier = new SurfaceGraph(graph);

    modifier->key1 = new QShortcut(widget);
    modifier->key1->setKey(Qt::Key_1);
    QObject::connect(modifier->key1, SIGNAL(activated()), modifier, SLOT(slotShortcut1()));

    modifier->key2 = new QShortcut(widget);
    modifier->key2->setKey(Qt::Key_2);
    QObject::connect(modifier->key2, SIGNAL(activated()), modifier, SLOT(slotShortcut2()));

    modifier->key3 = new QShortcut(widget);
    modifier->key3->setKey(Qt::Key_3);
    QObject::connect(modifier->key3, SIGNAL(activated()), modifier, SLOT(slotShortcut3()));

    modifier->key4 = new QShortcut(widget);
    modifier->key4->setKey(Qt::Key_4);
    QObject::connect(modifier->key4, SIGNAL(activated()), modifier, SLOT(slotShortcut4()));

    modifier->key5 = new QShortcut(widget);
    modifier->key5->setKey(Qt::Key_5);
    QObject::connect(modifier->key5, SIGNAL(activated()), modifier, SLOT(slotShortcut5()));

    QObject::connect(InitPlotModelRB, &QRadioButton::toggled,
                     modifier, &SurfaceGraph::enableInitPlotModel);
    QObject::connect(InterpModelRB, &QRadioButton::toggled,
                     modifier, &SurfaceGraph::enableInterpModel);
    QObject::connect(InitInterpModelRB, &QRadioButton::toggled,
                     modifier, &SurfaceGraph::enableInitInterpModel);
    QObject::connect(ResidModelRB, &QRadioButton::toggled,
                     modifier, &SurfaceGraph::enableResidModel);
    QObject::connect(axisMinSliderX, &QSlider::valueChanged,
                     modifier, &SurfaceGraph::adjustXMin);
    QObject::connect(axisMaxSliderX, &QSlider::valueChanged,
                     modifier, &SurfaceGraph::adjustXMax);
    QObject::connect(axisMinSliderZ, &QSlider::valueChanged,
                     modifier, &SurfaceGraph::adjustZMin);
    QObject::connect(axisMaxSliderZ, &QSlider::valueChanged,
                     modifier, &SurfaceGraph::adjustZMax);

    modifier->setAxisMinSliderX(axisMinSliderX);
    modifier->setAxisMaxSliderX(axisMaxSliderX);
    modifier->setAxisMinSliderZ(axisMinSliderZ);
    modifier->setAxisMaxSliderZ(axisMaxSliderZ);

    InitPlotModelRB->setChecked(true);
    modifier->setCount(countN, countM);
    modifier->setMode(InitPlotModelRB, InterpModelRB, InitInterpModelRB, ResidModelRB);

    return app.exec();
}
Example #2
0
void MainWindow::on_actionShortcuts_triggered() {

	QTableWidget* scTable = new QTableWidget();

	scTable->setRowCount(0);
	scTable->setColumnCount(2);

	scTable->setHorizontalHeaderItem(0, new QTableWidgetItem("Shortcut"));
	scTable->setHorizontalHeaderItem(1, new QTableWidgetItem("Description"));
	scTable->verticalHeader()->hide();


	QLinkedList<QPair<QString, QString>> scList;

	//read from file in resources and add to linked list
	QFile shortcutFile(":Shortcuts/resources/shortcuts.txt");

	if (!shortcutFile.open(QIODevice::ReadOnly | QIODevice::Text))
		return;

	QString line;
	while (!shortcutFile.atEnd()) {
		QTextStream stream(&shortcutFile);
		while (!stream.atEnd()) {
			line = stream.readLine();
			QStringList shortCutAndDescription = line.split(':');
			if (shortCutAndDescription.size() == 2) {
				scList.append(QPair<QString, QString>(shortCutAndDescription[0], shortCutAndDescription[1]));
			}
		}

	}

	QLinkedList<QPair<QString, QString>>::const_iterator sc;
	for (sc = scList.constBegin(); sc != scList.constEnd(); ++sc) {
		scTable->insertRow(scTable->rowCount());


		QTableWidgetItem* scKey = new QTableWidgetItem(sc->first);
		QTableWidgetItem* scKeyInfo = new QTableWidgetItem(sc->second);
		scKey->setFlags(Qt::NoItemFlags | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
		scKeyInfo->setFlags(Qt::NoItemFlags | Qt::ItemIsEnabled | Qt::ItemIsSelectable);

		scTable->setItem(scTable->rowCount() - 1, 0, scKey);
		scTable->setItem(scTable->rowCount() - 1, 1, scKeyInfo);
	}


	//scTable->horizontalHeader()->setStretchLastSection( true ); 
	scTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);

	QWidget* outerWidget = new QWidget();
	outerWidget->setWindowTitle("Shortcuts");
	outerWidget->resize(scTable->size());
	QVBoxLayout* vLayout = new QVBoxLayout();

	vLayout->addWidget(scTable);

	outerWidget->setLayout(vLayout);


	outerWidget->show();
}
Example #3
0
int main (int argc, char** argv) {
  // Handle input
  int vz_applyTransform, vz_pointStep;
  int pwn_chunkStep;
  float vz_pointSize, vz_alpha;
  float pwn_scaleFactor, pwn_scale;

  string pwn_configFilename, pwn_logFilename, pwn_sensorType;
  string oc_benchmarkFilename, oc_trajectoryFilename, oc_groundTruthFilename, oc_associationsFilename;

  string directory;

  g2o::CommandArgs arg;
  arg.param("vz_pointSize", vz_pointSize, 1.0f, "Size value of the points to visualize");
  arg.param("vz_transform", vz_applyTransform, 1, "Apply absolute transform to the point clouds");
  arg.param("vz_alpha", vz_alpha, 1.0f, "Alpha channel value of the points to visualize");
  arg.param("vz_pointStep", vz_pointStep, 1, "Step value at which points are drawn");
  
  arg.param("pwn_chunkStep", pwn_chunkStep, 30, "Number of cloud composing a registered scene");
  arg.param("pwn_scaleFactor", pwn_scaleFactor, 0.001f, "Scale factor at which the depth images were saved");
  arg.param("pwn_scale", pwn_scale, 4.0f, "Scale factor the depth images are loaded");
  arg.param("pwn_configFilename", pwn_configFilename, "pwn.conf", "Specify the name of the file that contains the parameter configurations of the pwn structures");
  arg.param("pwn_logFilename", pwn_logFilename, "pwn.log", "Specify the name of the file that will contain the trajectory computed in boss format");
  arg.param("pwn_sensorType", pwn_sensorType, "kinect", "Sensor type: xtion640/xtion320/kinect/kinectFreiburg1/kinectFreiburg2/kinectFreiburg3");  
  arg.param("oc_benchmarkFilename", oc_benchmarkFilename, "gicp_benchmark.txt", "Specify the name of the file that will contain the results of the benchmark");
  arg.param("oc_trajectoryFilename", oc_trajectoryFilename, "gicp_trajectory.txt", "Specify the name of the file that will contain the trajectory computed");
  arg.param("oc_associationsFilename", oc_associationsFilename, "gicp_associations.txt", "Specify the name of the file that contains the images associations");
  arg.param("oc_groundTruthFilename", oc_groundTruthFilename, "groundtruth.txt", "Specify the name of the file that contains the ground truth trajectory");

  arg.paramLeftOver("directory", directory, ".", "Directory where the program will find the input needed files and the subfolders depth and rgb containing the images", true);

  arg.parseArgs(argc, argv);
  
  // Create GUI
  QApplication application(argc,argv);
  QWidget* mainWindow = new QWidget();
  mainWindow->setWindowTitle("GICP Odometry ");
  QHBoxLayout* hlayout = new QHBoxLayout();
  mainWindow->setLayout(hlayout);
  PWNQGLViewer* viewer = new PWNQGLViewer(mainWindow);
  hlayout->addWidget(viewer);
  viewer->init();
  viewer->setAxisIsDrawn(true);
  viewer->show();
  mainWindow->showMaximized();
  mainWindow->show();
  
  // Init odometry controller
  GICPOdometryController *gicpOdometryController = new GICPOdometryController(pwn_configFilename.c_str(), pwn_logFilename.c_str());
  gicpOdometryController->fileInitialization(oc_groundTruthFilename.c_str(), oc_associationsFilename.c_str(),
						      oc_trajectoryFilename.c_str(), oc_benchmarkFilename.c_str());
  gicpOdometryController->setScaleFactor(pwn_scaleFactor);
  gicpOdometryController->setScale(pwn_scale);
  gicpOdometryController->setSensorType(pwn_sensorType);
  gicpOdometryController->setChunkStep(pwn_chunkStep);


  // Compute odometry
  bool sceneHasChanged = false;
  Frame *frame = 0, *groundTruthReferenceFrame = 0;
  Isometry3f groundTruthPose;	
  GLParameterTrajectory *groundTruthTrajectoryParam = new GLParameterTrajectory(0.02f, Vector4f(0.0f, 1.0f, 0.0f, 0.6f));
  GLParameterTrajectory *trajectoryParam = new GLParameterTrajectory(0.02f, Vector4f(1.0f, 0.0f, 0.0f, 0.6f));
  std::vector<Isometry3f> trajectory, groundTruthTrajectory;
  std::vector<Vector4f, Eigen::aligned_allocator<Eigen::Vector4f> > trajectoryColors, groundTruthTrajectoryColors;
  DrawableTrajectory *drawableGroundTruthTrajectory = new DrawableTrajectory(Isometry3f::Identity(), 
									    groundTruthTrajectoryParam, 
									    &groundTruthTrajectory, 
									    &groundTruthTrajectoryColors);
  DrawableTrajectory *drawableTrajectory = new DrawableTrajectory(Isometry3f::Identity(), 
								 trajectoryParam, 
								 &trajectory, 
								 &trajectoryColors);
  viewer->addDrawable(drawableGroundTruthTrajectory);
  viewer->addDrawable(drawableTrajectory);
  bool finished = false;
  while (mainWindow->isVisible()) {
    sceneHasChanged = false;
    if (sceneHasChanged)
      viewer->updateGL();
    application.processEvents();

    if (finished) {
      continue;
    }
    
    if (gicpOdometryController->loadFrame(frame)) {
    
      if(gicpOdometryController->counter() == 1) {
	gicpOdometryController->getGroundTruthPose(groundTruthPose, atof(gicpOdometryController->timestamp().c_str()));
	// Add first frame to draw
	groundTruthReferenceFrame = new Frame();
	*groundTruthReferenceFrame = *frame;
	GLParameterFrame *groundTruthReferenceFrameParams = new GLParameterFrame();
	groundTruthReferenceFrameParams->setStep(vz_pointStep);
	groundTruthReferenceFrameParams->setShow(true);	
	groundTruthReferenceFrameParams->parameterPoints()->setColor(Vector4f(1.0f, 0.0f, 1.0f, vz_alpha));
	DrawableFrame *drawableGroundTruthReferenceFrame = new DrawableFrame(groundTruthPose, groundTruthReferenceFrameParams, groundTruthReferenceFrame);
	GLParameterFrame *frameParams = new GLParameterFrame();
	frameParams->setStep(vz_pointStep);
	frameParams->setShow(true);	
	DrawableFrame *drawableFrame = new DrawableFrame(gicpOdometryController->globalPose(), frameParams, frame);
	viewer->addDrawable(drawableGroundTruthReferenceFrame);
	viewer->addDrawable(drawableFrame);

	sceneHasChanged = true;
      }
      // Compute current transformation
      if (gicpOdometryController->processFrame()) {
	gicpOdometryController->getGroundTruthPose(groundTruthPose, atof(gicpOdometryController->timestamp().c_str()));	
	
	// Add frame to draw
	GLParameterFrame *frameParams = new GLParameterFrame();
	frameParams->setStep(vz_pointStep);
	frameParams->setShow(true);	
	DrawableFrame *drawableFrame = new DrawableFrame(gicpOdometryController->globalPose(), frameParams, frame);
	viewer->addDrawable(drawableFrame);
	
	// Add trajectory pose
	groundTruthTrajectory.push_back(groundTruthPose);
	groundTruthTrajectoryColors.push_back(Vector4f(0.0f, 1.0f, 0.0f, 0.6f));
	trajectory.push_back(gicpOdometryController->globalPose());
	trajectoryColors.push_back(Vector4f(1.0f, 0.0f, 0.0f, 0.6f));
	drawableGroundTruthTrajectory->updateTrajectoryDrawList();
	drawableTrajectory->updateTrajectoryDrawList();
      
	// Write results
	gicpOdometryController->writeResults();
      
	sceneHasChanged = true;
      }
 
      // Remove old frames
      if (viewer->drawableList().size() > 23) {
	DrawableFrame *d = dynamic_cast<DrawableFrame*>(viewer->drawableList()[3]);
	if (d) {
	  Frame *f = d->frame();
	  if (gicpOdometryController->referenceFrame() != f &&
	      gicpOdometryController->currentFrame() != f) {
	    viewer->erase(3);
	    delete d;
	    delete f; 
	  }
	}
      }

      frame = 0;
    }
    else {
      finished = true;
    }
  }

  return 0;
}
Example #4
0
void VstPlugin::tryLoad( const QString &remoteVstPluginExecutable )
{
	init( remoteVstPluginExecutable, false );

	lock();
#ifdef LMMS_BUILD_WIN32
	QWidget * helper = new QWidget;
	QHBoxLayout * l = new QHBoxLayout( helper );
	QWidget * target = new QWidget( helper );
	l->setSpacing( 0 );
	l->setMargin( 0 );
	l->addWidget( target );

	static int k = 0;
	const QString t = QString( "vst%1%2" ).arg( GetCurrentProcessId()<<10 ).
								arg( ++k );
	helper->setWindowTitle( t );

	// we've to call that for making sure, Qt created the windows
	(void) helper->winId();
	(void) target->winId();

	sendMessage( message( IdVstPluginWindowInformation ).
					addString( QSTR_TO_STDSTR( t ) ) );
#endif

	VstHostLanguages hlang = LanguageEnglish;
	switch( QLocale::system().language() )
	{
		case QLocale::French: hlang = LanguageFrench; break;
		case QLocale::German: hlang = LanguageGerman; break;
		case QLocale::Italian: hlang = LanguageItalian; break;
		case QLocale::Japanese: hlang = LanguageJapanese; break;
		case QLocale::Korean: hlang = LanguageKorean; break;
		case QLocale::Spanish: hlang = LanguageSpanish; break;
		default: break;
	}
	sendMessage( message( IdVstSetLanguage ).addInt( hlang ) );


	QString p = m_plugin;
		if( QFileInfo( p ).dir().isRelative() )
		{
			p = ConfigManager::inst()->vstDir()  + p;
		}


	sendMessage( message( IdVstLoadPlugin ).addString( QSTR_TO_STDSTR( p ) ) );

	waitForInitDone();

	unlock();

#ifdef LMMS_BUILD_WIN32
	if( !failed() && m_pluginWindowID )
	{
		target->setFixedSize( m_pluginGeometry );
		vstSubWin * sw = new vstSubWin(
					gui->mainWindow()->workspace() );
		sw->setWidget( helper );
		helper->setWindowTitle( name() );
		m_pluginWidget = helper;
	}
	else
	{
		delete helper;
	}
#endif
}
void QgsAttributeTableDialog::doSearch( QString searchString )
{
  // parse search string and build parsed tree
  QgsExpression search( searchString );
  if ( search.hasParserError() )
  {
    QMessageBox::critical( this, tr( "Parsing error" ), search.parserErrorString() );
    return;
  }

  if ( ! search.prepare( mLayer->pendingFields() ) )
  {
    QMessageBox::critical( this, tr( "Evaluation error" ), search.evalErrorString() );
  }

  // TODO: fetch only necessary columns
  //QStringList columns = search.referencedColumns();
  bool fetchGeom = search.needsGeometry();

  QApplication::setOverrideCursor( Qt::WaitCursor );
  mSelectedFeatures.clear();

  if ( cbxSearchSelectedOnly->isChecked() )
  {
    QgsFeatureList selectedFeatures = mLayer->selectedFeatures();
    for ( QgsFeatureList::Iterator it = selectedFeatures.begin(); it != selectedFeatures.end(); ++it )
    {
      QgsFeature& feat = *it;
      if ( search.evaluate( &feat ).toInt() != 0 )
        mSelectedFeatures << feat.id();

      // check if there were errors during evaluating
      if ( search.hasEvalError() )
        break;
    }
  }
  else
  {
    mLayer->select( mLayer->pendingAllAttributesList(), QgsRectangle(), fetchGeom );
    QgsFeature f;

    while ( mLayer->nextFeature( f ) )
    {
      if ( search.evaluate( &f ).toInt() != 0 )
        mSelectedFeatures << f.id();

      // check if there were errors during evaluating
      if ( search.hasEvalError() )
        break;
    }
  }

  QApplication::restoreOverrideCursor();

  if ( search.hasEvalError() )
  {
    QMessageBox::critical( this, tr( "Error during search" ), search.evalErrorString() );
    return;
  }

  mLayer->setSelectedFeatures( mSelectedFeatures );

  QString str;
  QWidget *w = mDock ? qobject_cast<QWidget*>( mDock ) : qobject_cast<QWidget*>( this );
  if ( mSelectedFeatures.size() )
  {
    w->setWindowTitle( tr( "Attribute table - %1 (%n matching features)", "matching features", mSelectedFeatures.size() ).arg( mLayer->name() ) );
  }
  else
  {
    w->setWindowTitle( tr( "Attribute table - %1 (No matching features)" ).arg( mLayer->name() ) );
  }
  mView->setFocus();
}
Example #6
0
int main(int argc, char **argv)
{
    // Qt requires that we construct the global QApplication before creating any widgets.
    QApplication app(argc, argv);

    // use an ArgumentParser object to manage the program arguments.
    osg::ArgumentParser arguments(&argc,argv);

    // true = run osgViewer in a separate thread than Qt
    // false = interleave osgViewer and Qt in the main thread
    bool useFrameLoopThread = false;
    if (arguments.read("--no-frame-thread")) useFrameLoopThread = false;
    if (arguments.read("--frame-thread")) useFrameLoopThread = true;

    // true = use QWidgetImage
    // false = use QWebViewImage
    bool useWidgetImage = false;
    if (arguments.read("--useWidgetImage")) useWidgetImage = true;

    // true = use QWebView in a QWidgetImage to compare to QWebViewImage
    // false = make an interesting widget
    bool useBrowser = false;
    if (arguments.read("--useBrowser")) useBrowser = true;

    // true = use a QLabel for text
    // false = use a QTextEdit for text
    // (only applies if useWidgetImage == true and useBrowser == false)
    bool useLabel = false;
    if (arguments.read("--useLabel")) useLabel = true;

    // true = make a Qt window with the same content to compare to
    // QWebViewImage/QWidgetImage
    // false = use QWebViewImage/QWidgetImage (depending on useWidgetImage)
    bool sanityCheck = false;
    if (arguments.read("--sanityCheck")) sanityCheck = true;

    // Add n floating windows inside the QGraphicsScene.
    int numFloatingWindows = 0;
    while (arguments.read("--numFloatingWindows", numFloatingWindows));

    // true = Qt widgets will be displayed on a quad inside the 3D scene
    // false = Qt widgets will be an overlay over the scene (like a HUD)
    bool inScene = true;
    if (arguments.read("--fullscreen")) {
        inScene = false;
    }


    osg::ref_ptr<osg::Group> root = new osg::Group;

    if (!useWidgetImage)
    {
        //-------------------------------------------------------------------
        // QWebViewImage test
        //-------------------------------------------------------------------
        // Note: When the last few issues with QWidgetImage are fixed,
        // QWebViewImage and this if() {} section can be removed since
        // QWidgetImage can display a QWebView just like QWebViewImage. Use
        // --useWidgetImage --useBrowser to see that in action.

        if (!sanityCheck)
        {
            osg::ref_ptr<osgQt::QWebViewImage> image = new osgQt::QWebViewImage;

            if (arguments.argc()>1) image->navigateTo((arguments[1]));
            else image->navigateTo("http://www.youtube.com/");

            osgWidget::GeometryHints hints(osg::Vec3(0.0f,0.0f,0.0f),
                                           osg::Vec3(1.0f,0.0f,0.0f),
                                           osg::Vec3(0.0f,0.0f,1.0f),
                                           osg::Vec4(1.0f,1.0f,1.0f,1.0f),
                                           osgWidget::GeometryHints::RESIZE_HEIGHT_TO_MAINTAINCE_ASPECT_RATIO);

            osg::ref_ptr<osgWidget::Browser> browser = new osgWidget::Browser;
            browser->assign(image.get(), hints);

            root->addChild(browser.get());
        }
        else
        {
            // Sanity check, do the same thing as QGraphicsViewAdapter but in
            // a separate Qt window.
            QWebPage* webPage = new QWebPage;
            webPage->settings()->setAttribute(QWebSettings::JavascriptEnabled, true);
            webPage->settings()->setAttribute(QWebSettings::PluginsEnabled, true);

            QWebView* webView = new QWebView;
            webView->setPage(webPage);

            if (arguments.argc()>1) webView->load(QUrl(arguments[1]));
            else webView->load(QUrl("http://www.youtube.com/"));

            QGraphicsScene* graphicsScene = new QGraphicsScene;
            graphicsScene->addWidget(webView);

            QGraphicsView* graphicsView = new QGraphicsView;
            graphicsView->setScene(graphicsScene);

            QMainWindow* mainWindow = new QMainWindow;
            //mainWindow->setLayout(new QVBoxLayout);
            mainWindow->setCentralWidget(graphicsView);
            mainWindow->setGeometry(50, 50, 1024, 768);
            mainWindow->show();
            mainWindow->raise();
        }
    }
    else
    {
        //-------------------------------------------------------------------
        // QWidgetImage test
        //-------------------------------------------------------------------
        // QWidgetImage still has some issues, some examples are:
        //
        // 1. Editing in the QTextEdit doesn't work. Also when started with
        //    --useBrowser, editing in the search field on YouTube doesn't
        //    work. But that same search field when using QWebViewImage
        //    works... And editing in the text field in the pop-up getInteger
        //    dialog works too. All these cases use QGraphicsViewAdapter
        //    under the hood, so why do some work and others don't?
        //
        //    a) osgQtBrowser --useWidgetImage [--fullscreen] (optional)
        //    b) Try to click in the QTextEdit and type, or to select text
        //       and drag-and-drop it somewhere else in the QTextEdit. These
        //       don't work.
        //    c) osgQtBrowser --useWidgetImage --sanityCheck
        //    d) Try the operations in b), they all work.
        //    e) osgQtBrowser --useWidgetImage --useBrowser [--fullscreen]
        //    f) Try to click in the search field and type, it doesn't work.
        //    g) osgQtBrowser
        //    h) Try the operation in f), it works.
        //
        // 2. Operations on floating windows (--numFloatingWindows 1 or more).
        //    Moving by dragging the titlebar, clicking the close button,
        //    resizing them, none of these work. I wonder if it's because the
        //    OS manages those functions (they're functions of the window
        //    decorations) so we need to do something special for that? But
        //    in --sanityCheck mode they work.
        //
        //    a) osgQtBrowser --useWidgetImage --numFloatingWindows 1 [--fullscreen]
        //    b) Try to drag the floating window, click the close button, or
        //       drag its sides to resize it. None of these work.
        //    c) osgQtBrowser --useWidgetImage --numFloatingWindows 1 --sanityCheck
        //    d) Try the operations in b), all they work.
        //    e) osgQtBrowser --useWidgetImage [--fullscreen]
        //    f) Click the button so that the getInteger() dialog is
        //       displayed, then try to move that dialog or close it with the
        //       close button, these don't work.
        //    g) osgQtBrowser --useWidgetImage --sanityCheck
        //    h) Try the operation in f), it works.
        //
        // 3. (Minor) The QGraphicsView's scrollbars don't appear when
        //    using QWidgetImage or QWebViewImage. QGraphicsView is a
        //    QAbstractScrollArea and it should display scrollbars as soon as
        //    the scene is too large to fit the view.
        //
        //    a) osgQtBrowser --useWidgetImage --fullscreen
        //    b) Resize the OSG window so it's smaller than the QTextEdit.
        //       Scrollbars should appear but don't.
        //    c) osgQtBrowser --useWidgetImage --sanityCheck
        //    d) Try the operation in b), scrollbars appear. Even if you have
        //       floating windows (by clicking the button or by adding
        //       --numFloatingWindows 1) and move them outside the view,
        //       scrollbars appear too. You can't test that case in OSG for
        //       now because of problem 2 above, but that's pretty cool.
        //
        // 4. (Minor) In sanity check mode, the widget added to the
        //    QGraphicsView is centered. With QGraphicsViewAdapter, it is not.
        //
        //    a) osgQtBrowser --useWidgetImage [--fullscreen]
        //    b) The QTextEdit and button are not in the center of the image
        //       generated by the QGraphicsViewAdapter.
        //    c) osgQtBrowser --useWidgetImage --sanityCheck
        //    d) The QTextEdit and button are in the center of the
        //       QGraphicsView.


        QWidget* widget = 0;
        if (useBrowser)
        {
            QWebPage* webPage = new QWebPage;
            webPage->settings()->setAttribute(QWebSettings::JavascriptEnabled, true);
            webPage->settings()->setAttribute(QWebSettings::PluginsEnabled, true);

            QWebView* webView = new QWebView;
            webView->setPage(webPage);

            if (arguments.argc()>1) webView->load(QUrl(arguments[1]));
            else webView->load(QUrl("http://www.youtube.com/"));

            widget = webView;
        }
        else
        {
            widget = new QWidget;
            widget->setLayout(new QVBoxLayout);

            QString text("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque velit turpis, euismod ac ultrices et, molestie non nisi. Nullam egestas dignissim enim, quis placerat nulla suscipit sed. Donec molestie elementum risus sit amet sodales. Nunc consectetur congue neque, at viverra massa pharetra fringilla. Integer vitae mi sem. Donec dapibus semper elit nec sollicitudin. Vivamus egestas ultricies felis, in mollis mi facilisis quis. Nam suscipit bibendum eros sed cursus. Suspendisse mollis suscipit hendrerit. Etiam magna eros, convallis non congue vel, faucibus ac augue. Integer ante ante, porta in ornare ullamcorper, congue nec nibh. Etiam congue enim vitae enim sollicitudin fringilla. Mauris mattis, urna in fringilla dapibus, ipsum sem feugiat purus, ac hendrerit felis arcu sed sapien. Integer id velit quam, sit amet dignissim tortor. Sed mi tortor, placerat ac luctus id, tincidunt et urna. Nulla sed nunc ante.Sed ut sodales enim. Ut sollicitudin ultricies magna, vel ultricies ante venenatis id. Cras luctus mi in lectus rhoncus malesuada. Sed ac sollicitudin nisi. Nunc venenatis congue quam, et suscipit diam consectetur id. Donec vel enim ac enim elementum bibendum ut quis augue. Nulla posuere suscipit dolor, id convallis tortor congue eu. Vivamus sagittis consectetur dictum. Duis a ante quis dui varius fermentum. In hac habitasse platea dictumst. Nam dapibus dolor eu felis eleifend in scelerisque dolor ultrices. Donec arcu lectus, fringilla ut interdum non, tristique id dolor. Morbi sagittis sagittis volutpat. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Duis venenatis ultrices euismod.Nam sit amet convallis libero. Integer lectus urna, eleifend et sollicitudin non, porttitor vel erat. Vestibulum pulvinar egestas leo, a porttitor turpis ullamcorper et. Vestibulum in ornare turpis. Ut nec libero a sem mattis iaculis quis id purus. Praesent ante neque, dictum vitae pretium vel, iaculis luctus dui. Etiam luctus tellus vel nunc suscipit a ullamcorper nisl semper. Nunc dapibus, eros in sodales dignissim, orci lectus egestas felis, sit amet vehicula tortor dolor eu quam. Vivamus pellentesque convallis quam aliquet pellentesque. Phasellus facilisis arcu ac orci fringilla aliquet. Donec sed euismod augue. Duis eget orci sit amet neque tempor fringilla. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; In hac habitasse platea dictumst. Duis sollicitudin, lacus ac pellentesque lacinia, lacus magna pulvinar purus, pulvinar porttitor est nibh quis augue.Duis eleifend, massa sit amet mattis fringilla, elit turpis venenatis libero, sed convallis turpis diam sit amet ligula. Morbi non dictum turpis. Integer porttitor condimentum elit, sit amet sagittis nibh ultrices sit amet. Mauris ac arcu augue, id aliquet mauris. Donec ultricies urna id enim accumsan at pharetra dui adipiscing. Nunc luctus rutrum molestie. Curabitur libero ipsum, viverra at pulvinar ut, porttitor et neque. Aliquam sit amet dolor et purus sagittis adipiscing. Nam sit amet hendrerit sem. Etiam varius, ligula non ultricies dignissim, sapien dui commodo urna, eu vehicula enim nunc molestie augue. Fusce euismod, erat vitae pharetra tempor, quam eros tincidunt lorem, ut iaculis ligula erat vitae nibh. Aenean eu ultricies dolor. Curabitur suscipit viverra bibendum.Sed egestas adipiscing mi in egestas. Proin in neque in nibh blandit consequat nec quis tortor. Vestibulum sed interdum justo. Sed volutpat velit vitae elit pulvinar aliquam egestas elit rutrum. Proin lorem nibh, bibendum vitae sollicitudin condimentum, pulvinar ut turpis. Maecenas iaculis, mauris in consequat ultrices, ante erat blandit mi, vel fermentum lorem turpis eget sem. Integer ultrices tristique erat sit amet volutpat. In sit amet diam et nunc congue pellentesque at in dolor. Mauris eget orci orci. Integer posuere augue ornare tortor tempus elementum. Quisque iaculis, nunc ac cursus fringilla, magna elit cursus eros, id feugiat diam eros et tellus. Etiam consectetur ultrices erat quis rhoncus. Mauris eu lacinia neque. Curabitur suscipit feugiat tellus in dictum. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed aliquam tempus ante a tempor. Praesent viverra erat quis sapien pretium rutrum. Praesent dictum scelerisque venenatis.Proin bibendum lectus eget nisl lacinia porta. Morbi eu erat in sapien malesuada vulputate. Cras non elit quam. Ut dictum urna quis nisl feugiat ac sollicitudin libero luctus. Donec leo mauris, varius at luctus eget, placerat quis arcu. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Etiam tristique, mauris ut lacinia elementum, mauris erat consequat massa, ac gravida nisi tellus vitae purus. Curabitur consectetur ultricies commodo. Cras pulvinar orci nec enim adipiscing tristique. Ut ornare orci id est fringilla sit amet blandit libero pellentesque. Vestibulum tincidunt sapien ut enim venenatis vestibulum ultricies ipsum tristique. Mauris tempus eleifend varius. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse vitae dui ac quam gravida semper. In ac enim ac ligula rutrum porttitor.Integer dictum sagittis leo, at convallis sapien facilisis eget. Etiam cursus bibendum tortor, faucibus aliquam lectus ullamcorper sed. Nulla pulvinar posuere quam, ut sagittis ligula tincidunt ut. Nulla convallis velit ut enim condimentum pulvinar. Quisque gravida accumsan scelerisque. Proin pellentesque nisi cursus tortor aliquet dapibus. Duis vel eros orci. Sed eget purus ligula. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ullamcorper porta congue. Nunc id velit ut neque malesuada consequat in eu nisi. Nulla facilisi. Quisque pellentesque magna vitae nisl euismod ac accumsan tellus feugiat.Nulla facilisi. Integer quis orci lectus, non aliquam nisi. Vivamus varius porta est, ac porttitor orci blandit mattis. Sed dapibus facilisis dapibus. Duis tincidunt leo ac tortor faucibus hendrerit. Morbi sit amet sapien risus, vel luctus enim. Aliquam sagittis nunc id purus aliquam lobortis. Duis posuere viverra dui, sit amet convallis sem vulputate at. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque pellentesque, lectus id imperdiet commodo, diam diam faucibus lectus, sit amet vestibulum tortor lacus viverra eros.Maecenas nec augue lectus. Duis nec arcu eget lorem tempus sollicitudin suscipit vitae arcu. Nullam vitae mauris lectus. Vivamus id risus neque, dignissim vehicula diam. Cras rhoncus velit sed velit iaculis ac dignissim turpis luctus. Suspendisse potenti. Sed vitae ligula a ligula ornare rutrum sit amet ut quam. Duis tincidunt, nibh vitae iaculis adipiscing, dolor orci cursus arcu, vel congue tortor quam eget arcu. Suspendisse tellus felis, blandit ac accumsan vitae, fringilla id lorem. Duis tempor lorem mollis est congue ut imperdiet velit laoreet. Nullam interdum cursus mollis. Pellentesque non mauris accumsan elit laoreet viverra ut at risus. Proin rutrum sollicitudin sem, vitae ultricies augue sagittis vel. Cras quis vehicula neque. Aliquam erat volutpat. Aliquam erat volutpat. Praesent non est erat, accumsan rutrum lacus. Pellentesque tristique molestie aliquet. Cras ullamcorper facilisis faucibus. In non lorem quis velit lobortis pulvinar.Phasellus non sem ipsum. Praesent ut libero quis turpis viverra semper. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. In hac habitasse platea dictumst. Donec at velit tellus. Fusce commodo pharetra tincidunt. Proin lacus enim, fringilla a fermentum ut, vestibulum ut nibh. Duis commodo dolor vel felis vehicula at egestas neque bibendum. Phasellus malesuada dictum ante in aliquam. Curabitur interdum semper urna, nec placerat justo gravida in. Praesent quis mauris massa. Pellentesque porttitor lacinia tincidunt. Phasellus egestas viverra elit vel blandit. Sed dapibus nisi et lectus pharetra dignissim. Mauris hendrerit lectus nec purus dapibus condimentum. Sed ac eros nulla. Aenean semper sapien a nibh aliquam lobortis. Aliquam elementum euismod sapien, in dapibus leo dictum et. Pellentesque augue neque, ultricies non viverra eu, tincidunt ac arcu. Morbi ut porttitor lectus.");

            if (useLabel)
            {
                QLabel* label = new QLabel(text);
                label->setWordWrap(true);
                label->setTextInteractionFlags(Qt::TextEditorInteraction);

                QPalette palette = label->palette();
                palette.setColor(QPalette::Highlight, Qt::darkBlue);
                palette.setColor(QPalette::HighlightedText, Qt::white);
                label->setPalette(palette);

                QScrollArea* scrollArea = new QScrollArea;
                scrollArea->setWidget(label);

                widget->layout()->addWidget(scrollArea);
            }
            else
            {
                QTextEdit* textEdit = new QTextEdit(text);
                textEdit->setReadOnly(false);
                textEdit->setTextInteractionFlags(Qt::TextEditable);

                QPalette palette = textEdit->palette();
                palette.setColor(QPalette::Highlight, Qt::darkBlue);
                palette.setColor(QPalette::HighlightedText, Qt::white);
                textEdit->setPalette(palette);

                widget->layout()->addWidget(textEdit);
            }

            QPushButton* button = new MyPushButton("Button");
            widget->layout()->addWidget(button);

            widget->setGeometry(0, 0, 800, 600);
        }

        QGraphicsScene* graphicsScene = 0;

        if (!sanityCheck)
        {
            osg::ref_ptr<osgQt::QWidgetImage> widgetImage = new osgQt::QWidgetImage(widget);
#if (QT_VERSION >= QT_VERSION_CHECK(4, 5, 0))
            widgetImage->getQWidget()->setAttribute(Qt::WA_TranslucentBackground);
#endif
            widgetImage->getQGraphicsViewAdapter()->setBackgroundColor(QColor(0, 0, 0, 0));
            //widgetImage->getQGraphicsViewAdapter()->resize(800, 600);
            graphicsScene = widgetImage->getQGraphicsViewAdapter()->getQGraphicsScene();

            osg::Camera* camera = 0;        // Will stay NULL in the inScene case.
            osg::Geometry* quad = osg::createTexturedQuadGeometry(osg::Vec3(0,0,0), osg::Vec3(1,0,0), osg::Vec3(0,1,0), 1, 1);
            osg::Geode* geode = new osg::Geode;
            geode->addDrawable(quad);

            osg::MatrixTransform* mt = new osg::MatrixTransform;

            osg::Texture2D* texture = new osg::Texture2D(widgetImage.get());
            texture->setResizeNonPowerOfTwoHint(false);
            texture->setFilter(osg::Texture::MIN_FILTER,osg::Texture::LINEAR);
            texture->setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE);
            texture->setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE);
            mt->getOrCreateStateSet()->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON);

            osgViewer::InteractiveImageHandler* handler;
            if (inScene)
            {
                mt->setMatrix(osg::Matrix::rotate(osg::Vec3(0,1,0), osg::Vec3(0,0,1)));
                mt->addChild(geode);

                handler = new osgViewer::InteractiveImageHandler(widgetImage.get());
            }
            else    // fullscreen
            {
                // The HUD camera's viewport needs to follow the size of the
                // window. MyInteractiveImageHandler will make sure of this.
                // As for the quad and the camera's projection, setting the
                // projection resize policy to FIXED takes care of them, so
                // they can stay the same: (0,1,0,1) with a quad that fits.

                // Set the HUD camera's projection and viewport to match the screen.
                camera = new osg::Camera;
                camera->setProjectionResizePolicy(osg::Camera::FIXED);
                camera->setProjectionMatrix(osg::Matrix::ortho2D(0,1,0,1));
                camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
                camera->setViewMatrix(osg::Matrix::identity());
                camera->setClearMask(GL_DEPTH_BUFFER_BIT);
                camera->setRenderOrder(osg::Camera::POST_RENDER);
                camera->addChild(geode);
                camera->setViewport(0, 0, 1024, 768);

                mt->addChild(camera);

                handler = new osgViewer::InteractiveImageHandler(widgetImage.get(), texture, camera);
            }

            mt->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
            mt->getOrCreateStateSet()->setMode(GL_BLEND, osg::StateAttribute::ON);
            mt->getOrCreateStateSet()->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
            mt->getOrCreateStateSet()->setAttribute(new osg::Program);

            osg::Group* overlay = new osg::Group;
            overlay->addChild(mt);

            root->addChild(overlay);

            quad->setEventCallback(handler);
            quad->setCullCallback(handler);
        }
        else
        {
            // Sanity check, do the same thing as QWidgetImage and
            // QGraphicsViewAdapter but in a separate Qt window.

            graphicsScene = new QGraphicsScene;
            graphicsScene->addWidget(widget);

            QGraphicsView* graphicsView = new QGraphicsView;
            graphicsView->setScene(graphicsScene);

            QMainWindow* mainWindow = new QMainWindow;
            mainWindow->setCentralWidget(graphicsView);
            mainWindow->setGeometry(50, 50, 1024, 768);
            mainWindow->show();
            mainWindow->raise();
        }

        // Add numFloatingWindows windows to the graphicsScene.
        for (unsigned int i = 0; i < (unsigned int)numFloatingWindows; ++i)
        {
            QWidget* window = new QWidget(0, Qt::Window);
            window->setWindowTitle(QString("Window %1").arg(i));
            window->setLayout(new QVBoxLayout);
            window->layout()->addWidget(new QLabel(QString("This window %1").arg(i)));
            window->layout()->addWidget(new MyPushButton(QString("Button in window %1").arg(i)));
            window->setGeometry(100, 100, 300, 300);

            QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(0, Qt::Window);
            proxy->setWidget(window);
            proxy->setFlag(QGraphicsItem::ItemIsMovable, true);

            graphicsScene->addItem(proxy);
        }

    }

    root->addChild(osgDB::readNodeFile("cow.osg.(15,0,5).trans.(0.1,0.1,0.1).scale"));

    osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer(arguments);
    viewer->setSceneData(root.get());
    viewer->setCameraManipulator(new osgGA::TrackballManipulator());
    viewer->addEventHandler(new osgGA::StateSetManipulator(root->getOrCreateStateSet()));
    viewer->addEventHandler(new osgViewer::StatsHandler);
    viewer->addEventHandler(new osgViewer::WindowSizeHandler);

    viewer->setUpViewInWindow(50, 50, 1024, 768);
    viewer->getEventQueue()->windowResize(0, 0, 1024, 768);

    if (useFrameLoopThread)
    {
        // create a thread to run the viewer's frame loop
        ViewerFrameThread viewerThread(viewer.get(), true);
        viewerThread.startThread();

        // now start the standard Qt event loop, then exists when the viewerThead sends the QApplication::exit() signal.
        return QApplication::exec();

    }
    else
    {
        // run the frame loop, interleaving Qt and the main OSG frame loop
        while(!viewer->done())
        {
            // process Qt events - this handles both events and paints the browser image
            QCoreApplication::processEvents(QEventLoop::AllEvents, 100);

            viewer->frame();
        }

        return 0;
    }
}
Example #7
0
void TaskbarPreviews::setTabTitle(QWidget *tab, const QString &customTitle)
{
	QWidget *w = m_tabs.internal(tab);
	if (w)
		w->setWindowTitle(customTitle);
}
Example #8
0
QString
DistanceMapFilter::start(VolumeFileManager *vfm,
			 int nX, int nY, int nZ,
			 Vec dataMin, Vec dataMax,
			 QString prevDir,
			 int samplingLevel,
			 QList<Vec> clipPos,
			 QList<Vec> clipNormal,
			 QList<CropObject> crops,
			 QList<PathObject> paths,
			 uchar *lut,
			 int pruneLod, int pruneX, int pruneY, int pruneZ,
			 QVector<uchar> pruneData)
{
  m_vfm = vfm;
  m_voxelType = m_vfm->voxelType();
  m_depth = nX;
  m_width = nY;
  m_height = nZ;
  m_dataMin = dataMin;
  m_dataMax = dataMax;
  m_dataSize = m_dataMax - m_dataMin + Vec(1,1,1);
  m_nX = qMin(int(m_dataSize.z), m_depth);
  m_nY = qMin(int(m_dataSize.y), m_width);
  m_nZ = qMin(int(m_dataSize.x), m_height);
  m_crops = crops;
  m_paths = paths;
  m_pruneLod = pruneLod;
  m_pruneX = pruneX;
  m_pruneY = pruneY;
  m_pruneZ = pruneZ;
  m_pruneData = pruneData;
  m_samplingLevel = samplingLevel;

  // pruneLod that we get is wrt the original sized volume.
  // set pruneLod to reflect the selected sampling level.
  m_pruneLod = qMax((float)m_nX/(float)m_pruneZ,
		    qMax((float)m_nY/(float)m_pruneY,
			 (float)m_nZ/(float)m_pruneX));

//  QMessageBox::information(0, "", QString("%1 %2 %3\n%4 %5 %6\n%7").\
//			   arg(m_nX).arg(m_nY).arg(m_nZ).\
//			   arg(m_pruneZ).arg(m_pruneY).arg(m_pruneX).\
//			   arg(m_pruneLod));

  m_meshLog = new QTextEdit;
  m_meshProgress = new QProgressBar;

  QVBoxLayout *meshLayout = new QVBoxLayout;
  meshLayout->addWidget(m_meshLog);
  meshLayout->addWidget(m_meshProgress);

  QWidget *meshWindow = new QWidget;
  meshWindow->setWindowTitle("Drishti - Signed Distance Map Using Opacity Values");
  meshWindow->setLayout(meshLayout);
  meshWindow->show();
  meshWindow->resize(700, 300);

  m_meshLog->insertPlainText("Using Signed Maurer Distance Map Image Filter.");

  m_meshLog->insertPlainText("\n\n");
  m_meshLog->insertPlainText(QString("Volume Size : %1 %2 %3\n").\
			   arg(m_depth).
			   arg(m_width).
			   arg(m_height));
  m_meshLog->insertPlainText(QString("DataMin : %1 %2 %3\n").\
			   arg(m_dataMin.z).
			   arg(m_dataMin.y).
			   arg(m_dataMin.x));
  m_meshLog->insertPlainText(QString("DataMax : %1 %2 %3\n").\
			   arg(m_dataMax.z).
			   arg(m_dataMax.y).
			   arg(m_dataMax.x));
  m_meshLog->insertPlainText(QString("DataSize : %1 %2 %3\n").\
			   arg(m_dataSize.z).
			   arg(m_dataSize.y).
			   arg(m_dataSize.x));
  m_meshLog->insertPlainText(QString("Grid size : %1 %2 %3\n").\
			   arg(m_nX).arg(m_nY).arg(m_nZ));
  

  //---- export the grid ---
  QString flnm = QFileDialog::getSaveFileName(0,
					      "Save distance map to file",
					      prevDir,
					      "*.raw");
  if (flnm.size() == 0)
    {
      meshWindow->close();
      return "";
    }
  //----------------------------

  int chan = 0; // mop channel

  try
    {
      applyDistanceMapFilter(flnm,
			     clipPos, clipNormal,
			     crops, paths,
			     lut,
			     chan);
    }
  catch ( ... )
    {
      QMessageBox::information(0, "Error", "Sorry cannot run the filter.\nProbably cannot allocate enough memory or failure in the filter code.");
    }


  meshWindow->close();

  return flnm;
}
Example #9
0
int main(int argc, char **argv)
{
    //! [0]
    QApplication app(argc, argv);
    Q3DSurface *graph = new Q3DSurface();
    QWidget *container = QWidget::createWindowContainer(graph);
    //! [0]

    if (!graph->hasContext()) {
        QMessageBox msgBox;
        msgBox.setText("Couldn't initialize the OpenGL context.");
        msgBox.exec();
        return -1;
    }

    QSize screenSize = graph->screen()->size();
    container->setMinimumSize(QSize(screenSize.width() / 2, screenSize.height() / 1.6));
    container->setMaximumSize(screenSize);
    container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    container->setFocusPolicy(Qt::StrongFocus);

    //! [1]
    QWidget *widget = new QWidget;
    QHBoxLayout *hLayout = new QHBoxLayout(widget);
    QVBoxLayout *vLayout = new QVBoxLayout();
    hLayout->addWidget(container, 1);
    hLayout->addLayout(vLayout);
    vLayout->setAlignment(Qt::AlignTop);
    //! [1]

    widget->setWindowTitle(QStringLiteral("Surface example"));

    QGroupBox *modelGroupBox = new QGroupBox(QStringLiteral("Model"));

    QRadioButton *sqrtSinModelRB = new QRadioButton(widget);
    sqrtSinModelRB->setText(QStringLiteral("Sqrt && Sin"));
    sqrtSinModelRB->setChecked(false);

    QRadioButton *heightMapModelRB = new QRadioButton(widget);
    heightMapModelRB->setText(QStringLiteral("Height Map"));
    heightMapModelRB->setChecked(false);

    QVBoxLayout *modelVBox = new QVBoxLayout;
    modelVBox->addWidget(sqrtSinModelRB);
    modelVBox->addWidget(heightMapModelRB);
    modelGroupBox->setLayout(modelVBox);

    QGroupBox *selectionGroupBox = new QGroupBox(QStringLiteral("Selection Mode"));

    QRadioButton *modeNoneRB = new QRadioButton(widget);
    modeNoneRB->setText(QStringLiteral("No selection"));
    modeNoneRB->setChecked(false);

    QRadioButton *modeItemRB = new QRadioButton(widget);
    modeItemRB->setText(QStringLiteral("Item"));
    modeItemRB->setChecked(false);

    QRadioButton *modeSliceRowRB = new QRadioButton(widget);
    modeSliceRowRB->setText(QStringLiteral("Row Slice"));
    modeSliceRowRB->setChecked(false);

    QRadioButton *modeSliceColumnRB = new QRadioButton(widget);
    modeSliceColumnRB->setText(QStringLiteral("Column Slice"));
    modeSliceColumnRB->setChecked(false);

    QVBoxLayout *selectionVBox = new QVBoxLayout;
    selectionVBox->addWidget(modeNoneRB);
    selectionVBox->addWidget(modeItemRB);
    selectionVBox->addWidget(modeSliceRowRB);
    selectionVBox->addWidget(modeSliceColumnRB);
    selectionGroupBox->setLayout(selectionVBox);

    QSlider *axisMinSliderX = new QSlider(Qt::Horizontal, widget);
    axisMinSliderX->setMinimum(0);
    axisMinSliderX->setTickInterval(1);
    axisMinSliderX->setEnabled(true);
    QSlider *axisMaxSliderX = new QSlider(Qt::Horizontal, widget);
    axisMaxSliderX->setMinimum(1);
    axisMaxSliderX->setTickInterval(1);
    axisMaxSliderX->setEnabled(true);
    QSlider *axisMinSliderZ = new QSlider(Qt::Horizontal, widget);
    axisMinSliderZ->setMinimum(0);
    axisMinSliderZ->setTickInterval(1);
    axisMinSliderZ->setEnabled(true);
    QSlider *axisMaxSliderZ = new QSlider(Qt::Horizontal, widget);
    axisMaxSliderZ->setMinimum(1);
    axisMaxSliderZ->setTickInterval(1);
    axisMaxSliderZ->setEnabled(true);

    QComboBox *themeList = new QComboBox(widget);
    themeList->addItem(QStringLiteral("Qt"));
    themeList->addItem(QStringLiteral("Primary Colors"));
    themeList->addItem(QStringLiteral("Digia"));
    themeList->addItem(QStringLiteral("Stone Moss"));
    themeList->addItem(QStringLiteral("Army Blue"));
    themeList->addItem(QStringLiteral("Retro"));
    themeList->addItem(QStringLiteral("Ebony"));
    themeList->addItem(QStringLiteral("Isabelle"));

    QGroupBox *colorGroupBox = new QGroupBox(QStringLiteral("Custom gradient"));

    QLinearGradient grBtoY(0, 0, 1, 100);
    grBtoY.setColorAt(1.0, Qt::black);
    grBtoY.setColorAt(0.67, Qt::blue);
    grBtoY.setColorAt(0.33, Qt::red);
    grBtoY.setColorAt(0.0, Qt::yellow);
    QPixmap pm(24, 100);
    QPainter pmp(&pm);
    pmp.setBrush(QBrush(grBtoY));
    pmp.setPen(Qt::NoPen);
    pmp.drawRect(0, 0, 24, 100);
    QPushButton *gradientBtoYPB = new QPushButton(widget);
    gradientBtoYPB->setIcon(QIcon(pm));
    gradientBtoYPB->setIconSize(QSize(24, 100));

    QLinearGradient grGtoR(0, 0, 1, 100);
    grGtoR.setColorAt(1.0, Qt::darkGreen);
    grGtoR.setColorAt(0.5, Qt::yellow);
    grGtoR.setColorAt(0.2, Qt::red);
    grGtoR.setColorAt(0.0, Qt::darkRed);
    pmp.setBrush(QBrush(grGtoR));
    pmp.drawRect(0, 0, 24, 100);
    QPushButton *gradientGtoRPB = new QPushButton(widget);
    gradientGtoRPB->setIcon(QIcon(pm));
    gradientGtoRPB->setIconSize(QSize(24, 100));

    QHBoxLayout *colorHBox = new QHBoxLayout;
    colorHBox->addWidget(gradientBtoYPB);
    colorHBox->addWidget(gradientGtoRPB);
    colorGroupBox->setLayout(colorHBox);

    vLayout->addWidget(modelGroupBox);
    vLayout->addWidget(selectionGroupBox);
    vLayout->addWidget(new QLabel(QStringLiteral("Column range")));
    vLayout->addWidget(axisMinSliderX);
    vLayout->addWidget(axisMaxSliderX);
    vLayout->addWidget(new QLabel(QStringLiteral("Row range")));
    vLayout->addWidget(axisMinSliderZ);
    vLayout->addWidget(axisMaxSliderZ);
    vLayout->addWidget(new QLabel(QStringLiteral("Theme")));
    vLayout->addWidget(themeList);
    vLayout->addWidget(colorGroupBox);

    widget->show();

    SurfaceGraph *modifier = new SurfaceGraph(graph);

    QObject::connect(heightMapModelRB, &QRadioButton::toggled,
                     modifier, &SurfaceGraph::enableHeightMapModel);
    QObject::connect(sqrtSinModelRB, &QRadioButton::toggled,
                     modifier, &SurfaceGraph::enableSqrtSinModel);
    QObject::connect(modeNoneRB, &QRadioButton::toggled,
                     modifier, &SurfaceGraph::toggleModeNone);
    QObject::connect(modeItemRB,  &QRadioButton::toggled,
                     modifier, &SurfaceGraph::toggleModeItem);
    QObject::connect(modeSliceRowRB,  &QRadioButton::toggled,
                     modifier, &SurfaceGraph::toggleModeSliceRow);
    QObject::connect(modeSliceColumnRB,  &QRadioButton::toggled,
                     modifier, &SurfaceGraph::toggleModeSliceColumn);
    QObject::connect(axisMinSliderX, &QSlider::valueChanged,
                     modifier, &SurfaceGraph::adjustXMin);
    QObject::connect(axisMaxSliderX, &QSlider::valueChanged,
                     modifier, &SurfaceGraph::adjustXMax);
    QObject::connect(axisMinSliderZ, &QSlider::valueChanged,
                     modifier, &SurfaceGraph::adjustZMin);
    QObject::connect(axisMaxSliderZ, &QSlider::valueChanged,
                     modifier, &SurfaceGraph::adjustZMax);
    QObject::connect(themeList, SIGNAL(currentIndexChanged(int)),
                     modifier, SLOT(changeTheme(int)));
    QObject::connect(gradientBtoYPB, &QPushButton::pressed,
                     modifier, &SurfaceGraph::setBlackToYellowGradient);
    QObject::connect(gradientGtoRPB, &QPushButton::pressed,
                     modifier, &SurfaceGraph::setGreenToRedGradient);

    modifier->setAxisMinSliderX(axisMinSliderX);
    modifier->setAxisMaxSliderX(axisMaxSliderX);
    modifier->setAxisMinSliderZ(axisMinSliderZ);
    modifier->setAxisMaxSliderZ(axisMaxSliderZ);

    sqrtSinModelRB->setChecked(true);
    modeItemRB->setChecked(true);
    themeList->setCurrentIndex(2);

    return app.exec();
}
Example #10
0
QString
MeshGenerator::start(VolumeFileManager *vfm,
		     int nX, int nY, int nZ,
		     Vec dataMin, Vec dataMax,
		     QString prevDir,
		     Vec voxelScaling, int samplingLevel,
		     QList<Vec> clipPos,
		     QList<Vec> clipNormal,
		     QList<CropObject> crops,
		     QList<PathObject> paths,
		     uchar *lut,
		     int pruneLod, int pruneX, int pruneY, int pruneZ,
		     QVector<uchar> pruneData,
		     QVector<uchar> tagColors)
{
  m_vfm = vfm;
  m_voxelType = m_vfm->voxelType();
  m_depth = nX;
  m_width = nY;
  m_height = nZ;
  m_dataMin = dataMin;
  m_dataMax = dataMax;
  m_dataSize = m_dataMax - m_dataMin + Vec(1,1,1);
  m_nX = qMin(int(m_dataSize.z), m_depth);
  m_nY = qMin(int(m_dataSize.y), m_width);
  m_nZ = qMin(int(m_dataSize.x), m_height);
  m_crops = crops;
  m_paths = paths;
  m_pruneLod = pruneLod;
  m_pruneX = pruneX;
  m_pruneY = pruneY;
  m_pruneZ = pruneZ;
  m_pruneData = pruneData;
  m_tagColors = tagColors;
  m_samplingLevel = samplingLevel;

  // pruneLod that we get is wrt the original sized volume.
  // set pruneLod to reflect the selected sampling level.
  m_pruneLod = qMax((float)m_nX/(float)m_pruneZ,
		    qMax((float)m_nY/(float)m_pruneY,
			 (float)m_nZ/(float)m_pruneX));

//  QMessageBox::information(0, "", QString("%1 %2 %3\n%4 %5 %6\n%7").\
//			   arg(m_nX).arg(m_nY).arg(m_nZ).\
//			   arg(m_pruneZ).arg(m_pruneY).arg(m_pruneX).\
//			   arg(m_pruneLod));

  bool doBorder = false;
  if (qRound(m_dataSize.x) < m_height ||
      qRound(m_dataSize.y) < m_width ||
      qRound(m_dataSize.z) < m_depth)
    doBorder = true;
  if (clipPos.count() > 0 || m_crops.count() > 0 || m_paths.count() > 0)
    doBorder = true;

  int depth, fillValue;
  bool checkForMore;
  bool lookInside;
  QGradientStops stops;
  int chan;
  bool avgColor;
  if (! getValues(depth, fillValue,
		  checkForMore,
		  lookInside,
		  stops,
		  doBorder,
		  chan,
		  avgColor))
    return "";


  m_meshLog = new QTextEdit;
  m_meshProgress = new QProgressBar;

  QVBoxLayout *meshLayout = new QVBoxLayout;
  meshLayout->addWidget(m_meshLog);
  meshLayout->addWidget(m_meshProgress);

  QWidget *meshWindow = new QWidget;
  meshWindow->setWindowTitle("Drishti - Mesh Repainting Using Voxel Values");
  meshWindow->setLayout(meshLayout);
  meshWindow->show();
  meshWindow->resize(700, 300);


  float memGb = 0.5;
  memGb = QInputDialog::getDouble(0,
				  "Use memory",
				  "Max memory we can use (GB)", memGb, 0.1, 1000, 2);

  qint64 gb = 1024*1024*1024;
  qint64 memsize = memGb*gb; // max memory we can use (in GB)

  qint64 canhandle = memsize/15;
  qint64 gsize = qPow((double)canhandle, 0.333);

  m_meshLog->insertPlainText(QString("Can handle data with total grid size of %1 : typically %2^3\nOtherwise slabs method will be used.  Mesh is generated for each slab and then joined together.\n\n"). \
			   arg(canhandle).arg(gsize));


  m_meshLog->insertPlainText("\n\n");
  m_meshLog->insertPlainText(QString("Volume Size : %1 %2 %3\n").\
			   arg(m_depth).
			   arg(m_width).
			   arg(m_height));
  m_meshLog->insertPlainText(QString("DataMin : %1 %2 %3\n").\
			   arg(m_dataMin.z).
			   arg(m_dataMin.y).
			   arg(m_dataMin.x));
  m_meshLog->insertPlainText(QString("DataMax : %1 %2 %3\n").\
			   arg(m_dataMax.z).
			   arg(m_dataMax.y).
			   arg(m_dataMax.x));
  m_meshLog->insertPlainText(QString("DataSize : %1 %2 %3\n").\
			   arg(m_dataSize.z).
			   arg(m_dataSize.y).
			   arg(m_dataSize.x));
  m_meshLog->insertPlainText("\n\n");


  m_meshLog->insertPlainText(QString("Grid size : %1 %2 %3\n").\
			   arg(m_nX).arg(m_nY).arg(m_nZ));
  

  //---- import the mesh ---
  QString inflnm = QFileDialog::getOpenFileName(0,
						"Load mesh to repaint",
						prevDir,
						"*.ply");
  if (inflnm.size() == 0)
    {
      meshWindow->close();
      return "";
    }

  if (!loadPLY(inflnm))
    {
      meshWindow->close();
      return "";
    }
  //----------------------------

  //---- export the mesh ---
  QString outflnm = QFileDialog::getSaveFileName(0,
						 "Export mesh",
						 prevDir,
						 "*.ply");
  if (outflnm.size() == 0)
    {
      meshWindow->close();
      return "";
    }
  //----------------------------

  int nSlabs = 1;
  qint64 reqmem = m_nX;
  reqmem *= m_nY*m_nZ*20;
  nSlabs = qMax(qint64(1), reqmem/memsize + 1);
//  QMessageBox::information(0, "", QString("Number of Slabs : %1 : %2 %3").\
//			   arg(nSlabs).arg(reqmem).arg(memsize));

  QStringList volumeFiles;
#ifndef Q_OS_MACX
  volumeFiles = QFileDialog::getOpenFileNames(0,
					      "Load volume files for timeseries data, otherwise give CANCEL",
					      prevDir,
					      "NetCDF Files (*.pvl.nc)",
					      0,
					      QFileDialog::DontUseNativeDialog);
#else
  volumeFiles = QFileDialog::getOpenFileNames(0,
					      "Load volume files for timeseries data, otherwise give CANCEL",
					      prevDir,
					      "NetCDF Files (*.pvl.nc)",
					      0);
#endif

  int nvols = volumeFiles.count();      

  if (nvols == 0)
    volumeFiles << m_vfm->fileName();
  

  generateMesh(nSlabs,
	       volumeFiles,
	       outflnm,
	       depth,
	       stops,
	       fillValue,
	       checkForMore,
	       lookInside,
	       voxelScaling,
	       clipPos, clipNormal,
	       crops, paths,
	       lut,
	       chan,
	       avgColor);


  meshWindow->close();

  return outflnm;
}
Example #11
0
void QtWebDirectory::init() {
	setUrl(WsUrl::getWengoDirectoryUrl());
	QWidget * widget = (QWidget *) getWidget();
	widget->setWindowTitle(tr("@product@ - Directory"));
}
Example #12
0
//-----------------------------------------------------------------------------
int ctkLayoutManagerTest1(int argc, char * argv [] )
{
  QApplication app(argc, argv);

  QWidget viewport;
  viewport.setWindowTitle("Simple layout");
  ctkLayoutFactory layoutManager;

  layoutManager.setViewport(&viewport);
  if (layoutManager.viewport() != &viewport)
    {
    std::cerr << __LINE__ << ": ctkLayoutManager::setViewport() failed."
              << std::endl;
    return EXIT_FAILURE;
    }

  ctkTemplateLayoutViewFactory<QPushButton>* pButtonInstanciator=
    new ctkTemplateLayoutViewFactory<QPushButton>(&viewport);
  layoutManager.registerViewFactory(pButtonInstanciator);

  QDomDocument simpleLayoutDoc("simplelayout");
  bool res = simpleLayoutDoc.setContent(simpleLayout);
  Q_ASSERT(res);
  QDomDocument vboxLayoutDoc("vboxlayout");
  res = vboxLayoutDoc.setContent(vboxLayout);
  Q_ASSERT(res);
  QDomDocument gridLayoutDoc("gridlayout");
  res = gridLayoutDoc.setContent(gridLayout);
  Q_ASSERT(res);
  QDomDocument tabLayoutDoc("tablayout");
  res = tabLayoutDoc.setContent(tabLayout);
  Q_ASSERT(res);
  QDomDocument nestedLayoutDoc("nestedlayout");
  res = nestedLayoutDoc.setContent(nestedLayout);
  Q_ASSERT(res);

  layoutManager.setLayout(simpleLayoutDoc);
  if (layoutManager.layout() != simpleLayoutDoc)
    {
    std::cerr << __LINE__ << ": ctkLayoutFactory::setLayout() failed."
              << std::endl;
    return EXIT_FAILURE;
    }
  viewport.show();

  QWidget vbox;
  vbox.setWindowTitle("Vertical Box Layout");
  ctkLayoutFactory vboxLayoutManager;
  vboxLayoutManager.registerViewFactory(pButtonInstanciator);
  vboxLayoutManager.setLayout(vboxLayoutDoc);
  vboxLayoutManager.setViewport(&vbox);
  vbox.show();

  QWidget grid;
  grid.setWindowTitle("Grid Layout");
  ctkLayoutFactory gridLayoutManager;
  gridLayoutManager.registerViewFactory(pButtonInstanciator);
  gridLayoutManager.setLayout(gridLayoutDoc);
  gridLayoutManager.setViewport(&grid);
  grid.show();

  QWidget tab;
  tab.setWindowTitle("Tab Layout");
  ctkLayoutFactory tabLayoutManager;
  tabLayoutManager.registerViewFactory(pButtonInstanciator);
  tabLayoutManager.setLayout(tabLayoutDoc);
  tabLayoutManager.setViewport(&tab);
  tab.show();

  QWidget nested;
  nested.setWindowTitle("Nested Layout");
  ctkLayoutFactory nestedLayoutManager;
  nestedLayoutManager.registerViewFactory(pButtonInstanciator);
  nestedLayoutManager.setLayout(nestedLayoutDoc);
  nestedLayoutManager.setViewport(&nested);
  nested.show();

  // TabToGrid
  QWidget tabToGrid;
  tabToGrid.setWindowTitle("Tab to Grid Layout");
  ctkTemplateLayoutViewFactory<ctkSliderWidget>* tabToGridInstanciator =
    new ctkTemplateLayoutViewFactory<ctkSliderWidget>(&viewport);
  ctkLayoutFactory tabToGridLayoutManager;
  tabToGridLayoutManager.registerViewFactory(tabToGridInstanciator);
  tabToGridLayoutManager.setLayout(tabLayoutDoc);
  tabToGridLayoutManager.setViewport(&tabToGrid);
  tabToGrid.show();

  QTimer::singleShot(200, &app, SLOT(quit()));
  app.exec();

  tabToGridLayoutManager.setLayout(gridLayoutDoc);

  QTimer::singleShot(200, &app, SLOT(quit()));
  app.exec();

  if (tabToGridInstanciator->registeredViews().count() != 6 ||
      tabToGridInstanciator->registeredViews()[0]->isHidden() ||
      tabToGridInstanciator->registeredViews()[1]->isHidden() ||
      tabToGridInstanciator->registeredViews()[2]->isHidden() ||
      tabToGridInstanciator->registeredViews()[3]->isHidden())
    {
    std::cout << __LINE__ << " TabToGrid: "
              << "ctkLayoutManager::setupLayout() failed to show/hide widgets"
              << tabToGridInstanciator->registeredViews().count() << " "
              << tabToGridInstanciator->registeredViews()[0]->isHidden() << " "
              << tabToGridInstanciator->registeredViews()[1]->isHidden() << " "
              << tabToGridInstanciator->registeredViews()[2]->isHidden() << " "
              << tabToGridInstanciator->registeredViews()[3]->isHidden() << std::endl;
    return EXIT_FAILURE;
    }

  // TabToSimple
  QWidget tabToSimple;
  tabToSimple.setWindowTitle("Tab to Simple Layout");
  ctkTemplateLayoutViewFactory<ctkSliderWidget>* tabToSimpleInstanciator =
    new ctkTemplateLayoutViewFactory<ctkSliderWidget>(&viewport);
  ctkLayoutFactory tabToSimpleLayoutManager;
  tabToSimpleLayoutManager.registerViewFactory(tabToSimpleInstanciator);
  //tabToSimpleLayoutManager.setLayout(gridLayoutDoc);
  tabToSimpleLayoutManager.setLayout(tabLayoutDoc);
  tabToSimpleLayoutManager.setViewport(&tabToSimple);
  tabToSimple.show();

  QTimer::singleShot(200, &app, SLOT(quit()));
  app.exec();
  tabToSimpleLayoutManager.setLayout(simpleLayoutDoc);

  QTimer::singleShot(200, &app, SLOT(quit()));
  app.exec();

  if (tabToSimpleInstanciator->registeredViews().count() != 3 ||
      tabToSimpleInstanciator->registeredViews()[0]->isHidden() ||
      tabToSimpleInstanciator->registeredViews()[1]->isVisible() ||
      tabToSimpleInstanciator->registeredViews()[2]->isVisible())
    {
    std::cout << __LINE__ << " TabToSimple: "
              << "ctkLayoutManager::setupLayout() failed to show/hide widgets"
              << tabToSimpleInstanciator->registeredViews().count() << " "
              << tabToSimpleInstanciator->registeredViews()[0]->isHidden() << " "
              << tabToSimpleInstanciator->registeredViews()[1]->isVisible() << " "
              << tabToSimpleInstanciator->registeredViews()[2]->isVisible() << std::endl;
    return EXIT_FAILURE;
    }

  // NestedToTab
  QWidget nestedToTab;
  nestedToTab.setWindowTitle("Nested to Tab Layout");
  ctkTemplateLayoutViewFactory<ctkSliderWidget>* nestedToTabInstanciator =
    new ctkTemplateLayoutViewFactory<ctkSliderWidget>(&viewport);
  ctkLayoutFactory nestedToTabLayoutManager;
  nestedToTabLayoutManager.registerViewFactory(nestedToTabInstanciator);
  nestedToTabLayoutManager.setLayout(nestedLayoutDoc);
  nestedToTabLayoutManager.setViewport(&nestedToTab);
  nestedToTab.show();

  QTimer::singleShot(200, &app, SLOT(quit()));
  app.exec();

  nestedToTabLayoutManager.setLayout(tabLayoutDoc);

  QTimer::singleShot(200, &app, SLOT(quit()));
  app.exec();

  if (nestedToTabInstanciator->registeredViews()[0]->isHidden() ||
      nestedToTabInstanciator->registeredViews()[1]->isVisible() ||
      nestedToTabInstanciator->registeredViews()[2]->isVisible() ||
      nestedToTabInstanciator->registeredViews()[3]->isVisible())
    {
    std::cout << __LINE__ << " NestedToTab: "
              << "ctkLayoutManager::setupLayout() failed to show/hide widgets"
              << nestedToTabInstanciator->registeredViews()[0]->isHidden() << " "
              << nestedToTabInstanciator->registeredViews()[1]->isVisible() << " "
              << nestedToTabInstanciator->registeredViews()[2]->isVisible() << " "
              << nestedToTabInstanciator->registeredViews()[3]->isVisible() << std::endl;
    return EXIT_FAILURE;
    }


  if (argc < 2 || QString(argv[1]) != "-I" )
    {
    QTimer::singleShot(200, &app, SLOT(quit()));
    }

  return app.exec();
}
Example #13
0
//Delete everything that's based on settings, so we can change receivers, sound cards, etc
//ReceiverWidget initiates the power off and call us
bool Receiver::turnPowerOff()
{

	m_powerOn = false;

    //If we're closing app, don't bother to set title, crashes sometime
    QWidget *app = QApplication::activeWindow();
	if (app != NULL) {
		//Not Closing, just power off
        app->setWindowTitle("Pebble II");
	}

	if (m_sdrOptions != NULL)
		m_sdrOptions->showSdrOptions(m_sdr, false);

	if (m_isRecording) {
		m_recordingFile.Close();
		m_isRecording = false;
    }
	//Carefull with order of shutting down
	//if (settings->sdrDevice == DeviceInterface::SDR_IQ_USB) {
    //}

	//Stop incoming samples first
	if (m_sdr != NULL) {
		m_sdr->command(DeviceInterface::Cmd_Stop,0);
    }
	if (m_audioOutput != NULL)
		m_audioOutput->Stop();

	//m_iDigitalModem = NULL;

	//Now clean up rest
	if (m_sdr != NULL){
        //Save any run time settings
		m_sdr->set(DeviceInterface::Key_LastFrequency,m_frequency);
		m_sdr->command(DeviceInterface::Cmd_WriteSettings,0); //Always save last mode, last freq, etc

		m_sdr->command(DeviceInterface::Cmd_Disconnect,0);
		//Make sure SDR threads are fully stopped, otherwise processIQ objects below will crash in destructor
		//Active SDR object survives on/off and is kept in global.  Do not delete
		//delete sdr;
		m_sdr = NULL;
	}
	if (m_demodDecimator != NULL) {
		delete m_demodDecimator;
		m_demodDecimator = NULL;
	}
	if (m_demodWfmDecimator != NULL) {
		delete m_demodWfmDecimator;
		m_demodWfmDecimator = NULL;
	}
	if (m_demod != NULL) {
		delete m_demod;
		m_demod = NULL;
	}
	if (m_mixer != NULL) {
		delete m_mixer;
		m_mixer = NULL;
	}
	if (m_bpFilter != NULL) {
		delete m_bpFilter;
		m_bpFilter = NULL;
	}
	if (m_noiseBlanker != NULL) {
		delete m_noiseBlanker;
		m_noiseBlanker = NULL;
	}
	if (m_noiseFilter != NULL) {
		delete m_noiseFilter;
		m_noiseFilter = NULL;
	}

	if (m_signalStrength != NULL) {
		disconnect(m_signalStrength, SIGNAL(newSignalStrength(double,double,double,double,double)),
				   m_receiverWidget, SLOT(newSignalStrength(double,double,double,double,double)));
		delete m_signalStrength;
		m_signalStrength = NULL;
	}
	if (m_signalSpectrum != NULL) {
		delete m_signalSpectrum;
		m_signalSpectrum = NULL;
	}
	if (m_agc != NULL) {
		delete m_agc;
		m_agc = NULL;
	}
	if(m_iqBalance != NULL) {
		delete m_iqBalance;
		m_iqBalance=NULL;
	}
    //Making this last to work around a shut down order problem with consumer threads
	if (m_audioOutput != NULL) {
		delete m_audioOutput;
		m_audioOutput = NULL;
    }

#if(0)
	if (iqBalanceOptions != NULL) {
		if (iqBalanceOptions->isVisible()) {
			iqBalanceOptions->setHidden(true);
		}
		delete iqBalanceOptions;
		iqBalanceOptions = NULL;
	}
#endif

	if (m_workingBuf != NULL) {
		free (m_workingBuf);
		m_workingBuf = NULL;
    }
	if (m_sampleBuf != NULL) {
		free (m_sampleBuf);
		m_sampleBuf = NULL;
    }
	if (m_audioBuf != NULL) {
		free (m_audioBuf);
		m_audioBuf = NULL;
    }
	if (m_dbSpectrumBuf != NULL) {
		free (m_dbSpectrumBuf);
		m_dbSpectrumBuf = NULL;
	}
    return true;
}
Example #14
0
int main(int argc, char **argv)
{
    //! [0]
    QApplication app(argc, argv);
    Q3DScatter *graph = new Q3DScatter();
    QWidget *container = QWidget::createWindowContainer(graph);
    //! [0]

    QSize screenSize = graph->screen()->size();
    container->setMinimumSize(QSize(screenSize.width() / 2, screenSize.height() / 1.5));
    container->setMaximumSize(screenSize);
    container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    container->setFocusPolicy(Qt::StrongFocus);

    QWidget *widget = new QWidget;
    QHBoxLayout *hLayout = new QHBoxLayout(widget);
    QVBoxLayout *vLayout = new QVBoxLayout();
    hLayout->addWidget(container, 1);
    hLayout->addLayout(vLayout);
    vLayout->setAlignment(Qt::AlignTop);

    widget->setWindowTitle(QStringLiteral("A Galaxy"));

    QSlider *radiusGalaxySlider = new QSlider(Qt::Horizontal, widget);
    radiusGalaxySlider->setMinimum(1000);
    radiusGalaxySlider->setMaximum(40000);
    radiusGalaxySlider->setValue(15000);
    radiusGalaxySlider->setEnabled(true);

    QSlider *radiusCoreSlider = new QSlider(Qt::Horizontal, widget);
    radiusCoreSlider->setMinimum(1000);
    radiusCoreSlider->setMaximum(30000);
    radiusCoreSlider->setValue(4000);
    radiusCoreSlider->setEnabled(true);

    QSlider *angleOffsetSlider = new QSlider(Qt::Horizontal, widget);
    angleOffsetSlider->setMinimum(10);
    angleOffsetSlider->setMaximum(70);
    angleOffsetSlider->setValue(40);
    angleOffsetSlider->setEnabled(true);

    QSlider *eccentricityInnerSlider = new QSlider(Qt::Horizontal, widget);
    eccentricityInnerSlider->setMinimum(10);
    eccentricityInnerSlider->setMaximum(200);
    eccentricityInnerSlider->setValue(90);
    eccentricityInnerSlider->setEnabled(true);

    QSlider *eccentricityOuterSlider = new QSlider(Qt::Horizontal, widget);
    eccentricityOuterSlider->setMinimum(10);
    eccentricityOuterSlider->setMaximum(200);
    eccentricityOuterSlider->setValue(90);
    eccentricityOuterSlider->setEnabled(true);

    QCheckBox *staticCheckBox = new QCheckBox(widget);
    staticCheckBox->setText(QStringLiteral("Static"));
    staticCheckBox->setChecked(false);

    QCheckBox *starsCheckBox = new QCheckBox(widget);
    starsCheckBox->setText(QStringLiteral("Stars"));
    starsCheckBox->setChecked(true);

    QCheckBox *dustCheckBox = new QCheckBox(widget);
    dustCheckBox->setText(QStringLiteral("Dust"));
    dustCheckBox->setChecked(true);

    QCheckBox *H2CheckBox = new QCheckBox(widget);
    H2CheckBox->setText(QStringLiteral("H2"));
    H2CheckBox->setChecked(true);

    QPushButton *resetButton = new QPushButton(widget);
    resetButton->setText(QStringLiteral("Reset values"));

    QCheckBox *filteredCheckBox = new QCheckBox(widget);
    filteredCheckBox->setText(QStringLiteral("Filtered"));
    filteredCheckBox->setChecked(false);

    QLabel *fpsLabel = new QLabel(QStringLiteral(""));

    vLayout->addWidget(new QLabel(QStringLiteral("Galaxy radius")));
    vLayout->addWidget(radiusGalaxySlider);
    vLayout->addWidget(new QLabel(QStringLiteral("Core radius")));
    vLayout->addWidget(radiusCoreSlider);
    vLayout->addWidget(new QLabel(QStringLiteral("Angle offset")));
    vLayout->addWidget(angleOffsetSlider);
    vLayout->addWidget(new QLabel(QStringLiteral("Eccentricity inner")));
    vLayout->addWidget(eccentricityInnerSlider);
    vLayout->addWidget(new QLabel(QStringLiteral("Eccentricity outer")));
    vLayout->addWidget(eccentricityOuterSlider);
    vLayout->addWidget(staticCheckBox);
    vLayout->addWidget(starsCheckBox);
    vLayout->addWidget(dustCheckBox);
    vLayout->addWidget(H2CheckBox);
    vLayout->addWidget(resetButton);
    vLayout->addWidget(filteredCheckBox);
    vLayout->addWidget(fpsLabel);

    GalaxyData *modifier = new GalaxyData(graph);

    QObject::connect(radiusGalaxySlider, &QSlider::valueChanged,
                     modifier, &GalaxyData::radiusGalaxyChanged);
    QObject::connect(radiusCoreSlider, &QSlider::valueChanged,
                     modifier, &GalaxyData::radiusCoreChanged);
    QObject::connect(angleOffsetSlider, &QSlider::valueChanged,
                     modifier, &GalaxyData::angleOffsetChanged);
    QObject::connect(eccentricityInnerSlider, &QSlider::valueChanged,
                     modifier, &GalaxyData::eccentricityInnerChanged);
    QObject::connect(eccentricityOuterSlider, &QSlider::valueChanged,
                     modifier, &GalaxyData::eccentricityOuterChanged);
    QObject::connect(resetButton, &QPushButton::clicked,
                     modifier, &GalaxyData::resetValues);
    QObject::connect(filteredCheckBox, &QCheckBox::stateChanged,
                     modifier, &GalaxyData::setFilteredEnabled);
    QObject::connect(staticCheckBox, &QCheckBox::stateChanged,
                     modifier, &GalaxyData::setStaticEnabled);
    QObject::connect(starsCheckBox, &QCheckBox::stateChanged,
                     modifier, &GalaxyData::setStarsVisible);
    QObject::connect(dustCheckBox, &QCheckBox::stateChanged,
                     modifier, &GalaxyData::setDustVisible);
    QObject::connect(H2CheckBox, &QCheckBox::stateChanged,
                     modifier, &GalaxyData::setH2Visible);

    modifier->setSliders(radiusGalaxySlider, radiusCoreSlider, angleOffsetSlider,
                         eccentricityInnerSlider, eccentricityOuterSlider);
    modifier->setFpsLabel(fpsLabel);

    widget->show();
    return app.exec();
}
Example #15
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    ToDoListModel model;

    // Labels with totals

    QLabel * lcEffort = new QLabel;
    TotalEstimateLabel * lEffort = new TotalEstimateLabel;
    lcEffort->setText("Total Effort");
    QObject::connect(&model, SIGNAL(totalEffortChanged(int)),
                     lEffort, SLOT(setTotalEstimate(int)));


    QLabel * lcEstimated = new QLabel();
    TotalEstimateLabel * lEstimated = new TotalEstimateLabel();
    lcEstimated->setText("Estimated Effort");
    QObject::connect(&model, SIGNAL(totalEstimateChanged(int)),
                     lEstimated, SLOT(setTotalEstimate(int)));


    QFormLayout * form1 = new QFormLayout;
    form1->addRow(lcEffort, lEffort);
    form1->addRow(lcEstimated, lEstimated);

    // Table with tasks

    QTableView *table = new QTableView;

    // TODO enable drag and drop for moving cells
    table->setDragEnabled(true);
    table->viewport()->setAcceptDrops(true);
    table->setDropIndicatorShown(true);
    table->setDragDropMode(QAbstractItemView::InternalMove);

    // Init model after the signal is set.

    QList<ToDoItem> tasks;
    for (int row = 0; row < 100; ++row) {
       ToDoItem ti;
       ti.name = QString("Task %0").arg(row + 1);
       ti.estimated_minutes = row + 1;
       ti.was_done = false;
       tasks.append(ti);
    }
    model.appendTasks(tasks);

    // NOTE: add now the model, otherwise the table does not show data.
    table->setModel(&model);

    // Add widgets to the main layout
    QVBoxLayout *layout = new QVBoxLayout;
    layout->addLayout(form1);
    layout->addWidget(table);

    // Create main window
    QWidget window;
    window.setLayout(layout);
    window.setWindowTitle("Lazy GUI Chooser - QT");
    window.show();

    return app.exec();
}
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),

    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    QPushButton *buttonUp = new QPushButton(this);
    QPushButton *buttonDown = new QPushButton;
    QPushButton *buttonLeft = new QPushButton;
    QPushButton *buttonRight = new QPushButton;

    this->gridLayout = new QGridLayout;

    this->boardBoundX = 11;
    this->boardBoundY = 11;

    this->_curX = 0;
    this->_curY = this->boardBoundY;

    for (int y = 0; y <= this->boardBoundY; y++) {
        for (int x = 0; x <= this->boardBoundX; x++) {
            QLabel *textBlock = new QLabel;

            if (x == 0 && y == this->boardBoundY)
                textBlock->setText("<span style='color:red'>X</span>");
            else {
                textBlock->setText(QString("<span style='color:black'>%1</span>").arg(this->boardMatrix[y][x]));
            }
            gridLayout->addWidget(textBlock, y, x, 1, 1, Qt::AlignCenter);
        }
    }


    buttonUp->setText("UP");
    buttonDown->setText("DOWN");
    buttonLeft->setText("LEFT");
    buttonRight->setText("RIGHT");

    QSignalMapper *signalMapper = new QSignalMapper(this);
    QObject::connect(signalMapper, SIGNAL(mapped(int)), this, SLOT(moveCharacter(int)));
    QObject::connect(buttonUp, SIGNAL(clicked()), signalMapper, SLOT(map()));
    QObject::connect(buttonDown, SIGNAL(clicked()), signalMapper, SLOT(map()));
    QObject::connect(buttonLeft, SIGNAL(clicked()), signalMapper, SLOT(map()));
    QObject::connect(buttonRight, SIGNAL(clicked()), signalMapper, SLOT(map()));

    signalMapper->setMapping(buttonUp, MOVE_UP);
    signalMapper->setMapping(buttonDown, MOVE_DOWN);
    signalMapper->setMapping(buttonLeft, MOVE_LEFT);
    signalMapper->setMapping(buttonRight, MOVE_RIGHT);

    gridLayout->addWidget(buttonUp, this->boardBoundY + 1, 0, 1, 3, Qt::AlignCenter);
    gridLayout->addWidget(buttonDown, this->boardBoundY + 1, 3, 1, 3, Qt::AlignCenter);
    gridLayout->addWidget(buttonLeft, this->boardBoundY + 1, 6, 1, 3, Qt::AlignCenter);
    gridLayout->addWidget(buttonRight, this->boardBoundY + 1, 9, 1, 3, Qt::AlignCenter);

    QWidget *mainWidget = new QWidget;
    mainWidget->setLayout(gridLayout);
    mainWidget->setWindowTitle("Test");

    if (this->centralWidget())
        this->centralWidget()->setParent(0); // Preserve current central widget
    this->setCentralWidget(mainWidget);

}
Example #17
0
void VstPlugin::createUI( QWidget * parent )
{
	if ( m_pluginWidget ) {
		qWarning() << "VstPlugin::createUI called twice";
		m_pluginWidget->setParent( parent );
		return;
	}

	if( m_pluginWindowID == 0 )
	{
		return;
	}

	QWidget* container = nullptr;

#if QT_VERSION >= 0x050100
	if (m_embedMethod == "qt" )
	{
		QWindow* vw = QWindow::fromWinId(m_pluginWindowID);
		container = QWidget::createWindowContainer(vw, parent );
		container->installEventFilter(this);
	} else
#endif

#ifdef LMMS_BUILD_WIN32
	if (m_embedMethod == "win32" )
	{
		QWidget * helper = new QWidget;
		QHBoxLayout * l = new QHBoxLayout( helper );
		QWidget * target = new QWidget( helper );
		l->setSpacing( 0 );
		l->setMargin( 0 );
		l->addWidget( target );

		// we've to call that for making sure, Qt created the windows
		helper->winId();
		HWND targetHandle = (HWND)target->winId();
		HWND pluginHandle = (HWND)(intptr_t)m_pluginWindowID;

		DWORD style = GetWindowLong(pluginHandle, GWL_STYLE);
		style = style & ~(WS_POPUP);
		style = style | WS_CHILD;
		SetWindowLong(pluginHandle, GWL_STYLE, style);
		SetParent(pluginHandle, targetHandle);

		DWORD threadId = GetWindowThreadProcessId(pluginHandle, NULL);
		DWORD currentThreadId = GetCurrentThreadId();
		AttachThreadInput(currentThreadId, threadId, true);

		container = helper;
		RemotePlugin::showUI();

	} else
#endif

#ifdef LMMS_BUILD_LINUX
	if (m_embedMethod == "xembed" )
	{
		if (parent)
		{
			parent->setAttribute(Qt::WA_NativeWindow);
		}
		QX11EmbedContainer * embedContainer = new QX11EmbedContainer( parent );
		connect(embedContainer, SIGNAL(clientIsEmbedded()), this, SLOT(handleClientEmbed()));
		embedContainer->embedClient( m_pluginWindowID );
		container = embedContainer;
	} else
#endif
	{
		qCritical() << "Unknown embed method" << m_embedMethod;
		return;
	}

	container->setFixedSize( m_pluginGeometry );
	container->setWindowTitle( name() );

	m_pluginWidget = container;
}
Example #18
0
void TaskbarPreviews::setTabTitle(unsigned tabid, const QString &title)
{
	QWidget *w = m_tabs.internal(tabid);
	if (w)
		w->setWindowTitle(title);
}
Example #19
0
BpdeMainWindow::BpdeMainWindow(RInside& R, const QString& sourceFile, QObject *parent)
    : R(R),
    sourceFile(sourceFile), x(), y(), H(), solver(NULL)
{
    tempfile = QString::fromStdString(Rcpp::as<std::string>(R.parseEval("tfile <- tempfile()")));
    svgfile = QString::fromStdString(Rcpp::as<std::string>(R.parseEval("sfile <- tempfile()")));

    QWidget *window = new QWidget;
    window->setWindowTitle("BpdeGUI");
    setCentralWidget(window);

    QGroupBox *runParameters = new QGroupBox("Параметры запуска");
    openMPEnabled = new QRadioButton("&OpenMP");
    openClEnabled = new QRadioButton("&OpenCL");

    openMPEnabled->setChecked(true);

    connect(openMPEnabled, SIGNAL(clicked()), this, SLOT(loadSource()));
    connect(openClEnabled, SIGNAL(clicked()), this, SLOT(loadSource()));

    QVBoxLayout *vbox = new QVBoxLayout;
    vbox->addWidget(openMPEnabled);
    vbox->addWidget(openClEnabled);


    QLabel *threadsLabel = new QLabel("Количество потоков");
    threadsLineEdit = new QLineEdit("4");
    QHBoxLayout *threadNumber = new QHBoxLayout;
    threadNumber->addWidget(threadsLabel);
    threadNumber->addWidget(threadsLineEdit);

    QHBoxLayout *deviceLayout = new QHBoxLayout;
    QLabel *deviceLabel = new QLabel("Устройство");
    deviceComboBox = new QComboBox();

    scanDevices();
    for (std::vector<cl::Device>::iterator it = devices.begin(); it != devices.end(); it++)
        deviceComboBox->addItem((*it).getInfo<CL_DEVICE_NAME>().c_str());

    connect(deviceComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(loadSource()));

    deviceLayout->addWidget(deviceLabel);
    deviceLayout->addWidget(deviceComboBox);

    QHBoxLayout* runLayout = new QHBoxLayout;
    runButton = new QPushButton("Начать вычисления", this);
    qDebug() << "Connect : " <<
    connect(runButton, SIGNAL(clicked()), this, SLOT(solve()));
    runLayout->addWidget(runButton);

    QVBoxLayout* ulLayout = new QVBoxLayout;
    ulLayout->addLayout(vbox);
    ulLayout->addLayout(threadNumber);
    ulLayout->addLayout(deviceLayout);
    ulLayout->addLayout(runLayout);

    runParameters->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    runParameters->setLayout(ulLayout);

    QButtonGroup *kernelGroup = new QButtonGroup;
    kernelGroup->addButton(openMPEnabled, 0);
    kernelGroup->addButton(openClEnabled, 1);

    QGroupBox *solveParamBox = new QGroupBox("Настройки вычислительного метода");

    QHBoxLayout *iterationsLayout = new QHBoxLayout;
    QHBoxLayout *stepLayout = new QHBoxLayout;
    QLabel *sourceFileLabel = new QLabel("SourceFile");
    sourceFileEdit = new QLineEdit(sourceFile);
    iterationsEdit = new QLineEdit("10000");
    stepEdit = new QLineEdit("3600");
    QLabel *iterationsLabel = new QLabel("Итерации");
    QLabel *stepLabel = new QLabel("Шаг            ");
    QHBoxLayout *exportLayout = new QHBoxLayout;
    exportImage = new QPushButton("Экспорт изотерм");
    export3D = new QPushButton("Экспорт 3D модели");
    connect(exportImage, SIGNAL(clicked()), this, SLOT(exportIsoterms()));
    connect(export3D, SIGNAL(clicked()), this, SLOT(export3DModel()));

    iterationsLayout->addWidget(iterationsLabel);
    iterationsLayout->addWidget(iterationsEdit);
    stepLayout->addWidget(stepLabel);
    stepLayout->addWidget(stepEdit);

    exportLayout->addWidget(exportImage);
    exportLayout->addWidget(export3D);

    svg = new QSvgWidget();
    loadSource();

    QVBoxLayout *solveParamLayout = new QVBoxLayout;
    solveParamLayout->addWidget(sourceFileLabel);
    solveParamLayout->addWidget(sourceFileEdit);
    solveParamLayout->addLayout(iterationsLayout);
    solveParamLayout->addLayout(stepLayout);
    solveParamLayout->addLayout(exportLayout);

    solveParamBox->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    solveParamBox->setLayout(solveParamLayout);

    QHBoxLayout *upperlayout = new QHBoxLayout;
    upperlayout->addWidget(runParameters);
    upperlayout->addWidget(solveParamBox);

    QHBoxLayout *lowerlayout = new QHBoxLayout;
    lowerlayout->addWidget(svg);

    QVBoxLayout *outer = new QVBoxLayout;
    outer->addLayout(upperlayout);
    outer->addLayout(lowerlayout);
    window->setLayout(outer);
}
Example #20
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    {
//! [0]
    QWidget *window = new QWidget;
//! [0] //! [1]
    QPushButton *button1 = new QPushButton("One");
//! [1] //! [2]
    QPushButton *button2 = new QPushButton("Two");
    QPushButton *button3 = new QPushButton("Three");
    QPushButton *button4 = new QPushButton("Four");
    QPushButton *button5 = new QPushButton("Five");
//! [2]

//! [3]
    QHBoxLayout *layout = new QHBoxLayout;
//! [3] //! [4]
    layout->addWidget(button1);
    layout->addWidget(button2);
    layout->addWidget(button3);
    layout->addWidget(button4);
    layout->addWidget(button5);

    window->setLayout(layout);
//! [4]
    window->setWindowTitle("QHBoxLayout");
//! [5]
    window->show();
//! [5]
    }
    
    {
//! [6]
    QWidget *window = new QWidget;
//! [6] //! [7]
    QPushButton *button1 = new QPushButton("One");
//! [7] //! [8]
    QPushButton *button2 = new QPushButton("Two");
    QPushButton *button3 = new QPushButton("Three");
    QPushButton *button4 = new QPushButton("Four");
    QPushButton *button5 = new QPushButton("Five");
//! [8]

//! [9]
    QVBoxLayout *layout = new QVBoxLayout;
//! [9] //! [10]
    layout->addWidget(button1);
    layout->addWidget(button2);
    layout->addWidget(button3);
    layout->addWidget(button4);
    layout->addWidget(button5);

    window->setLayout(layout);
//! [10]
    window->setWindowTitle("QVBoxLayout");
//! [11]
    window->show();
//! [11]
    }
    
    {
//! [12]
    QWidget *window = new QWidget;
//! [12] //! [13]
    QPushButton *button1 = new QPushButton("One");
//! [13] //! [14]
    QPushButton *button2 = new QPushButton("Two");
    QPushButton *button3 = new QPushButton("Three");
    QPushButton *button4 = new QPushButton("Four");
    QPushButton *button5 = new QPushButton("Five");
//! [14]

//! [15]
    QGridLayout *layout = new QGridLayout;
//! [15] //! [16]
    layout->addWidget(button1, 0, 0);
    layout->addWidget(button2, 0, 1);
    layout->addWidget(button3, 1, 0, 1, 2);
    layout->addWidget(button4, 2, 0);
    layout->addWidget(button5, 2, 1);

    window->setLayout(layout);
//! [16]
    window->setWindowTitle("QGridLayout");
//! [17]
    window->show();
//! [17]
    }

    {
//! [18]
    QWidget *window = new QWidget;
//! [18]
//! [19]
    QPushButton *button1 = new QPushButton("One");
    QLineEdit *lineEdit1 = new QLineEdit();
//! [19]
//! [20]
    QPushButton *button2 = new QPushButton("Two");
    QLineEdit *lineEdit2 = new QLineEdit();
    QPushButton *button3 = new QPushButton("Three");
    QLineEdit *lineEdit3 = new QLineEdit();
//! [20]
//! [21]
    QFormLayout *layout = new QFormLayout;
//! [21]
//! [22]
    layout->addRow(button1, lineEdit1);
    layout->addRow(button2, lineEdit2);
    layout->addRow(button3, lineEdit3);

    window->setLayout(layout);
//! [22]
    window->setWindowTitle("QFormLayout");
//! [23]
    window->show();
//! [23]    
    }

    return app.exec();
}
Example #21
0
void ADHighAccuracy::on_settings_clicked()
{
    QWidget *newWidget = test->getPTAppBckPsoc();
    newWidget->setWindowTitle("AppCard BackPanel PSoC Panel");
    newWidget->show();
}
Example #22
0
int drv_widget(int drvid, void *a0, void* a1, void* a2, void* a3, void* a4, void* a5, void* a6, void* a7, void* a8, void* a9)
{
    handle_head* head = (handle_head*)a0;
    QWidget *self = (QWidget*)head->native;
    switch (drvid) {
    case WIDGET_INIT: {
        drvNewObj(a0,new QWidget);
        break;
    }
    case WIDGET_DESTROY: {
        drvDelObj(a0,self);
        break;
    }
    case WIDGET_SETAUTODESTROY: {
        self->setAttribute(Qt::WA_DeleteOnClose,drvGetBool(a1));
        break;
    }
    case WIDGET_AUTODESTROY: {
        drvSetBool(a1,self->testAttribute(Qt::WA_DeleteOnClose));
        break;
    }
    case WIDGET_SETLAYOUT: {
        self->setLayout(drvGetLayout(a1));
        break;
    }
    case WIDGET_LAYOUT: {
        drvSetHandle(a1,self->layout());
        break;
    }
    case WIDGET_SETPARENT: {
        self->setParent(drvGetWidget(a1));
        break;
    }
    case WIDGET_PARENT: {
        drvSetHandle(a1,self->parent());
        break;
    }
    case WIDGET_SETVISIBLE: {
        self->setVisible(drvGetBool(a1));
        break;
    }
    case WIDGET_ISVISIBLE: {
        drvSetBool(a1,self->isVisible());
        break;
    }
    case WIDGET_SETWINDOWTITLE: {
        self->setWindowTitle(drvGetString(a1));
        break;
    }
    case WIDGET_WINDOWTITLE: {
        drvSetString(a1,self->windowTitle());
        break;
    }
    case WIDGET_SETPOS: {
        self->move(drvGetPoint(a1));
        break;
    }
    case WIDGET_POS: {
        drvSetPoint(a1,self->pos());
        break;
    }
    case WIDGET_SETSIZE: {
        self->resize(drvGetSize(a1));
        break;
    }
    case WIDGET_SIZE: {
        drvSetSize(a1,self->size());
        break;
    }
    case WIDGET_SETGEOMETRY: {
        self->setGeometry(drvGetRect(a1));
        break;
    }
    case WIDGET_GEOMETRY: {
        drvSetRect(a1,self->geometry());
        break;
    }
    case WIDGET_SETFONT: {
        self->setFont(drvGetFont(a1));
        break;
    }
    case WIDGET_FONT: {
        drvSetFont(a1,self->font());
        break;
    }
    case WIDGET_CLOSE: {
        self->close();
        break;
    }
    case WIDGET_UPDATE: {
        self->update();
        break;
    }
    case WIDGET_REPAINT: {
        self->repaint();
        break;
    }
    case WIDGET_ONSHOWEVENT: {
        drvNewEvent(QEvent::Show,a0,a1,a2);
        break;
    }
    case WIDGET_ONHIDEEVENT: {
        drvNewEvent(QEvent::Hide,a0,a1,a2);
        break;
    }
    case WIDGET_ONCLOSEEVENT: {
        drvNewEvent(QEvent::Close,a0,a1,a2);
        break;
    }
    case WIDGET_ONKEYPRESSEVENT: {
        drvNewEvent(QEvent::KeyPress,a0,a1,a2);
        break;
    }
    case WIDGET_ONKEYRELEASEEVENT: {
        drvNewEvent(QEvent::KeyRelease,a0,a1,a2);
        break;
    }
    case WIDGET_ONMOUSEPRESSEVENT: {
        drvNewEvent(QEvent::MouseButtonPress,a0,a1,a2);
        break;
    }
    case WIDGET_ONMOUSERELEASEEVENT: {
        drvNewEvent(QEvent::MouseButtonRelease,a0,a1,a2);
        break;
    }
    case WIDGET_ONMOUSEMOVEEVENT: {
        drvNewEvent(QEvent::MouseMove,a0,a1,a2);
        break;
    }
    case WIDGET_ONMOUSEDOUBLECLICKEVENT: {
        drvNewEvent(QEvent::MouseButtonDblClick,a0,a1,a2);
        break;
    }
    case WIDGET_ONMOVEEVENT: {
        drvNewEvent(QEvent::Move,a0,a1,a2);
        break;
    }
    case WIDGET_ONPAINTEVENT: {
        drvNewEvent(QEvent::Paint,a0,a1,a2);
        break;
    }
    case WIDGET_ONRESIZEEVENT: {
        drvNewEvent(QEvent::Resize,a0,a1,a2);
        break;
    }
    case WIDGET_ONENTEREVENT: {
        drvNewEvent(QEvent::Enter,a0,a1,a2);
        break;
    }
    case WIDGET_ONLEAVEEVENT: {
        drvNewEvent(QEvent::Leave,a0,a1,a2);
        break;
    }
    case WIDGET_ONFOCUSINEVENT: {
        drvNewEvent(QEvent::FocusIn,a0,a1,a2);
        break;
    }
    case WIDGET_ONFOCUSOUTEVENT: {
        drvNewEvent(QEvent::FocusOut,a0,a1,a2);
        break;
    }
    default:
        return 0;
    }
    return 1;
}
Example #23
0
int main(int argc, char *argv[])
{

/************************************************* example as a standalone window ************************************************************/
/*	
	//create an application
	QApplication app(argc, argv);					
   
	// create and fill the data vector
	QVector<QPointF> data1;
	for (float i=0;i<20;i+=0.1)
		data1.append(QPointF(i,sin(i)));

	// create and fill another data vector
	QVector<QPointF> data2;
	for (float i=0;i<20;i+=0.1)
		data2.append(QPointF(i,sin(i/2)));

	//creat the plotter and set its data
	Plotter *plotter = new Plotter;							// create a plotter
	plotter->setPlotSettings(PlotSettings(0,20,-2,2));		//initialise the axis
	plotter->setCurveData(0,data1);							//set the first plotter data set
	plotter->setCurveData(1,data2);							//set the second plotter data set
	
	//show the plotter widget
	plotter->show();										
    
	//execute the application
	return app.exec();						
*/
/*********************************************************************************************************************************************/


/******************************************** example of use as a widget among others *********************************************************/
	
	//create an application
	QApplication app(argc, argv);				

	// create a window
    QWidget *window = new QWidget;
	window->setWindowTitle("Plotter widget application");

	// create a label
	QLabel *label = new QLabel("<h2><i><font color=blue> Plot example </font> </i></h2>");
	
	//create the plotter and its data
	Plotter *plotter = new Plotter;	
	plotter->setPlotSettings(PlotSettings(0,20,-2,2));		
	
	QVector<QPointF> data1;
	for (float i=0;i<20;i+=0.1)
		data1.append(QPointF(i,sin(i)));
	QVector<QPointF> data2;
	for (float i=0;i<20;i+=0.1)
		data2.append(QPointF(i,sin(i/2)));
	
	plotter->setCurveData(0,data1);							
	plotter->setCurveData(1,data2);							
	

	//layout the widgets
	QVBoxLayout *layout = new QVBoxLayout;
	layout -> addWidget (label);
	layout -> addWidget (plotter);
	window->setLayout(layout);
	
	//show the window
	window->show();

	//execute the application
	return app.exec();	
	
/*********************************************************************************************************************************************/


}
Example #24
0
int main(int argc, char **argv)
{
    //! [0]
    QApplication app(argc, argv);
    Q3DScatter *graph = new Q3DScatter();
    QWidget *container = QWidget::createWindowContainer(graph);
    //! [0]

    if (!graph->hasContext()) {
        QMessageBox msgBox;
        msgBox.setText("Couldn't initialize the OpenGL context.");
        msgBox.exec();
        return -1;
    }

    QSize screenSize = graph->screen()->size();
    container->setMinimumSize(QSize(screenSize.width() / 2, screenSize.height() / 1.5));
    container->setMaximumSize(screenSize);
    container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    container->setFocusPolicy(Qt::StrongFocus);

    //! [1]
    QWidget *widget = new QWidget;
    QHBoxLayout *hLayout = new QHBoxLayout(widget);
    QVBoxLayout *vLayout = new QVBoxLayout();
    hLayout->addWidget(container, 1);
    hLayout->addLayout(vLayout);
    //! [1]

    widget->setWindowTitle(QStringLiteral("A Cosine Wave"));

    //! [4]
    QComboBox *themeList = new QComboBox(widget);
    themeList->addItem(QStringLiteral("Qt"));
    themeList->addItem(QStringLiteral("Primary Colors"));
    themeList->addItem(QStringLiteral("Digia"));
    themeList->addItem(QStringLiteral("Stone Moss"));
    themeList->addItem(QStringLiteral("Army Blue"));
    themeList->addItem(QStringLiteral("Retro"));
    themeList->addItem(QStringLiteral("Ebony"));
    themeList->addItem(QStringLiteral("Isabelle"));
    themeList->setCurrentIndex(6);

    QPushButton *labelButton = new QPushButton(widget);
    labelButton->setText(QStringLiteral("Change label style"));

    QCheckBox *smoothCheckBox = new QCheckBox(widget);
    smoothCheckBox->setText(QStringLiteral("Smooth dots"));
    smoothCheckBox->setChecked(true);

    QComboBox *itemStyleList = new QComboBox(widget);
    itemStyleList->addItem(QStringLiteral("Sphere"), int(QAbstract3DSeries::MeshSphere));
    itemStyleList->addItem(QStringLiteral("Cube"), int(QAbstract3DSeries::MeshCube));
    itemStyleList->addItem(QStringLiteral("Minimal"), int(QAbstract3DSeries::MeshMinimal));
    itemStyleList->addItem(QStringLiteral("Point"), int(QAbstract3DSeries::MeshPoint));
    itemStyleList->setCurrentIndex(0);

    QPushButton *cameraButton = new QPushButton(widget);
    cameraButton->setText(QStringLiteral("Change camera preset"));

    QPushButton *itemCountButton = new QPushButton(widget);
    itemCountButton->setText(QStringLiteral("Toggle item count"));

    QCheckBox *backgroundCheckBox = new QCheckBox(widget);
    backgroundCheckBox->setText(QStringLiteral("Show background"));
    backgroundCheckBox->setChecked(true);

    QCheckBox *gridCheckBox = new QCheckBox(widget);
    gridCheckBox->setText(QStringLiteral("Show grid"));
    gridCheckBox->setChecked(true);

    QComboBox *shadowQuality = new QComboBox(widget);
    shadowQuality->addItem(QStringLiteral("None"));
    shadowQuality->addItem(QStringLiteral("Low"));
    shadowQuality->addItem(QStringLiteral("Medium"));
    shadowQuality->addItem(QStringLiteral("High"));
    shadowQuality->addItem(QStringLiteral("Low Soft"));
    shadowQuality->addItem(QStringLiteral("Medium Soft"));
    shadowQuality->addItem(QStringLiteral("High Soft"));
    shadowQuality->setCurrentIndex(4);

    QFontComboBox *fontList = new QFontComboBox(widget);
    fontList->setCurrentFont(QFont("Arial"));
    //! [4]

    //! [5]
    vLayout->addWidget(labelButton, 0, Qt::AlignTop);
    vLayout->addWidget(cameraButton, 0, Qt::AlignTop);
    vLayout->addWidget(itemCountButton, 0, Qt::AlignTop);
    vLayout->addWidget(backgroundCheckBox);
    vLayout->addWidget(gridCheckBox);
    vLayout->addWidget(smoothCheckBox, 0, Qt::AlignTop);
    vLayout->addWidget(new QLabel(QStringLiteral("Change dot style")));
    vLayout->addWidget(itemStyleList);
    vLayout->addWidget(new QLabel(QStringLiteral("Change theme")));
    vLayout->addWidget(themeList);
    vLayout->addWidget(new QLabel(QStringLiteral("Adjust shadow quality")));
    vLayout->addWidget(shadowQuality);
    vLayout->addWidget(new QLabel(QStringLiteral("Change font")));
    vLayout->addWidget(fontList, 1, Qt::AlignTop);
    //! [5]

    //! [2]
    ScatterDataModifier *modifier = new ScatterDataModifier(graph);
    //! [2]

    //! [6]
    QObject::connect(cameraButton, &QPushButton::clicked, modifier,
                     &ScatterDataModifier::changePresetCamera);
    QObject::connect(labelButton, &QPushButton::clicked, modifier,
                     &ScatterDataModifier::changeLabelStyle);
    QObject::connect(itemCountButton, &QPushButton::clicked, modifier,
                     &ScatterDataModifier::toggleItemCount);

    QObject::connect(backgroundCheckBox, &QCheckBox::stateChanged, modifier,
                     &ScatterDataModifier::setBackgroundEnabled);
    QObject::connect(gridCheckBox, &QCheckBox::stateChanged, modifier,
                     &ScatterDataModifier::setGridEnabled);
    QObject::connect(smoothCheckBox, &QCheckBox::stateChanged, modifier,
                     &ScatterDataModifier::setSmoothDots);

    QObject::connect(modifier, &ScatterDataModifier::backgroundEnabledChanged,
                     backgroundCheckBox, &QCheckBox::setChecked);
    QObject::connect(modifier, &ScatterDataModifier::gridEnabledChanged,
                     gridCheckBox, &QCheckBox::setChecked);
    QObject::connect(itemStyleList, SIGNAL(currentIndexChanged(int)), modifier,
                     SLOT(changeStyle(int)));

    QObject::connect(themeList, SIGNAL(currentIndexChanged(int)), modifier,
                     SLOT(changeTheme(int)));

    QObject::connect(shadowQuality, SIGNAL(currentIndexChanged(int)), modifier,
                     SLOT(changeShadowQuality(int)));

    QObject::connect(modifier, &ScatterDataModifier::shadowQualityChanged, shadowQuality,
                     &QComboBox::setCurrentIndex);
    QObject::connect(graph, &Q3DScatter::shadowQualityChanged, modifier,
                     &ScatterDataModifier::shadowQualityUpdatedByVisual);

    QObject::connect(fontList, &QFontComboBox::currentFontChanged, modifier,
                     &ScatterDataModifier::changeFont);

    QObject::connect(modifier, &ScatterDataModifier::fontChanged, fontList,
                     &QFontComboBox::setCurrentFont);
    //! [6]

    //! [3]
    widget->show();
    return app.exec();
    //! [3]
}
Example #25
0
int main(int argc, char **argv)
{

    QApplication app(argc, argv);

    // Initializing the graph and its container
    Q3DScatter *graph = new Q3DScatter();
    QWidget *container = QWidget::createWindowContainer(graph);
    //! [0]

    QSize screenSize = graph->screen()->size();
    container->setMinimumSize(QSize(screenSize.width() / 2.25, screenSize.height() / 4));
    container->setMaximumSize(screenSize);
    container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    container->setFocusPolicy(Qt::StrongFocus);

    //! [1]
    QWidget *widget = new QWidget;
    QGroupBox *menuLayout = new QGroupBox;
    QGroupBox *optionLayout = new QGroupBox;
    QVBoxLayout *vLayout = new QVBoxLayout(widget);
    vLayout->addWidget(menuLayout);
    vLayout->addWidget(container, 1);
    vLayout->addWidget(optionLayout);
    //! [1]

    widget->setWindowTitle(QStringLiteral("CRN Dava Visualization"));

    //! [4]
    /*
    QComboBox *themeList = new QComboBox(widget);
    themeList->addItem(QStringLiteral("Qt"));
    themeList->addItem(QStringLiteral("Primary Colors"));
    themeList->addItem(QStringLiteral("Digia"));
    themeList->addItem(QStringLiteral("Stone Moss"));
    themeList->addItem(QStringLiteral("Army Blue"));
    themeList->addItem(QStringLiteral("Retro"));
    themeList->addItem(QStringLiteral("Ebony"));
    themeList->addItem(QStringLiteral("Isabelle"));
    themeList->setCurrentIndex(6);

    QPushButton *labelButton = new QPushButton(widget);
    labelButton->setText(QStringLiteral("Change label style"));
    */
    int logoHeight = 100, logoWidth = 300;
    int buttonSize = 100;
    QGridLayout *gridMenu = new QGridLayout();
    QPushButton *taLogoLabel = new QPushButton();
    QPushButton *configLabel = new QPushButton();
    QPushButton *saveLabel = new QPushButton();
    QPushButton *openLabel = new QPushButton();
    QPushButton *globeLabel = new QPushButton();
    QPixmap taLogoPix("/home/adityarputra/Pictures/placeholder.png");
    QIcon taLogoIcon(taLogoPix);
    QPixmap configPix("/home/adityarputra/Pictures/placeholder.png");
    QIcon configIcon(configPix);
    QPixmap savePix("/home/adityarputra/Pictures/placeholder.png");
    QIcon saveIcon(savePix);
    QPixmap openPix("/home/adityarputra/Pictures/placeholder.png");
    QIcon openIcon(openPix);
    QPixmap globePix("/home/adityarputra/Pictures/placeholder.png");
    QIcon globeIcon(globePix);

    taLogoLabel->setIcon(taLogoIcon);
    taLogoLabel->setMaximumSize(logoWidth,logoHeight);
    //taLogoLabel->setText("TA logo label");
    configLabel->setIcon(configIcon);
    configLabel->setMaximumSize(buttonSize,buttonSize);
    //configLabel->setText("Config Icon");
    saveLabel->setIcon(saveIcon);
    saveLabel->setMaximumSize(buttonSize,buttonSize);
    //saveLabel->setText("Save Icon");
    openLabel->setIcon(openIcon);
    openLabel->setMaximumSize(buttonSize,buttonSize);
    //openLabel->setText("Open Icon");
    globeLabel->setIcon(globeIcon);
    globeLabel->setMaximumSize(buttonSize,buttonSize);
    //globeLabel->setText("Globe Icon");

    gridMenu->addWidget(taLogoLabel,0,0);
    gridMenu->addWidget(configLabel,0,2);
    gridMenu->addWidget(saveLabel,0,3);
    gridMenu->addWidget(openLabel,0,4);
    gridMenu->addWidget(globeLabel,0,5);

    gridMenu->setColumnStretch(0,300);
    gridMenu->setRowMinimumHeight(0,100);
    gridMenu->setColumnStretch(1,100);
    gridMenu->setColumnStretch(2,100);
    gridMenu->setColumnStretch(3,100);
    gridMenu->setColumnStretch(4,100);
    gridMenu->setColumnStretch(5,100);

    menuLayout->setLayout(gridMenu);

    //-----------------------------------//
    QGridLayout *gridOption = new QGridLayout();
    QComboBox *gasTypeCombo = new QComboBox();
    QPushButton *rewindButton = new QPushButton();
    QPushButton *prevButton = new QPushButton();
    QPushButton *startButton = new QPushButton();
    QPushButton *nextButton = new QPushButton();
    QPushButton *forwardButton = new QPushButton();
    QTableWidget *sensorDataTable = new QTableWidget();
    QPlainTextEdit *console = new QPlainTextEdit();

    sensorDataTable->setRowCount(60);
    sensorDataTable->setColumnCount(9);

    QPixmap buttonPix("/home/adityarputra/Pictures/placeholder.png");
    QIcon buttonIcon(buttonPix);

    rewindButton->setIcon(buttonIcon);
    rewindButton->setMaximumWidth(50);
    prevButton->setIcon(buttonIcon);
    prevButton->setMaximumWidth(50);
    startButton->setIcon(buttonIcon);
    startButton->setMaximumWidth(50);
    nextButton->setIcon(buttonIcon);
    nextButton->setMaximumWidth(50);
    forwardButton->setIcon(buttonIcon);
    forwardButton->setMaximumWidth(50);

    gridOption->addWidget(sensorDataTable,0,6,3,1);
    gridOption->addWidget(gasTypeCombo,0,0,1,5);
    gridOption->addWidget(rewindButton,1,0);
    gridOption->addWidget(prevButton,1,1);
    gridOption->addWidget(startButton,1,2);
    gridOption->addWidget(nextButton,1,3);
    gridOption->addWidget(forwardButton,1,4);
    gridOption->addWidget(console,2,0,1,5);
    gridOption->setColumnStretch(0,50);
    gridOption->setColumnStretch(1,50);
    gridOption->setColumnStretch(2,50);
    gridOption->setColumnStretch(3,50);
    gridOption->setColumnStretch(4,50);
    gridOption->setColumnStretch(5,50);
    gridOption->setColumnStretch(6,400);

    optionLayout->setLayout(gridOption);

    //----------------------------------To be deleted---------------------------------
    /*QCheckBox *smoothCheckBox = new QCheckBox(widget);
    smoothCheckBox->setText(QStringLiteral("Smooth dots"));
    smoothCheckBox->setChecked(true);

    QComboBox *itemStyleList = new QComboBox(widget);
    itemStyleList->addItem(QStringLiteral("Sphere"), int(QAbstract3DSeries::MeshSphere));
    itemStyleList->addItem(QStringLiteral("Cube"), int(QAbstract3DSeries::MeshCube));
    itemStyleList->addItem(QStringLiteral("Minimal"), int(QAbstract3DSeries::MeshMinimal));
    itemStyleList->addItem(QStringLiteral("Point"), int(QAbstract3DSeries::MeshPoint));
    itemStyleList->setCurrentIndex(0);

    QPushButton *cameraButton = new QPushButton(widget);
    cameraButton->setText(QStringLiteral("Change camera preset"));

    QPushButton *itemCountButton = new QPushButton(widget);
    itemCountButton->setText(QStringLiteral("Toggle item count"));

    QCheckBox *backgroundCheckBox = new QCheckBox(widget);
    backgroundCheckBox->setText(QStringLiteral("Show background"));
    backgroundCheckBox->setChecked(true);

    QCheckBox *gridCheckBox = new QCheckBox(widget);
    gridCheckBox->setText(QStringLiteral("Show grid"));
    gridCheckBox->setChecked(true);

    QComboBox *shadowQuality = new QComboBox(widget);
    shadowQuality->addItem(QStringLiteral("None"));
    shadowQuality->addItem(QStringLiteral("Low"));
    shadowQuality->addItem(QStringLiteral("Medium"));
    shadowQuality->addItem(QStringLiteral("High"));
    shadowQuality->addItem(QStringLiteral("Low Soft"));
    shadowQuality->addItem(QStringLiteral("Medium Soft"));
    shadowQuality->addItem(QStringLiteral("High Soft"));
    shadowQuality->setCurrentIndex(4);

    QFontComboBox *fontList = new QFontComboBox(widget);
    fontList->setCurrentFont(QFont("Arial"));*/
    //----------------------------------------------------------------

    // Adding widget to respective layout
    /*
    vLayout->addWidget(labelButton, 0, Qt::AlignTop);
    vLayout->addWidget(cameraButton, 0, Qt::AlignTop);
    vLayout->addWidget(itemCountButton, 0, Qt::AlignTop);
    vLayout->addWidget(backgroundCheckBox);
    vLayout->addWidget(gridCheckBox);
    vLayout->addWidget(smoothCheckBox, 0, Qt::AlignTop);
    vLayout->addWidget(new QLabel(QStringLiteral("Change dot style")));
    vLayout->addWidget(itemStyleList);
    vLayout->addWidget(new QLabel(QStringLiteral("Change theme")));
    vLayout->addWidget(themeList);
    vLayout->addWidget(new QLabel(QStringLiteral("Adjust shadow quality")));
    vLayout->addWidget(shadowQuality);
    vLayout->addWidget(new QLabel(QStringLiteral("Change font")));
    vLayout->addWidget(fontList, 1, Qt::AlignTop);
    */
    //! [5]

    //! [2]
    ScatterDataModifier *modifier = new ScatterDataModifier(graph);
    //! [2]

    connect(configLabel,SIGNAL(clicked(bool)),this,
    /*
    QObject::connect(cameraButton, &QPushButton::clicked, modifier,
                     &ScatterDataModifier::changePresetCamera);
    QObject::connect(labelButton, &QPushButton::clicked, modifier,
                     &ScatterDataModifier::changeLabelStyle);
    QObject::connect(itemCountButton, &QPushButton::clicked, modifier,
                     &ScatterDataModifier::toggleItemCount);

    QObject::connect(backgroundCheckBox, &QCheckBox::stateChanged, modifier,
                     &ScatterDataModifier::setBackgroundEnabled);
    QObject::connect(gridCheckBox, &QCheckBox::stateChanged, modifier,
                     &ScatterDataModifier::setGridEnabled);
    QObject::connect(smoothCheckBox, &QCheckBox::stateChanged, modifier,
                     &ScatterDataModifier::setSmoothDots);

    QObject::connect(modifier, &ScatterDataModifier::backgroundEnabledChanged,
                     backgroundCheckBox, &QCheckBox::setChecked);
    QObject::connect(modifier, &ScatterDataModifier::gridEnabledChanged,
                     gridCheckBox, &QCheckBox::setChecked);
    QObject::connect(itemStyleList, SIGNAL(currentIndexChanged(int)), modifier,
                     SLOT(changeStyle(int)));

    QObject::connect(themeList, SIGNAL(currentIndexChanged(int)), modifier,
                     SLOT(changeTheme(int)));

    QObject::connect(shadowQuality, SIGNAL(currentIndexChanged(int)), modifier,
                     SLOT(changeShadowQuality(int)));

    QObject::connect(modifier, &ScatterDataModifier::shadowQualityChanged, shadowQuality,
                     &QComboBox::setCurrentIndex);
    QObject::connect(graph, &Q3DScatter::shadowQualityChanged, modifier,
                     &ScatterDataModifier::shadowQualityUpdatedByVisual);

    QObject::connect(fontList, &QFontComboBox::currentFontChanged, modifier,
                     &ScatterDataModifier::changeFont);
    QObject::connect(modifier, &ScatterDataModifier::fontChanged, fontList,
                     &QFontComboBox::setCurrentFont);
    */
    //! [6]

    //! [3]
    widget->show();
    return app.exec();
    //! [3]
}