Esempio n. 1
0
MultiWindowVisApp::MultiWindowVisApp(VisItViewer *v) : QMainWindow()
{
    viewer = v;
    windowsAdded = false;
    currentWindow = 0;
    for(int i = 0; i < NWINDOWS + 1; ++i)
        viswindows[i] = 0;

    setWindowTitle(tr("Multiwindow visualization"));

    // Create the window.
    QWidget *central = new QWidget(this);
    setCentralWidget(central);

    QHBoxLayout *hLayout = new QHBoxLayout(central);
    hLayout->setMargin(10);
    hLayout->setSpacing(10);
    QVBoxLayout *leftLayout = new QVBoxLayout(0);
    leftLayout->setSpacing(10);
    hLayout->addLayout(leftLayout);

    QLabel *scalarLabel = new QLabel(tr("Scalar variables"), central);
    leftLayout->addWidget(scalarLabel);

    variables = new QListWidget(central);
    leftLayout->addWidget(variables);
    connect(variables, SIGNAL(currentTextChanged(const QString &)),
            this, SLOT(onSelectVariable(const QString &)));

    // Create the visualization windows. Do an easy layout in this example.
    QSplitter *splitter = new QSplitter(central);
    splitter->setOrientation(Qt::Horizontal);
    hLayout->addWidget(splitter, 100);

    viswindows[PSEUDOCOLOR_WINDOW] = new vtkQtRenderWindow(splitter);
    viswindows[PSEUDOCOLOR_WINDOW]->setMinimumSize(QSize(300,400));

    viswindows[VOLUME_WINDOW] = new vtkQtRenderWindow(splitter);
    viswindows[VOLUME_WINDOW]->setMinimumSize(QSize(300,400));
 
    //
    // Register a window creation function (before Setup) that will
    // return the vtkQtRenderWindow objects that we've already
    // parented into our interface.
    //
    viewer->SetWindowCreationCallback(ReturnVisWin, (void *)this);

    // Create menus
    QMenu *fileMenu = menuBar()->addMenu(tr("File"));
    fileMenu->addAction(tr("Open . . ."), this, SLOT(selectFile()));
    fileMenu->addSeparator();
    fileMenu->addAction(tr("Quit"), qApp, SLOT(quit()));

    QMenu *controlsMenu = menuBar()->addMenu(tr("Controls"));
    controlsMenu->addAction(tr("Open GUI"), this, SLOT(openGUI()));
}
Esempio n. 2
0
SimpleVisApp::SimpleVisApp(VisItViewer *v, int *argc, char ***argv)
    : QMainWindow()
{
    viewer = v;
    setWindowTitle(tr("Simple visualization"));
    plotType = 0;

    // Create the window.
    QWidget *central = new QWidget(this);
    setCentralWidget(central);

    QHBoxLayout *hLayout = new QHBoxLayout(central);
    hLayout->setMargin(10);
    hLayout->setSpacing(10);
    QVBoxLayout *leftLayout = new QVBoxLayout(0);
    leftLayout->setSpacing(10);
    hLayout->addLayout(leftLayout);

    scalarLabel = new QLabel(tr("Scalar variables"), central);
    leftLayout->addWidget(scalarLabel);

    variables = new QListWidget(central);
    leftLayout->addWidget(variables);
    connect(variables, SIGNAL(currentTextChanged(const QString &)),
            this, SLOT(changeVariable(const QString &)));

    plotTypeWidget = new QWidget(central);
    leftLayout->addWidget(plotTypeWidget);
    QHBoxLayout *ptLayout = new QHBoxLayout(plotTypeWidget);
    ptLayout->setSpacing(10);
    ptLayout->addWidget(new QLabel(tr("Plot type"), plotTypeWidget));
    plotType = new QButtonGroup(plotTypeWidget);
    QRadioButton *rb = new QRadioButton(tr("Pseudocolor"), plotTypeWidget);
    plotType->addButton(rb, 0);
    ptLayout->addWidget(rb);
    rb = new QRadioButton(tr("Contour"), plotTypeWidget);
    plotType->addButton(rb, 1);
    ptLayout->addWidget(rb);
    connect(plotType, SIGNAL(buttonClicked(int)),
            this, SLOT(changePlotType(int)));

    contourWidget = new QWidget(central);
    leftLayout->addWidget(contourWidget);
    QHBoxLayout *cLayout = new QHBoxLayout(contourWidget);
    cLayout->setSpacing(10);
    nContours = new QSpinBox(contourWidget);
    nContours->setRange(1,40);
    nContours->setValue(10);
    connect(nContours, SIGNAL(valueChanged(int)),
            this, SLOT(setNContours(int)));
    cLayout->addWidget(new QLabel(tr("Number of contours"), contourWidget));
    cLayout->addWidget(nContours);

    // Create the vis window directly.
    viswin = new vtkQtRenderWindow(central);
    viswin->setMinimumSize(QSize(500,500));
    hLayout->addWidget(viswin, 100);

    // Create menus
    QMenu *fileMenu = menuBar()->addMenu(tr("File"));
    fileMenu->addAction(tr("Open . . ."), this, SLOT(selectFile()));
    fileMenu->addAction(tr("Open commands. . ."), this, SLOT(execFile()));
    fileMenu->addSeparator();
    fileMenu->addAction(tr("Save window"), this, SLOT(saveWindow()));
    fileMenu->addSeparator();
    fileMenu->addAction(tr("Quit"), this, SLOT(quitApp()));
    
    QMenu *controlsMenu = menuBar()->addMenu(tr("Controls"));
    controlsMenu->addAction(tr("Open GUI"), this, SLOT(openGUI()));

    //
    // Register a window creation function (before Setup) that will
    // return the vtkQtRenderWindow objects that we've already
    // parented into our interface.
    //
    viewer->SetWindowCreationCallback(ReturnVisWin, (void *)this);

    // Set the initial widget sensitivity.
    resetWindow();

    cmd = 0;

    if (*argc > 1)
        clfilename = (*argv)[1];
}
Esempio n. 3
0
int main(int argc, char *argv[])
{
  QApplication::setApplicationName(LONG_NAME);
  QApplication::setApplicationVersion(VERSION);
  QApplication::setOrganizationName(ORG); 
  QApplication::setDesktopSettingsAware(true);
  QApplication app(argc, argv);

	// Create seed for the QT random number generator
	QTime time = QTime::currentTime();
	qsrand((uint)time.msec());

	// setup the command line parser
	QCommandLineParser parser;
	parser.setApplicationDescription(QApplication::translate("main.cpp", "GStreamer based media player.") );
	
	QCommandLineOption streamBuffering(QStringList() << "b" << "stream-buffering", QCoreApplication::translate("main.cpp", "Enable buffering of the demuxed or parsed data in the stream (default is no stream buffering).") );
	parser.addOption(streamBuffering);	
	
  QCommandLineOption connectionSpeed(QStringList() << "c" << "connection-speed", QCoreApplication::translate("main.cpp", "Specify a network connection speed in kbps (default is 0 meaning unknown)."), QCoreApplication::translate("main.cpp", "connection-speed"), "0" );  
  parser.addOption(connectionSpeed);
  
	QCommandLineOption downloadBuffering(QStringList() << "d" << "download-buffering", QCoreApplication::translate("main.cpp", "Enable progressive download buffering of selected formats (default is no download buffering).") );
	parser.addOption(downloadBuffering);	  
	
	QCommandLineOption openFullScreen(QStringList() << "f" << "fullscreen", QCoreApplication::translate("main.cpp", "Start the player in full screen mode (default is start in window).") );
	parser.addOption(openFullScreen);
	
	QCommandLineOption openGUI(QStringList() << "g" << "gui", QCoreApplication::translate("main.cpp", "Open the player in GUI mode (default is no GUI).") );
	parser.addOption(openGUI);
	
  parser.addHelpOption();  
  
  QCommandLineOption useIconTheme(QStringList() << "i" << "icon-theme",
		QCoreApplication::translate("main.cpp", "Use an icon theme from your system."),
		QCoreApplication::translate("main.cpp", "Icon Theme Name"),
		QString() );
  parser.addOption(useIconTheme);   
	
	QCommandLineOption logLevel(QStringList() << "l" << "loglevel", QCoreApplication::translate("main.cpp", "Set the log level from 0 to 4 (default is 1)."), QCoreApplication::translate("main.cpp", "loglevel"), "1" );
	parser.addOption(logLevel);  

 	QCommandLineOption openShadeMode(QStringList() << "s" << "shademode", QCoreApplication::translate("main.cpp", "Start the player in shade mode (default is start in normal mode).") );
	parser.addOption(openShadeMode);
	
	QCommandLineOption noHardwareDecoding(QStringList() << "w" << "no-hardware-decoding", QCoreApplication::translate("main.cpp", "Disable hardware decoding, (default is enabled).") );
	parser.addOption(noHardwareDecoding);
 
  parser.addVersionOption();	  
    
  QCommandLineOption cdDevice(QStringList() << "C" << "CD", QCoreApplication::translate("main.cpp", "Specify the optical drive that will play the audio CD (default is /dev/sr0)."), QCoreApplication::translate("main.cpp", "CD"), "/dev/sr0");
  parser.addOption(cdDevice);
  
  QCommandLineOption dvdDevice(QStringList() << "D" << "DVD", QCoreApplication::translate("main.cpp", "Specify the optical drive that will play the DVD (default is /dev/sr0)."), QCoreApplication::translate("main.cpp", "DVD"), "/dev/sr0");
  parser.addOption(dvdDevice);
 
 QCommandLineOption enableSubtitles(QStringList() << "S" << "subtitles", QCoreApplication::translate("main.cpp", "Enable display of subtitles if a subtitle stream is found (default is no subtitles).") );
  parser.addOption(enableSubtitles);  
	 
  QCommandLineOption enableVisualizer(QStringList() << "V" << "visualizer", QCoreApplication::translate("main.cpp", "Enable a visualizer when playing audio tracks (default is no visualizer).") );
  parser.addOption(enableVisualizer);  

  QCommandLineOption promoteElement(QStringList() << "promote", QCoreApplication::translate("main.cpp", "List of GStreamer elements (comma separated) to be promoted."), QCoreApplication::translate("main.cpp", "element list"), "" );  
  parser.addOption(promoteElement);
  
  QCommandLineOption blacklistElement(QStringList() << "blacklist", QCoreApplication::translate("main.cpp", "List (comma separated) of GStreamer elements to be blacklisted."), QCoreApplication::translate("main.cpp", "element list"), "" );  
  parser.addOption(blacklistElement);
    
	parser.addPositionalArgument("filename", QCoreApplication::translate("main.cpp", "Media file to play."));
  
  // Setup translations   
  QTranslator qtTranslator;
  qtTranslator.load("qt_" + QLocale::system().name(),
  QLibraryInfo::location(QLibraryInfo::TranslationsPath));
  app.installTranslator(&qtTranslator);

  QTranslator mbmpTranslator;
  if (mbmpTranslator.load("mbmp_" + QLocale::system().name(), ":/translations/translations" ) ) {  
		app.installTranslator(&mbmpTranslator);	
	}
	// else use en_US as it contains Connman strings properized and some singular/plural strings
	else if (mbmpTranslator.load("mbmp_en_US", ":/translations/translations" ) ) {
		app.installTranslator(&mbmpTranslator);	
	}


  // Make sure all the command lines can be parsed 
  // using parse() instead of process() as process stops on an error if an option needs a value
  // and it is not specified, even if we provide a default.  We're supposed to catch errors if we
  // use parse(), but parse.errorText() returns an empty string on this.  Bag the error checking
  // for now.
  parser.parse(QCoreApplication::arguments() );   
  QStringList sl = parser.unknownOptionNames();
  if (sl.size() > 0 ) parser.showHelp(1);
  if (parser.isSet("help") ) parser.showHelp(1);	
  if (parser.isSet("version") ) parser.showVersion();
  
  // signal handler             
  signal(SIGINT, signalhandler); 
  
  PlayerControl pctl(parser);
  pctl.show();
   
  return app.exec();

}