Esempio n. 1
0
QDockWindow* CGLWin::_createDockWidgetBar(QWidget *parent, const QString& appdir)
{
    QDockWindow* p = new QDockWindow( QDockWindow::InDock, this );
    p->setResizeEnabled(true);
    p->setCloseMode(QDockWindow::Always);
    addToolBar( p, Qt::DockLeft );

    QToolBox* pToolBox = new QToolBox(p);
    p->setWidget(pToolBox);
    p->setFixedExtentWidth( 200 );
    p->setCaption("Object List");
    setDockEnabled( p, Qt::DockTop, FALSE );
    setDockEnabled( p, Qt::DockBottom, FALSE );

    //first node
    m_pListViews = new CObjectListView(m_pGLUIWin->m_SceneGraph, pToolBox);
    pToolBox->addItem(m_pListViews, "Objects");

	/*
    //second node
	m_pMaterialTree = new CMaterialTree(appdir, pActiveSceneNode, pToolBox);
    pToolBox->addItem(m_pMaterialTree, "Materials");
	*/
    return p;    
}
Esempio n. 2
0
QToolBox* UiGenerator::createToolBox(
        scheme::Para& para,
        QWidget* parent) {
    QToolBox* res = new QToolBox(parent);
    auto buttonGroupPtr = createButtonGroup(para, parent);
    for(const auto& paraPtr : para.getOrParas()) {
        QWidget* page = generateUi(*paraPtr, parent, buttonGroupPtr);
        res->addItem(page, paraPtr->getName());
    }
    return res;
}
Esempio n. 3
0
GUI::GUI(QWidget* parent) : 
    QWidget(parent), stats(NULL), sceneView(NULL)
{
    //Create each component
    stats     = new StatsPanel(this);
    sceneView = new RenderViewWidget(this);

    //TODO: Make real stuff here
    QPushButton* button1 = new QPushButton(this); button1->setText("Re-Render");
    connect(button1, SIGNAL(clicked()), sceneView, SLOT(draw()));

    QPushButton* button2 = new QPushButton(this); button2->setText("Button 2");
    QPushButton* button3 = new QPushButton(this); button3->setText("Button 3");
    QPushButton* button4 = new QPushButton(this); button4->setText("Button 4");
    QPushButton* button5 = new QPushButton(this); button5->setText("Button 5");

    QToolBox* tb = new QToolBox(this);
    tb->addItem(button1, "Rendering");
    tb->insertItem(0, button2, "Rendering 2");
    tb->addItem(button3, "Tone Mapping");
    tb->addItem(button4, "Tone Mapping");
    tb->addItem(button5, "Parallelization");

    //Left layout = vertical box layout
    //upper component = view panel
    //lower component = statstics
    QVBoxLayout* leftLayout = new QVBoxLayout();
    leftLayout->addWidget(sceneView, 100); //OpenGL viewer
    leftLayout->addWidget(stats);     //Stats Panel

    //Right layout = Vertical layout with a bunch of controls
    QVBoxLayout* controlsLayout = new QVBoxLayout();
    controlsLayout->addWidget(tb);

    //Main layout is a vbox layout
    QHBoxLayout* mainLayout = new QHBoxLayout();
    mainLayout->addLayout(leftLayout, 100);
    mainLayout->addLayout(controlsLayout);
    setLayout(mainLayout);

    setWindowTitle(WINDOW_TITLE);

}
Esempio n. 4
0
/**
 * Initialize this object.
 */
PakooView::PakooView( QWidget *parent )
    : DCOPObject("pakooIface"), QWidget(parent)
{
    m_backend = new PortageBackend();

    // Overall layout

    QHBoxLayout* topLayout = new QHBoxLayout( this );
    topLayout->setAutoAdd( true );

    m_hSplitter = new QSplitter( this );
    m_hSplitter->setOpaqueResize( true );

    QToolBox* toolBox = new QToolBox( m_hSplitter, "toolBox" );

    m_vSplitter = new QSplitter( m_hSplitter );
    m_vSplitter->setOrientation( QSplitter::Vertical );
    m_vSplitter->setOpaqueResize( true );


    // Adding the individual widgets

    m_treeView = new PackageTreeView( this, "treeView", m_backend );

    int sectionIndex = toolBox->addItem( m_treeView, TREEVIEWTEXT );
    m_sectionIndexes[sectionIndex] = BrowseSection;

    sectionIndex = toolBox->addItem(
                       new QLabel("Action View", 0, "tempactionlabel"), ACTIONVIEWTEXT );
    m_sectionIndexes[sectionIndex] = ActionSection;
    toolBox->setCurrentIndex( 1 );

    sectionIndex = toolBox->addItem(
                       new QLabel("Config View", 0, "tempconfiglabel"), CONFIGVIEWTEXT );
    m_sectionIndexes[sectionIndex] = ConfigSection;

    m_viewAreas = new QWidgetStack( m_vSplitter, "viewArea" );
    m_packageView = new PackageView( m_viewAreas, "packageView", m_backend );
    m_actionArea = new QWidgetStack( m_viewAreas, "actionArea" );
    JobView* jobView = new JobView( new EmergeProcess(), "title", m_actionArea, "jobView" );
    jobView->start();
    m_configArea = new QWidgetStack( m_viewAreas, "configArea" );
    new QLabel( "Config View", m_viewAreas, "configView" );
    m_viewAreas->raiseWidget( m_actionArea );

    m_packageInfoView = new PackageInfoView( m_vSplitter, "packageInfoView" );

    m_hSplitter->setResizeMode( toolBox, QSplitter::KeepSize );
    m_vSplitter->setResizeMode( m_packageInfoView->view(), QSplitter::KeepSize );

    m_vSplitter->setSizes( PakooConfig::vSplitterSizes() );
    m_hSplitter->setSizes( PakooConfig::hSplitterSizes() );


    //
    // Here comes the big connection creator
    //

    // Connect the QToolBox signals so the right side follows the left one
    connect(
        toolBox, SIGNAL( currentChanged(int) ),
        this,      SLOT( showSection(int) )
    );

    // Connect the package displaying widgets to work together
    connect(
        m_treeView,            SIGNAL( packageListChanged(PackageList&) ),
        m_packageView->listView, SLOT( setPackageList(PackageList&) )
    );
    connect(
        m_treeView,            SIGNAL( selectionChanged(PackageSelector&) ),
        m_packageView->listView, SLOT( setPackageSelector(PackageSelector&) )
    );
    connect(
        m_packageView->listView, SIGNAL( selectionChanged(Package*) ),
        m_packageInfoView, SLOT( displayPackage(Package*) )
    );
    connect(
        m_packageView->listView, SIGNAL(selectionChanged(Package*, PackageVersion*)),
        m_packageInfoView, SLOT(displayPackage(Package*, PackageVersion*))
    );

    // Connect the convenience method for copying text,
    // like pointed out by Scott Wheeler on the kde-core mailing list
    KStdAction::copy( KApplication::kApplication(), SLOT(copy()), NULL );

    // Connect the package list view with the status bar,
    // so the latter one is updated properly
    //TODO: adapt
    /*connect(
    	m_packageView->listView, SIGNAL(loadingPackageInfo(int,int)),
    	this, SLOT(handleLoadingPackageInfo(int,int))
    );
    connect(
    	m_packageView->listView, SIGNAL(finishedLoadingPackageDetails(PackageList&)),
    	this, SLOT(handleFinishedLoadingPackageDetails(PackageList&))
    );*/
}
Esempio n. 5
0
Dialog::Dialog(QWidget *parent)
    : QWidget(parent)
{
    QVBoxLayout *mainLayout = new QVBoxLayout(this);
    QToolBox *toolbox = new QToolBox;
    mainLayout->addWidget(toolbox);

    errorMessageDialog = new QErrorMessage(this);

    int frameStyle = QFrame::Sunken | QFrame::Panel;

    integerLabel = new QLabel;
    integerLabel->setFrameStyle(frameStyle);
    QPushButton *integerButton =
            new QPushButton(tr("QInputDialog::get&Int()"));

    doubleLabel = new QLabel;
    doubleLabel->setFrameStyle(frameStyle);
    QPushButton *doubleButton =
            new QPushButton(tr("QInputDialog::get&Double()"));

    itemLabel = new QLabel;
    itemLabel->setFrameStyle(frameStyle);
    QPushButton *itemButton = new QPushButton(tr("QInputDialog::getIte&m()"));

    textLabel = new QLabel;
    textLabel->setFrameStyle(frameStyle);
    QPushButton *textButton = new QPushButton(tr("QInputDialog::get&Text()"));

    multiLineTextLabel = new QLabel;
    multiLineTextLabel->setFrameStyle(frameStyle);
    QPushButton *multiLineTextButton = new QPushButton(tr("QInputDialog::get&MultiLineText()"));

    colorLabel = new QLabel;
    colorLabel->setFrameStyle(frameStyle);
    QPushButton *colorButton = new QPushButton(tr("QColorDialog::get&Color()"));

    fontLabel = new QLabel;
    fontLabel->setFrameStyle(frameStyle);
    QPushButton *fontButton = new QPushButton(tr("QFontDialog::get&Font()"));

    directoryLabel = new QLabel;
    directoryLabel->setFrameStyle(frameStyle);
    QPushButton *directoryButton =
            new QPushButton(tr("QFileDialog::getE&xistingDirectory()"));

    openFileNameLabel = new QLabel;
    openFileNameLabel->setFrameStyle(frameStyle);
    QPushButton *openFileNameButton =
            new QPushButton(tr("QFileDialog::get&OpenFileName()"));

    openFileNamesLabel = new QLabel;
    openFileNamesLabel->setFrameStyle(frameStyle);
    QPushButton *openFileNamesButton =
            new QPushButton(tr("QFileDialog::&getOpenFileNames()"));

    saveFileNameLabel = new QLabel;
    saveFileNameLabel->setFrameStyle(frameStyle);
    QPushButton *saveFileNameButton =
            new QPushButton(tr("QFileDialog::get&SaveFileName()"));

    criticalLabel = new QLabel;
    criticalLabel->setFrameStyle(frameStyle);
    QPushButton *criticalButton =
            new QPushButton(tr("QMessageBox::critica&l()"));

    informationLabel = new QLabel;
    informationLabel->setFrameStyle(frameStyle);
    QPushButton *informationButton =
            new QPushButton(tr("QMessageBox::i&nformation()"));

    questionLabel = new QLabel;
    questionLabel->setFrameStyle(frameStyle);
    QPushButton *questionButton =
            new QPushButton(tr("QMessageBox::&question()"));

    warningLabel = new QLabel;
    warningLabel->setFrameStyle(frameStyle);
    QPushButton *warningButton = new QPushButton(tr("QMessageBox::&warning()"));

    errorLabel = new QLabel;
    errorLabel->setFrameStyle(frameStyle);
    QPushButton *errorButton =
            new QPushButton(tr("QErrorMessage::showM&essage()"));

    connect(integerButton, SIGNAL(clicked()), this, SLOT(setInteger()));
    connect(doubleButton, SIGNAL(clicked()), this, SLOT(setDouble()));
    connect(itemButton, SIGNAL(clicked()), this, SLOT(setItem()));
    connect(textButton, SIGNAL(clicked()), this, SLOT(setText()));
    connect(multiLineTextButton, SIGNAL(clicked()), this, SLOT(setMultiLineText()));
    connect(colorButton, SIGNAL(clicked()), this, SLOT(setColor()));
    connect(fontButton, SIGNAL(clicked()), this, SLOT(setFont()));
    connect(directoryButton, SIGNAL(clicked()),
            this, SLOT(setExistingDirectory()));
    connect(openFileNameButton, SIGNAL(clicked()),
            this, SLOT(setOpenFileName()));
    connect(openFileNamesButton, SIGNAL(clicked()),
            this, SLOT(setOpenFileNames()));
    connect(saveFileNameButton, SIGNAL(clicked()),
            this, SLOT(setSaveFileName()));
    connect(criticalButton, SIGNAL(clicked()), this, SLOT(criticalMessage()));
    connect(informationButton, SIGNAL(clicked()),
            this, SLOT(informationMessage()));
    connect(questionButton, SIGNAL(clicked()), this, SLOT(questionMessage()));
    connect(warningButton, SIGNAL(clicked()), this, SLOT(warningMessage()));
    connect(errorButton, SIGNAL(clicked()), this, SLOT(errorMessage()));

    QWidget *page = new QWidget;
    QGridLayout *layout = new QGridLayout(page);
    layout->setColumnStretch(1, 1);
    layout->setColumnMinimumWidth(1, 250);
    layout->addWidget(integerButton, 0, 0);
    layout->addWidget(integerLabel, 0, 1);
    layout->addWidget(doubleButton, 1, 0);
    layout->addWidget(doubleLabel, 1, 1);
    layout->addWidget(itemButton, 2, 0);
    layout->addWidget(itemLabel, 2, 1);
    layout->addWidget(textButton, 3, 0);
    layout->addWidget(textLabel, 3, 1);
    layout->addWidget(multiLineTextButton, 4, 0);
    layout->addWidget(multiLineTextLabel, 4, 1);
    layout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding), 5, 0);
    toolbox->addItem(page, tr("Input Dialogs"));

    const QString doNotUseNativeDialog = tr("Do not use native dialog");

    page = new QWidget;
    layout = new QGridLayout(page);
    layout->setColumnStretch(1, 1);
    layout->addWidget(colorButton, 0, 0);
    layout->addWidget(colorLabel, 0, 1);
    colorDialogOptionsWidget = new DialogOptionsWidget;
    colorDialogOptionsWidget->addCheckBox(doNotUseNativeDialog, QColorDialog::DontUseNativeDialog);
    colorDialogOptionsWidget->addCheckBox(tr("Show alpha channel") , QColorDialog::ShowAlphaChannel);
    colorDialogOptionsWidget->addCheckBox(tr("No buttons") , QColorDialog::NoButtons);
    layout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding), 1, 0);
    layout->addWidget(colorDialogOptionsWidget, 2, 0, 1 ,2);

    toolbox->addItem(page, tr("Color Dialog"));

    page = new QWidget;
    layout = new QGridLayout(page);
    layout->setColumnStretch(1, 1);
    layout->addWidget(fontButton, 0, 0);
    layout->addWidget(fontLabel, 0, 1);
    fontDialogOptionsWidget = new DialogOptionsWidget;
    fontDialogOptionsWidget->addCheckBox(doNotUseNativeDialog, QFontDialog::DontUseNativeDialog);
    fontDialogOptionsWidget->addCheckBox(tr("No buttons") , QFontDialog::NoButtons);
    layout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding), 1, 0);
    layout->addWidget(fontDialogOptionsWidget, 2, 0, 1 ,2);
    toolbox->addItem(page, tr("Font Dialog"));

    page = new QWidget;
    layout = new QGridLayout(page);
    layout->setColumnStretch(1, 1);
    layout->addWidget(directoryButton, 0, 0);
    layout->addWidget(directoryLabel, 0, 1);
    layout->addWidget(openFileNameButton, 1, 0);
    layout->addWidget(openFileNameLabel, 1, 1);
    layout->addWidget(openFileNamesButton, 2, 0);
    layout->addWidget(openFileNamesLabel, 2, 1);
    layout->addWidget(saveFileNameButton, 3, 0);
    layout->addWidget(saveFileNameLabel, 3, 1);
    fileDialogOptionsWidget = new DialogOptionsWidget;
    fileDialogOptionsWidget->addCheckBox(doNotUseNativeDialog, QFileDialog::DontUseNativeDialog);
    fileDialogOptionsWidget->addCheckBox(tr("Show directories only"), QFileDialog::ShowDirsOnly);
    fileDialogOptionsWidget->addCheckBox(tr("Do not resolve symlinks"), QFileDialog::DontResolveSymlinks);
    fileDialogOptionsWidget->addCheckBox(tr("Do not confirm overwrite"), QFileDialog::DontConfirmOverwrite);
    fileDialogOptionsWidget->addCheckBox(tr("Do not use sheet"), QFileDialog::DontUseSheet);
    fileDialogOptionsWidget->addCheckBox(tr("Readonly"), QFileDialog::ReadOnly);
    fileDialogOptionsWidget->addCheckBox(tr("Hide name filter details"), QFileDialog::HideNameFilterDetails);
    layout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding), 4, 0);
    layout->addWidget(fileDialogOptionsWidget, 5, 0, 1 ,2);
    toolbox->addItem(page, tr("File Dialogs"));

    page = new QWidget;
    layout = new QGridLayout(page);
    layout->setColumnStretch(1, 1);
    layout->addWidget(criticalButton, 0, 0);
    layout->addWidget(criticalLabel, 0, 1);
    layout->addWidget(informationButton, 1, 0);
    layout->addWidget(informationLabel, 1, 1);
    layout->addWidget(questionButton, 2, 0);
    layout->addWidget(questionLabel, 2, 1);
    layout->addWidget(warningButton, 3, 0);
    layout->addWidget(warningLabel, 3, 1);
    layout->addWidget(errorButton, 4, 0);
    layout->addWidget(errorLabel, 4, 1);
    layout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding), 5, 0);
    toolbox->addItem(page, tr("Message Boxes"));

    setWindowTitle(tr("Standard Dialogs"));
}
Esempio n. 6
0
SofaConfiguration::SofaConfiguration(std::string path_, std::vector< DEFINES >& config):QMainWindow(),path(path_),data(config),saveButton(NULL)

{
    resize(800, 600);

    QWidget *appli = new QWidget(this);
    QVBoxLayout *layout = new QVBoxLayout(appli);



    QToolBox *global = new QToolBox(appli);
    global->setMaximumHeight(600);
    global->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum);


    std::string currentCategory;

    std::set< std::string > alreadyBuiltCategories;

    QWidget *page=NULL;
    QVBoxLayout *pageLayout=NULL;
    for (unsigned int i=0; i<config.size(); ++i)
    {
        if (alreadyBuiltCategories.find(config[i].category) == alreadyBuiltCategories.end())
        {
            alreadyBuiltCategories.insert(config[i].category);
            if (page)
            {
                pageLayout->addItem( new QSpacerItem(10,10,QSizePolicy::Expanding, QSizePolicy::Expanding));
            }
            currentCategory = config[i].category;
            page = new QWidget(global);
            global->addItem(page,QString(currentCategory.c_str()));
            pageLayout=new QVBoxLayout(page);

            for (unsigned int j=0; j<config.size(); ++j)
            {
                if (config[j].category == currentCategory)
                {
                    ConfigWidget *o;
                    if (config[j].typeOption) o=new OptionConfigWidget(page, config[j]);
                    else                      o=new TextConfigWidget(page, config[j]);

                    pageLayout->addWidget(o);
                    options.push_back(o);
                    connect(o, SIGNAL(modified()), this, SLOT(updateOptions()));
                }
            }
        }
    }

    if (page)
    {
        pageLayout->addItem( new QSpacerItem(10,10,QSizePolicy::Expanding, QSizePolicy::Expanding));
    }
    updateConditions();

    saveButton = new QPushButton(QString("Save and Update Configuration"),appli);
    connect( saveButton, SIGNAL(clicked()), this, SLOT(saveConfiguration()));
    layout->addWidget(global);

#ifdef WIN32
    projectVC = new QLineEdit(QString("Project VC8.bat"),appli);
    layout->addWidget(projectVC);
#endif

    layout->addWidget(saveButton);
    this->setCentralWidget(appli);
}
Esempio n. 7
0
int main( int argc, char ** argv )
{
	// Register custom message handler if desired
	bool handler_registered = FALSE;
	MyMessageOutput * mymsghandler = NULL;
	for(int i = 1; i < argc; i++)
	{
		QString arg(argv[i]);
		QString opt("-msg_handler");
		if(arg.startsWith(opt))
		{
			// Extract handler type
			QString handler = arg.section("=",1,1);
			if(handler.isEmpty())
			{
				qWarning("Option '-msg_handler' is not complete. Use default handler.");
				handler_registered = TRUE;
				break;
			}
			if(handler == "console")
			{
				handler_registered = TRUE;
				break;
			}
			if(!handler.endsWith(".txt"))
			{
				qWarning("File '%s' does not end with '.txt'. Use default handler.",handler.ascii());
				handler_registered = TRUE;
				break;
			}
			QFileInfo hfinfo(handler);
			if(hfinfo.exists())
			{
				if(!hfinfo.isWritable())
				{
					qWarning("Cannot write to '%s'. Use default handler",handler.ascii());
					handler_registered = TRUE;
					break;
				}
			}
			else
			{
				QString path = hfinfo.dirPath();
				QFileInfo hfdinfo(path);
				if(!hfdinfo.isWritable())
				{
					qWarning("Cannot create file in dir '%s'. Use default handler",path.ascii());
					handler_registered = TRUE;
					break;
				}

			}
			mymsghandler = new MyMessageOutput(handler);
			handler_registered = TRUE;
			break;
		}
	}
	if(!handler_registered)
	{
		mymsghandler = new MyMessageOutput(QString("debuglog.txt"));
		handler_registered = TRUE;
	}

#ifdef Q_WS_X11
	if(XInitThreads() == 0)
		qFatal("XInitThreads didn't succeed");
#endif

	// Create a QApplication object and add default close
    QApplication a( argc, argv );
    a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );

	// Start the configuration selection dialog if more than one config file is available
	ConfigSelector cs;
	if(cs.getNumConfigs() > 1)
	{
		cs.resize(300,150);
		cs.show();
		a.exec();
	}

	// Load configuration
	Configuration * config = new Configuration();
	QString configfile(cs.getConfig());
	if(!config->load(configfile))
	{
		qFatal("Unable to load %s", configfile.ascii());
	}

	ConfigNode * cn = config->getConfig();
	if(!cn)
	{
		qFatal("Unable to get ConfigNode");
	}

	ApplicationNode * an = cn->getApplicationNode();
	if(!an)
	{
		qFatal("Unable to get ApplicationNode");
	}

	PluginsNode * pn = cn->getPluginsNode();
	if(!pn)
	{
		qFatal("Unable to get PluginsNode");
	}

	OBJECTVALUENODE_DECLARE_AND_GET(QPoint,position,an);
	OBJECTVALUENODE_DECLARE_AND_GET(QSize,size,an);
	SIMPLEVALUENODE_DECLARE_AND_GET(bool,maximized,an);
	SIMPLEVALUENODE_DECLARE_AND_GET(Q_INT8,tbindex,an);

    // Create the toplevel window
	Q3HBox * w = new Q3HBox();
	w->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred);

	// Add a widget that contains the toolbox and measurements
	Q3VBox * pVBox = new Q3VBox( w );
	pVBox->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Preferred );
	pVBox->setSpacing( 5 );
	pVBox->setMargin( 2 );

	// Create the toolbox
	QToolBox * tb = new QToolBox( pVBox );

	// Create all plugins
    Plugin * VisualizePlugin = new Plugin("visualize");
    Plugin * AnalysePlugin = new Plugin("analyse_os");
    Plugin * WaveInPlugin = new Plugin("wavein");
    Plugin * FileWriterPlugin = new Plugin("filewriter");
    // Load plugin objects
	PI_Unknown *ukvi = VisualizePlugin->getObject();
	PI_Unknown *ukan = AnalysePlugin->getObject();
	PI_Unknown *ukwi = WaveInPlugin->getObject();
	PI_Unknown *ukfw = FileWriterPlugin->getObject();

	// Configure the system
	if( ukvi && ukan && ukwi && ukfw )
	{
		PI_GuiContainer* gcwiobj = NULL;
		PI_GuiContainer* gcviobj = NULL;
		PI_GuiContainer* gcfwobj = NULL;
		PI_Configuration* xcanobj = NULL;
		PI_Configuration* xcviobj = NULL;
		PI_Configuration* xcwiobj = NULL;
		PI_Configuration* xcfwobj = NULL;
		PI_DataBufferProvider* dbpwiobj = NULL;
		PI_DataBufferProvider* dbpanobj = NULL;
		PI_DataBufferConsumer* dbcanobj = NULL;
		PI_DataBufferConsumer* dbcviobj = NULL;
		PI_DataBufferConsumer* dbcfwobj = NULL;
		PI_TimeProvider* tpwiobj = NULL;
		PI_TimeConsumer* tcviobj = NULL;
		PI_TimeConsumer* tcfwobj = NULL;

		ukwi->queryInterface( PIID_GUI_CONTAINER, (void**)&gcwiobj );
		ukvi->queryInterface( PIID_GUI_CONTAINER , (void**)&gcviobj );
		ukfw->queryInterface( PIID_GUI_CONTAINER, (void**)&gcfwobj );
		ukan->queryInterface( PIID_CONFIGURATION, (void**)&xcanobj );
		ukvi->queryInterface( PIID_CONFIGURATION, (void**)&xcviobj );
		ukwi->queryInterface( PIID_CONFIGURATION, (void**)&xcwiobj );
		ukfw->queryInterface( PIID_CONFIGURATION, (void**)&xcfwobj );
		ukwi->queryInterface( PIID_DATA_BUFFER_PROVIDER, (void**)&dbpwiobj );
		ukan->queryInterface( PIID_DATA_BUFFER_PROVIDER, (void**)&dbpanobj );
		ukan->queryInterface( PIID_DATA_BUFFER_CONSUMER, (void**)&dbcanobj );
		ukvi->queryInterface( PIID_DATA_BUFFER_CONSUMER, (void**)&dbcviobj );
		ukfw->queryInterface( PIID_DATA_BUFFER_CONSUMER, (void**)&dbcfwobj );
		ukwi->queryInterface( PIID_TIME_PROVIDER, (void**)&tpwiobj );
		ukvi->queryInterface( PIID_TIME_CONSUMER, (void**)&tcviobj );
		ukfw->queryInterface( PIID_TIME_CONSUMER, (void**)&tcfwobj );

		if( gcwiobj && gcviobj && gcfwobj &&
			xcwiobj && xcanobj && xcviobj && xcfwobj &&
			dbpwiobj && dbpanobj && dbcanobj && dbcviobj && dbcfwobj &&
			tpwiobj && tcviobj && tcfwobj)
		{
			// Wave in object
			gcwiobj->setParentWindow( tb, "WaveDeviceConfiguration" );
			// Visualize object
    		gcviobj->setParentWindow( tb, "Diagram1" );
    		gcviobj->setParentWindow( tb, "Diagram2" );
    		gcviobj->setParentWindow( tb, "Diagram3" );
			gcviobj->setParentWindow( tb, "Diagram4" );
			gcviobj->setParentWindow( tb, "Diagram5" );
			gcviobj->setParentWindow( tb, "Configuration" );
			gcviobj->setParentWindow( tb, "BaseFrequency" );
			gcviobj->setParentWindow( pVBox, "TopDisplay" );
			gcviobj->setParentWindow( w, "Graph" );
			// File writer object
			gcfwobj->setParentWindow( tb, "SpectralDataSaveGui" );

			// Wave in object
			PLUGINNODE_DECLARE_AND_GET(wavein,pn);
			xcwiobj->configure(NODE_VARIABLE_NAME(wavein));
			// Analyse object
			PLUGINNODE_DECLARE_AND_GET(analyse,pn);
			xcanobj->configure(NODE_VARIABLE_NAME(analyse));
			// Visualize object
			PLUGINNODE_DECLARE_AND_GET(visualize,pn);
			xcviobj->configure(NODE_VARIABLE_NAME(visualize));
			// File writer object
			PLUGINNODE_DECLARE_AND_GET(filewriter,pn);
			xcfwobj->configure(NODE_VARIABLE_NAME(filewriter));

			// Connect the 'pause' source to different sinks
			gcviobj->connectSlot( "pause", gcwiobj->getObject("WaveDeviceConfiguration"), "setPause" );
			gcviobj->connectSlot( "pause", gcfwobj->getObject("SpectralDataSaveGui"), "setPause" );

			// Add visualize object configurations to the toolbox
			tb->addItem( gcviobj->getWidget("Diagram1"), "Diagramm 1" );
			tb->addItem( gcviobj->getWidget("Diagram2"), "Diagramm 2" );
			tb->addItem( gcviobj->getWidget("Diagram3"), "Diagramm 3" );
			tb->addItem( gcviobj->getWidget("Diagram4"), "Diagramm 4" );
			tb->addItem( gcviobj->getWidget("Diagram5"), "Diagramm 5" );
			tb->addItem( gcviobj->getWidget("Configuration"), "Konfiguration" );
			tb->addItem( gcviobj->getWidget("BaseFrequency"), "Bezugston, Stimmung" );
			// Add file writer object configuration to the toolbox
			tb->addItem( gcfwobj->getWidget("SpectralDataSaveGui"), "Datenspeicherung" );
			// Add wave in object configuration to the toolbox
			tb->addItem( gcwiobj->getWidget("WaveDeviceConfiguration"), "Soundkarte" );

			dbpwiobj->addRef();
			dbcanobj->connectToProvider( dbpwiobj );
			dbpanobj->addRef();
			dbcviobj->connectToProvider( dbpanobj );

			dbpwiobj->addRef();
			dbcfwobj->connectToProvider( dbpwiobj ); //filewrite
			dbpanobj->addRef();
			dbcfwobj->connectToProvider( dbpanobj ); //filewrite

			tpwiobj->addRef();
			tcviobj->connectToProvider( tpwiobj );
			tpwiobj->addRef();
			tcfwobj->connectToProvider( tpwiobj ); //filewrite

			xcwiobj->startRunning();
			xcanobj->startRunning();
			xcviobj->startRunning();
			xcfwobj->startRunning(); //filewrite

		}

		if( gcwiobj ) gcwiobj->release();
		if( gcviobj ) gcviobj->release();
		if( gcfwobj ) gcfwobj->release();
		if( xcanobj ) xcanobj->release();
		if( xcviobj ) xcviobj->release();
		if( xcwiobj ) xcwiobj->release();
		if( xcfwobj ) xcfwobj->release();
		if( dbpwiobj ) dbpwiobj->release();
		if( dbpanobj ) dbpanobj->release();
		if( dbcanobj ) dbcanobj->release();
		if( dbcviobj ) dbcviobj->release();
		if( dbcfwobj ) dbcfwobj->release();
		if( tpwiobj ) tpwiobj->release();
		if( tcviobj ) tcviobj->release();
		if( tcfwobj ) tcfwobj->release();
	}

	// Set active item in the ToolBox
	tb->setCurrentIndex(VALUENODE_GET_VALUE(tbindex));

	w->resize(VALUENODE_GET_VALUE(size));
	w->move(VALUENODE_GET_VALUE(position));
	if(VALUENODE_GET_VALUE(maximized))
		w->showMaximized();
	w->setCaption("Prisma-Realtime v1.3b");
    w->show();

    Q3Accel *esc = new Q3Accel( w );
    esc->connectItem( esc->insertItem( Qt::Key_Escape ), &a, SLOT( quit() ) );

    a.exec();

	w->hide();

	if(!w->isMaximized())
	{
		VALUENODE_SET_VALUE(size,w->size());
		VALUENODE_SET_VALUE(position,w->pos());
	}
	VALUENODE_SET_VALUE(maximized,w->isMaximized());

	VALUENODE_SET_VALUE(tbindex,tb->currentIndex());

	if( ukvi && ukan && ukwi && ukfw )
	{
		PI_Configuration * xmlconfig = NULL;

		ukvi->queryInterface(PIID_CONFIGURATION, (void**)&xmlconfig);
		if(xmlconfig != NULL)
		{
			xmlconfig->stopRunning();
			xmlconfig->release();
			xmlconfig = NULL;
		}
		ukan->queryInterface(PIID_CONFIGURATION, (void**)&xmlconfig);
		if(xmlconfig != NULL)
		{
			xmlconfig->stopRunning();
			xmlconfig->release();
			xmlconfig = NULL;
		}
		ukwi->queryInterface(PIID_CONFIGURATION, (void**)&xmlconfig);
		if(xmlconfig != NULL)
		{
			xmlconfig->stopRunning();
			xmlconfig->release();
			xmlconfig = NULL;
		}
		ukfw->queryInterface(PIID_CONFIGURATION, (void**)&xmlconfig);
		if(xmlconfig != NULL)
		{
			xmlconfig->stopRunning();
			xmlconfig->release();
			xmlconfig = NULL;
		}
	}

	if(ukvi) ukvi->release();
	if(ukan) ukan->release();
	if(ukwi) ukwi->release();
	if(ukfw) ukfw->release();

	delete w;

	config->save(configfile);
	// Delete before unloading plugins!!!
	delete config;

	// Release plugins
	delete VisualizePlugin;
	delete FileWriterPlugin;
	delete AnalysePlugin;
	delete WaveInPlugin;


	if(mymsghandler)
		delete mymsghandler;

    return 0;

}
Esempio n. 8
0
void QToolBoxButton::drawButton( QPainter *p )
{
    QStyle::SFlags flags = QStyle::Style_Default;
    const QColorGroup &cg = colorGroup();

    if ( isEnabled() )
	flags |= QStyle::Style_Enabled;
    if ( selected )
	flags |= QStyle::Style_Selected;
    if ( hasFocus() )
	flags |= QStyle::Style_HasFocus;
    if (isDown())
	flags |= QStyle::Style_Down;
    style().drawControl( QStyle::CE_ToolBoxTab, p, parentWidget(), rect(), cg, flags );

    QPixmap pm = icon.pixmap( QIconSet::Small, isEnabled() ? QIconSet::Normal : QIconSet::Disabled );

    QRect cr = style().subRect( QStyle::SR_ToolBoxTabContents, this );
    QRect tr, ir;
    int ih = 0;
    if ( pm.isNull() ) {
	tr = cr;
	tr.addCoords( 4, 0, -8, 0 );
    } else {
	int iw = pm.width() + 4;
	ih = pm.height();
	ir = QRect( cr.left() + 4, cr.top(), iw + 2, ih );
	tr = QRect( ir.right(), cr.top(), cr.width() - ir.right() - 4, cr.height() );
    }

    if ( selected && style().styleHint( QStyle::SH_ToolBox_SelectedPageTitleBold ) ) {
	QFont f( p->font() );
	f.setBold( TRUE );
	p->setFont( f );
    }

    QString txt;
    if ( p->fontMetrics().width(label) < tr.width() ) {
	txt = label;
    } else {
	txt = label.left( 1 );
	int ew = p->fontMetrics().width( "..." );
	int i = 1;
	while ( p->fontMetrics().width( txt ) + ew +
		p->fontMetrics().width( label[i] )  < tr.width() )
	    txt += label[i++];
	txt += "...";
    }

    if ( ih )
	p->drawPixmap( ir.left(), (height() - ih) / 2, pm );

    QToolBox *tb = (QToolBox*)parentWidget();

    const QColor* fill = 0;
    if ( selected &&
	 style().styleHint( QStyle::SH_ToolBox_SelectedPageTitleBold ) &&
	 tb->backgroundMode() != NoBackground )
	fill = &cg.color( QPalette::foregroundRoleFromMode( tb->backgroundMode() ) );

    int alignment = AlignLeft | AlignVCenter | ShowPrefix;
    if (!style().styleHint(QStyle::SH_UnderlineAccelerator, this))
	alignment |= NoAccel;
    style().drawItem( p, tr, alignment, cg,
		      isEnabled(), 0, txt, -1, fill );

    if ( !txt.isEmpty() && hasFocus() )
	style().drawPrimitive( QStyle::PE_FocusRect, p, tr, cg );
}
Esempio n. 9
0
void HierarchyList::insertObject( QObject *o, QListViewItem *parent )
{
    bool fakeMainWindow = false;
    if ( o && o->inherits( "QMainWindow" ) ) {
  QObject *cw = ( (QMainWindow*)o )->centralWidget();
  if ( cw ) {
      o = cw;
      fakeMainWindow = true;
  }
    }
    QListViewItem *item = 0;
    QString className = WidgetFactory::classNameOf( o );
    if ( o->inherits( "QLayoutWidget" ) ) {
  switch ( WidgetFactory::layoutType( (QWidget*)o ) ) {
  case WidgetFactory::HBox:
      className = "HBox";
      break;
  case WidgetFactory::VBox:
      className = "VBox";
      break;
  case WidgetFactory::Grid:
      className = "Grid";
      break;
  default:
      break;
  }
    }

    QString dbInfo;
#ifndef QT_NO_SQL
    dbInfo = MetaDataBase::fakeProperty( o, "database" ).toStringList().join(".");
#endif

    QString name = o->name();
    if ( o->parent() && o->parent()->inherits( "QWidgetStack" ) &&
   o->parent()->parent() ) {
  if ( o->parent()->parent()->inherits( "QTabWidget" ) )
      name = ( (QTabWidget*)o->parent()->parent() )->tabLabel( (QWidget*)o );
  else if ( o->parent()->parent()->inherits( "QWizard" ) )
      name = ( (QWizard*)o->parent()->parent() )->title( (QWidget*)o );
    }

    QToolBox *tb;
    if ( o->parent() && o->parent()->parent() &&
     (tb = ::qt_cast<QToolBox*>(o->parent()->parent()->parent())) )
    name = tb->itemLabel( tb->indexOf((QWidget*)o) );


    if ( fakeMainWindow ) {
  name = o->parent()->name();
  className = "QMainWindow";
    }

    if ( !parent )
  item = new HierarchyItem( HierarchyItem::Widget, this, name, className, dbInfo );
    else
  item = new HierarchyItem( HierarchyItem::Widget, parent, name, className, dbInfo );
    if ( !parent )
  item->setPixmap( 0, PixmapChooser::loadPixmap( "form.xpm", PixmapChooser::Mini ) );
    else if ( o->inherits( "QLayoutWidget") )
  item->setPixmap( 0, PixmapChooser::loadPixmap( "layout.xpm", PixmapChooser::Small ) );
    else
  item->setPixmap( 0, WidgetDatabase::iconSet( WidgetDatabase::idFromClassName( WidgetFactory::classNameOf( o ) ) ).
       pixmap( QIconSet::Small, QIconSet::Normal ) );
    ( (HierarchyItem*)item )->setWidget( (QWidget*)o );

    const QObjectList *l = o->children();
    if ( !l )
  return;
    QObjectListIt it( *l );
    it.toLast();
    for ( ; it.current(); --it ) {
  if ( !it.current()->isWidgetType() || ( (QWidget*)it.current() )->isHidden() )
      continue;
  if (  !formWindow->widgets()->find( (QWidget*)it.current() ) ) {
      if ( it.current()->parent() &&
     ( it.current()->parent()->inherits( "QTabWidget" ) ||
       it.current()->parent()->inherits( "QWizard" ) ) &&
     it.current()->inherits( "QWidgetStack" ) ) {
    QObject *obj = it.current();
    QObjectList *l2 = obj->queryList( "QWidget", 0, true, false );
    QDesignerTabWidget *tw = 0;
    QDesignerWizard *dw = 0;
    if ( it.current()->parent()->inherits( "QTabWidget" ) )
        tw = (QDesignerTabWidget*)it.current()->parent();
    if ( it.current()->parent()->inherits( "QWizard" ) )
      dw = (QDesignerWizard*)it.current()->parent();
    QWidgetStack *stack = (QWidgetStack*)obj;
    for ( obj = l2->last(); obj; obj = l2->prev() ) {
        if ( qstrcmp( obj->className(), "QWidgetStackPrivate::Invisible" ) == 0 ||
       ( tw && !tw->tabBar()->tab( stack->id( (QWidget*)obj ) ) ) ||
       ( dw && dw->isPageRemoved( (QWidget*)obj ) ) )
      continue;
        insertObject( obj, item );
    }
    delete l2;
      } else if ( ::qt_cast<QToolBox*>(it.current()->parent()) ) {
            if ( !::qt_cast<QScrollView*>(it.current()) )
            continue;
            QToolBox *tb = (QToolBox*)it.current()->parent();
            for ( int i = tb->count() - 1; i >= 0; --i )
            insertObject( tb->item( i ), item );
        }
      continue;
  }
  insertObject( it.current(), item );
    }

    if ( item->firstChild() )
  item->setOpen( true );
}
Esempio n. 10
0
QWidget* WidgetStyle::createWidget(const QString& name)
{
    if(name == "CheckBox")
    {
        QCheckBox* box = new QCheckBox("CheckBox");
        box->setObjectName("CheckBox");
        return setLayoutWidget({ box }, { 100, 30 });
    }
    else if(name == "ComboBox")
    {
        QComboBox* box = new QComboBox;
        box->addItem("Item1");
        box->addItem("Item3");
        box->addItem("Item3");
        box->setObjectName("ComboBox");
        return setLayoutWidget({ box }, { 70, 30 });
    }
    else if(name == "DateEdit")
    {
        QDateEdit* date = new QDateEdit;
        date->setObjectName("DateEdit");
        return setLayoutWidget({ date }, { 110, 40 });
    }
    else if(name == "DateTimeEdit")
    {
        QDateTimeEdit* date = new QDateTimeEdit;
        date->setObjectName("DateTimeEdit");
        return setLayoutWidget({ date }, { 160, 30 });
    }
    else if(name == "Dialog")
    {
        QDialog* dialog = new QDialog;
        dialog->setObjectName("Dialog");
        return setLayoutWidget({ dialog }, { 160, 110 });
    }
    else if(name == "DockWidget") //?
    {
        QDockWidget* widget = new QDockWidget;
        widget->setObjectName("DockWidget");
        widget->resize(61, 22);
        return widget;
    }
    else if(name == "DoubleSpinBox")
    {
        QDoubleSpinBox* box = new QDoubleSpinBox;
        box->setObjectName("DoubleSpinBox");
        return setLayoutWidget({ box }, { 90, 40 });
    }
    else if(name == "Frame") //??
    {
        QFrame* frame = new QFrame;
        frame->setObjectName("Frame");
        frame->resize(150, 100);
        return frame;
    }
    else if(name == "GroupBox")
    {
        QGroupBox* box = new QGroupBox("GroupBox");
        box->setObjectName("GroupBox");
        return setLayoutWidget({ box }, { 160, 110 });
    }
    else if(name == "Label")
    {
        QLabel* label = new QLabel("Label");
        label->setObjectName("Label");
        return setLayoutWidget({ label }, { 40, 20});
    }
    else if(name == "LineEdit")
    {
        QLineEdit* line = new QLineEdit;
        line->setObjectName("LineEdit");
        return setLayoutWidget({ line }, { 30, 30 });
    }
    else if(name == "ListView") //??
    {
        QListView* view = new QListView;
        view->setObjectName("ListView");
        view->resize(71, 71);
        return view;
    }
    else if(name == "ListWidget")
    {
        QListWidget* list = new QListWidget;
        list->setObjectName("ListWidget");
        for(int i = 0; i < 20; i++)
            list->addItem(QString("Item %1").arg(i));
        return setLayoutWidget({ list }, { 80, 80 });
    }
    else if(name == "MainWindow")
    {
        QMainWindow* window = new QMainWindow;
        window->setObjectName("MainWindow");
        return setLayoutWidget({ window }, { 160, 110 });
    }
    else if(name == "Menu")
    {
        QMenu* parentMenu = new QMenu;
        parentMenu->setObjectName("Menu");
        parentMenu->addMenu("Menu1");
        QMenu* menu1 = parentMenu->addMenu("Menu2");
        menu1->addMenu("Menu1");
        menu1->addMenu("Menu2");
        parentMenu->addSeparator();
        parentMenu->addMenu("Menu3");
        return setLayoutWidget({ parentMenu }, { 160, 110 });
    }
    else if(name == "MenuBar")
    {
        QMenuBar* bar = new QMenuBar;
        bar->setObjectName("QMenuBar");
        QMenu* menu1 = bar->addMenu("MenuBar1");
        menu1->addMenu("Menu1");
        menu1->addSeparator();
        menu1->addMenu("Menu2");
        QMenu* menu2 = bar->addMenu("MenuBar2");
        menu2->addMenu("Menu1");
        menu2->addSeparator();
        menu2->addMenu("Menu2");
        QMenu* menu3 = bar->addMenu("MenuBar3");
        menu3->addMenu("Menu1");
        menu3->addSeparator();
        menu3->addMenu("Menu2");
        return setLayoutWidget({ bar }, { 280, 60 });
    }
    else if(name == "ProgressBar")
    {
        QProgressBar* bar = new QProgressBar;
        bar->setObjectName("ProgressBar");
        bar->setRange(0, 100);
        bar->setValue(0);

        QTimer* timer = new QTimer(bar);
        this->connect(timer, &QTimer::timeout, this, [bar]()
        {
            if(bar->value() == 100)
                bar->setValue(0);
            else
                bar->setValue(bar->value() + 1);
        });
        timer->start(100);
        return setLayoutWidget({ bar }, { 110, 30 });
    }
    else if(name == "PushButton")
    {
        QPushButton* button = new QPushButton("PushButton");
        button->setObjectName("PushButton");
        return setLayoutWidget({ button }, { 125, 30 });
    }
    else if(name == "RadioButton")
    {
        QRadioButton* button = new QRadioButton("RadioButton");
        button->setObjectName("RadioButton");
        return setLayoutWidget({ button }, { 125, 30 });
    }
    else if(name == "ScrollBar")
    {
        QScrollBar* barH = new QScrollBar(Qt::Horizontal);
        QScrollBar* barV = new QScrollBar(Qt::Vertical);
        barH->setObjectName("ScrollBarH");
        barV->setObjectName("ScrollBarV");
        return setLayoutWidget({ barH, barV }, { 200, 100 });
    }
    else if(name == "Slider")
    {
        QSlider* sliderH = new QSlider(Qt::Horizontal);
        QSlider* sliderV = new QSlider(Qt::Vertical);
        sliderH->setObjectName("SliderH");
        sliderV->setObjectName("SliderV");
        return setLayoutWidget({ sliderH, sliderV }, { 200, 100 });
    }
    else if(name == "SpinBox")
    {
        QSpinBox* spinBox = new QSpinBox;
        spinBox->setObjectName("SpinBox");
        return setLayoutWidget({ spinBox }, { 60, 35 });
    }
    else if(name == "Splitter")
    {
        QSplitter* splitterV = new QSplitter(Qt::Vertical);
        QSplitter* splitterH = new QSplitter(Qt::Horizontal);
        splitterV->setObjectName("SplitterV");
        splitterH->setObjectName("SplitterH");
        splitterV->addWidget(new QPushButton("PushButton1"));
        splitterV->addWidget(new QPushButton("PushButton2"));
        splitterH->addWidget(splitterV);
        splitterH->addWidget(new QPushButton("PushButton3"));
        return setLayoutWidget({ splitterH }, { 250, 110 });
    }
    else if(name == "TabWidget")
    {
        QTabWidget* tab = new QTabWidget;
        tab->addTab(new QWidget, "Widget1");
        tab->addTab(new QWidget, "Widget2");
        tab->addTab(new QWidget, "Widget3");
        tab->setObjectName("TabWidget");
        return setLayoutWidget({ tab }, { 210, 110 });
    }
    else if(name == "TableView") //?
    {
        QTableView* view = new QTableView;
        view->setObjectName("TableView");
        view->resize(200, 100);
        return view;
    }
    else if(name == "TableWidget")
    {
        const int n = 100;
        QStringList list = { "one", "two", "three" };
        QTableWidget* table = new QTableWidget(n, n);
        table->setObjectName("TableWidget");
        table->setHorizontalHeaderLabels(list);
        table->setVerticalHeaderLabels(list);
        for(int i = 0; i < n; i++)
            for(int j = 0; j < n; j++)
                table->setItem(i, j, new QTableWidgetItem(QString("%1, %2").arg(i).arg(j)));
        return setLayoutWidget({ table }, { 210, 110 });
    }
    else if(name == "TextEdit")
    {
        QTextEdit* text = new QTextEdit;
        text->setObjectName("TextEdit");
        return setLayoutWidget({ text }, { 80, 80 });
    }
    else if(name == "TimeEdit")
    {
        QTimeEdit* time = new QTimeEdit;
        time->setObjectName("TimeEdit");
        return setLayoutWidget({ time }, { 80, 80 });
    }
    else if(name == "ToolButton")
    {
        QToolButton* button = new QToolButton;
        button->setText("ToolButton");
        button->setObjectName("ToolButton");
        return setLayoutWidget({ button }, { 95, 25 });
    }
    else if(name == "ToolBox")
    {
        QToolBox* box = new QToolBox;
        box->addItem(new QWidget, "Widget1");
        box->addItem(new QWidget, "Widget2");
        box->addItem(new QWidget, "Widget3");
        box->setObjectName("ToolBox");
        return setLayoutWidget({ box }, { 110, 180 });
    }
    else if(name == "TreeView") //?
    {
        QTreeView* tree = new QTreeView;
        tree->setObjectName("TreeView");
        tree->resize(200, 100);
        return tree;
    }
    else if(name == "TreeWidget")
    {
        QTreeWidget* tree = new QTreeWidget;
        tree->setObjectName("TreeWidget");
        tree->setHeaderLabels({ "Folders", "Used Space" });
        QTreeWidgetItem* item = new QTreeWidgetItem(tree);
        item->setText(0, "Local Disk");
        for(int i = 1; i < 20; i++)
        {
            QTreeWidgetItem* dir = new QTreeWidgetItem(item);
            dir->setText(0, "Directory" + QString::number(i));
            dir->setText(1, QString::number(i) + "MB");
        }
        tree->setItemExpanded(item, true);
        return setLayoutWidget({ tree }, { 210, 110 });
    }
    else if(name == "Widget")
    {
        QWidget* widget = new QWidget;
        widget->setObjectName("Widget");
        return setLayoutWidget({ widget }, { 210, 110 });
    }
    return nullptr;
}
MainApplication::MainApplication(QWidget *parent) : QWidget(parent)
{

	const int textSize = 12;
	const int toolBoxWidth = 160;
	const int toolBoxWidgetsWidth = 140;
	const int toolBoxSubWidgetsWidth = 120;
	QSize textEditSize = QSize(40, 30);
	int windowHeight = 500;
	int windowWidth = 800;

	/*---- Buttons ----*/
	QPushButton *rangeQueryButton = new QPushButton(tr("Range"));
	rangeQueryButton->setFont(QFont("Times", textSize, QFont::AnyStyle));

	QPushButton *radiusQueryButton = new QPushButton(tr("Radius"));
	radiusQueryButton->setFont(QFont("Times", textSize, QFont::AnyStyle));

	QPushButton *loadButton = new QPushButton(tr("Load"));
	loadButton->setFont(QFont("Times", textSize, QFont::AnyStyle));

	QPushButton *nnQueryButton = new QPushButton(tr("NN-Query"));
	nnQueryButton->setFont(QFont("Times", textSize, QFont::AnyStyle));

	QPushButton *smoothingButton = new QPushButton(tr("Smooth"));
	smoothingButton->setFont(QFont("Times", textSize, QFont::AnyStyle));

	QPushButton *distanceColorMapButton = new QPushButton(tr("ColorbyDist"));
	distanceColorMapButton->setFont(QFont("Times", textSize, QFont::AnyStyle));

	QPushButton *thinningButton = new QPushButton(tr("Thinning"));
	thinningButton->setFont(QFont("Times", textSize, QFont::AnyStyle));

	QPushButton *lineFittingButton = new QPushButton(tr("fit Line"));
	lineFittingButton->setFont(QFont("Times", textSize, QFont::AnyStyle));

	QPushButton *planeFittingButton = new QPushButton(tr("fit Plane"));
	planeFittingButton->setFont(QFont("Times", textSize, QFont::AnyStyle));

	QPushButton *sphereFittingButton = new QPushButton(tr("fit Sphere"));
	sphereFittingButton->setFont(QFont("Times", textSize, QFont::AnyStyle));

	connect(loadButton, SIGNAL(clicked()), this, SLOT(loadPoints()));
	connect(rangeQueryButton, SIGNAL(clicked()), this, SLOT(rangeQuery()));
	connect(radiusQueryButton, SIGNAL(clicked()), this, SLOT(radiusQuery()));
	connect(smoothingButton, SIGNAL(clicked()), this, SLOT(smoothPointCloud()));
	connect(nnQueryButton, SIGNAL(clicked()), this, SLOT(nnQuery()));
	connect(distanceColorMapButton, SIGNAL(clicked()), this, SLOT(colorPointsByDistance()));
	connect(thinningButton, SIGNAL(clicked()), this, SLOT(applyThinning()));
	connect(lineFittingButton, SIGNAL(clicked()), this, SLOT(fitLine()));
	connect(planeFittingButton, SIGNAL(clicked()), this, SLOT(fitPlane()));
	connect(sphereFittingButton, SIGNAL(clicked()), this, SLOT(fitSphere()));

	/*---- Labels ----*/ 
	labelCloudBounds = new QLabel("---", this);
	labelCloudBounds->setMaximumHeight(60);

	labelPoints = new QLabel("---", this);
	labelPoints->setMaximumHeight(60);

	labelTime = new QLabel("---", this);
	labelTime->setMaximumHeight(60);

	labelFitting = new QLabel("p: dir:", this);
	labelFitting->setMaximumHeight(120);

	/*---- Text Edits ----*/
	QDoubleValidator *validDouble = new QDoubleValidator();
	minXRange = new QLineEdit();
	minXRange->setMaximumSize(textEditSize);
	minXRange->setValidator(validDouble);
	maxXRange = new QLineEdit();
	maxXRange->setMaximumSize(textEditSize);
	maxXRange->setValidator(validDouble);
	minYRange = new QLineEdit();
	minYRange->setMaximumSize(textEditSize);
	minYRange->setValidator(validDouble);
	maxYRange = new QLineEdit();
	maxYRange->setMaximumSize(textEditSize);
	maxYRange->setValidator(validDouble);
	minZRange = new QLineEdit();
	minZRange->setMaximumSize(textEditSize);
	minZRange->setValidator(validDouble);
	maxZRange = new QLineEdit();
	maxZRange->setMaximumSize(textEditSize);
	maxZRange->setValidator(validDouble);

	xRadius = new QLineEdit();
	xRadius->setMaximumSize(textEditSize);
	xRadius->setValidator(validDouble);
	yRadius = new QLineEdit();
	yRadius->setMaximumSize(textEditSize);
	yRadius->setValidator(validDouble);
	zRadius = new QLineEdit();
	zRadius->setMaximumSize(textEditSize);
	zRadius->setValidator(validDouble);
	rRadius = new QLineEdit();
	rRadius->setMaximumSize(textEditSize);
	rRadius->setValidator(validDouble);

	xNeighbour = new QLineEdit();
	xNeighbour->setMaximumSize(textEditSize);
	xNeighbour->setValidator(validDouble);
	yNeighbour = new QLineEdit();
	yNeighbour->setMaximumSize(textEditSize);
	yNeighbour->setValidator(validDouble);
	zNeighbour = new QLineEdit();
	zNeighbour->setMaximumSize(textEditSize);
	zNeighbour->setValidator(validDouble);

	rSmoothing = new QLineEdit();
	rSmoothing->setMaximumSize(textEditSize);
	rSmoothing->setMaximumWidth(toolBoxSubWidgetsWidth);
	rSmoothing->setValidator(validDouble);

	rThinning = new QLineEdit();
	rThinning->setMaximumSize(textEditSize);
	rThinning->setMaximumWidth(toolBoxSubWidgetsWidth);
	rThinning->setValidator(validDouble);
	
	/*---- Tool Box and Tool Box Widgets ----*/
	QToolBox *toolBox = new QToolBox();

	//Load
	QVBoxLayout *layoutLoad = new QVBoxLayout();
	layoutLoad->addWidget(loadButton);
	QWidget* LoadWidget = new QWidget();
	LoadWidget->setLayout(layoutLoad);
	LoadWidget->setFixedWidth(toolBoxWidgetsWidth);
	toolBox->addItem(LoadWidget, "Load Data");
	
	// Range Query
	QGridLayout *layoutRangeTextEdits = new QGridLayout();
	layoutRangeTextEdits->addWidget(minXRange,0,0,0);
	layoutRangeTextEdits->addWidget(maxXRange,0,1,0);
	layoutRangeTextEdits->addWidget(minYRange,1,0,0);
	layoutRangeTextEdits->addWidget(maxYRange,1,1,0);
	layoutRangeTextEdits->addWidget(minZRange,2,0,0);
	layoutRangeTextEdits->addWidget(maxZRange,2,1,0);

	QWidget* RangeTextEditsWidget = new QWidget();
	RangeTextEditsWidget->setLayout(layoutRangeTextEdits);
	RangeTextEditsWidget->setFixedWidth(toolBoxSubWidgetsWidth);

	QVBoxLayout *layoutRange = new QVBoxLayout();
	layoutRange->addWidget(RangeTextEditsWidget);
	layoutRange->addWidget(rangeQueryButton);	

	QWidget* RangeWidget = new QWidget();
	RangeWidget->setLayout(layoutRange);
	RangeWidget->setFixedWidth(toolBoxWidgetsWidth);
	toolBox->addItem(RangeWidget, "Range Query");

	// Radius Query
	QGridLayout *layoutRadiusTextEdits = new QGridLayout();
	layoutRadiusTextEdits->addWidget(xRadius, 0, 0, 0);
	layoutRadiusTextEdits->addWidget(yRadius, 0, 1, 0);
	layoutRadiusTextEdits->addWidget(zRadius, 0, 3, 0);
	layoutRadiusTextEdits->addWidget(rRadius, 1, 1, 0);

	QWidget* RadiusTextEditsWidget = new QWidget();
	RadiusTextEditsWidget->setLayout(layoutRadiusTextEdits);
	RadiusTextEditsWidget->setFixedWidth(toolBoxSubWidgetsWidth);

	QVBoxLayout *layoutRadius = new QVBoxLayout();
	layoutRadius->addWidget(RadiusTextEditsWidget);
	layoutRadius->addWidget(radiusQueryButton);

	QWidget* RadiusWidget = new QWidget();
	RadiusWidget->setLayout(layoutRadius);
	RadiusWidget->setFixedWidth(toolBoxWidgetsWidth);
	toolBox->addItem(RadiusWidget, "Radius Query");

	// NN Query
	QGridLayout *layoutNNTextEdits = new QGridLayout();
	layoutNNTextEdits->addWidget(xNeighbour, 0, 0, 0);
	layoutNNTextEdits->addWidget(yNeighbour, 0, 1, 0);
	layoutNNTextEdits->addWidget(zNeighbour, 0, 3, 0);

	QWidget* NNTextEditsWidget = new QWidget();
	NNTextEditsWidget->setLayout(layoutNNTextEdits);
	NNTextEditsWidget->setFixedWidth(toolBoxSubWidgetsWidth);

	QVBoxLayout *layoutNN = new QVBoxLayout();
	layoutNN->addWidget(NNTextEditsWidget);
	layoutNN->addWidget(nnQueryButton);

	QWidget* NNWidget = new QWidget();
	NNWidget->setLayout(layoutNN);
	NNWidget->setFixedWidth(toolBoxWidgetsWidth);
	toolBox->addItem(NNWidget, "Nearest Neighbour");

	// Thinning
	QVBoxLayout *layoutThinning = new QVBoxLayout();
	layoutThinning->addWidget(rThinning);
	layoutThinning->addWidget(thinningButton);
	
	QWidget* ThinningWidget = new QWidget();
	ThinningWidget->setLayout(layoutThinning);
	ThinningWidget->setFixedWidth(toolBoxWidgetsWidth);
	toolBox->addItem(ThinningWidget, "Thinning");

	// Smoothing
	QVBoxLayout *layoutSmoothing = new QVBoxLayout();
	layoutSmoothing->addWidget(rSmoothing);
	layoutSmoothing->addWidget(smoothingButton);

	QWidget* SmoothingWidget = new QWidget();
	SmoothingWidget->setLayout(layoutSmoothing);
	SmoothingWidget->setFixedWidth(toolBoxWidgetsWidth);
	toolBox->addItem(SmoothingWidget, "Smoothing");

	// Fitting
	QVBoxLayout *layoutFitting = new QVBoxLayout();
	layoutFitting->addWidget(labelFitting);
	layoutFitting->addWidget(planeFittingButton);
	layoutFitting->addWidget(lineFittingButton);
	layoutFitting->addWidget(sphereFittingButton);

	QWidget* FittingWidget = new QWidget();
	FittingWidget->setLayout(layoutFitting);
	FittingWidget->setFixedWidth(toolBoxWidgetsWidth);
	toolBox->addItem(FittingWidget, "Fitting");

	// Color
	QVBoxLayout *layoutColorByDist = new QVBoxLayout();
	layoutColorByDist->addWidget(distanceColorMapButton);

	QWidget* ColorByDistWidget = new QWidget();
	ColorByDistWidget->setLayout(layoutColorByDist);
	ColorByDistWidget->setFixedWidth(toolBoxWidgetsWidth);
	toolBox->addItem(ColorByDistWidget, "Color by Distance");

	/*---- Data Group Box ----*/
	QGroupBox *dataBox = new QGroupBox(tr("Data"));
	QVBoxLayout *layoutDataBox = new QVBoxLayout;
	layoutDataBox->addWidget(labelPoints);
	layoutDataBox->addWidget(labelCloudBounds);
	dataBox->setLayout(layoutDataBox);

	/*---- Side Bar ----*/
	QVBoxLayout *layoutSideBar = new QVBoxLayout();

	layoutSideBar->addWidget(dataBox);
	layoutSideBar->addWidget(toolBox);
	layoutSideBar->addWidget(labelTime);
	
	QWidget* sideBarWidget = new QWidget();
	sideBarWidget->setLayout(layoutSideBar);
	sideBarWidget->setFixedWidth(toolBoxWidth);
	
	/*---- Main Widget ----*/
	glWidget = new MainGLWidget();
	glWidget->resize(windowWidth, windowHeight);
	glWidget->setMinimumWidth(windowWidth);
	glWidget->setMinimumHeight(windowHeight);

	QHBoxLayout *layoutMain = new QHBoxLayout();
	layoutMain->addWidget(glWidget);
	layoutMain->addWidget(sideBarWidget);

	setLayout(layoutMain);
}
Esempio n. 12
0
/**
 * Initialize this object.
 */
PakooView::PakooView( QWidget *parent )
: DCOPObject("pakooIface"), QWidget(parent)
{
	QHBoxLayout* topLayout = new QHBoxLayout( this );
	topLayout->setAutoAdd( true );

	hSplitter = new QSplitter( this );
	hSplitter->setOpaqueResize( true );

	QToolBox* toolBox = new QToolBox( hSplitter, "toolBox" );

	treeView = new PortageTreeView( 0, "treeView" );
	toolBox->addItem( treeView, TREEVIEWTEXT );
	toolBox->addItem( new QLabel("Action View", 0, "tempactionlabel"), ACTIONVIEWTEXT );
	toolBox->addItem( new QLabel("Config View", 0, "tempactionlabel"), CONFIGVIEWTEXT );

	vSplitter = new QSplitter( hSplitter );
	vSplitter->setOrientation(QSplitter::Vertical);
	vSplitter->setOpaqueResize( true );

	packageView = new PackageView(
		vSplitter, "packageView", portageTreeScanner.packageScanner()
	);

	packageInfoView = new PackageInfoView( vSplitter, "packageInfoView" );

	hSplitter->setResizeMode( toolBox, QSplitter::KeepSize );
	vSplitter->setResizeMode( packageInfoView->view(), QSplitter::KeepSize );

	vSplitter->setSizes( PakooConfig::vSplitterSizes() );
	hSplitter->setSizes( PakooConfig::hSplitterSizes() );


	//
	// Here comes the big connection creator
	//

	// Connect the package displaying widgets to work together
	connect(
		treeView,
		SIGNAL(selectionChanged(PortageTree*, PortageSettings*, const QString&, const QString&)),
		packageView->listView,
		SLOT(displayPackages(PortageTree*, PortageSettings*, const QString&, const QString&))
	);
	connect(
		packageView->listView, SIGNAL(selectionChanged(Package*)),
		packageInfoView, SLOT(displayPackage(Package*))
	);
	connect(
		packageView->listView, SIGNAL(selectionChanged(Package*, PackageVersion*)),
		packageInfoView, SLOT(displayPackage(Package*, PackageVersion*))
	);

	// Connect the package list view with the status bar,
	// so the latter one is updated properly
	connect(
		packageView->listView, SIGNAL(loadingPackageInfo(int,int)),
		this, SLOT(handleLoadingPackageInfo(int,int))
	);
	connect(
		packageView->listView, SIGNAL(finishedLoadingPackageInfo(int)),
		this, SLOT(handleFinishedLoadingPackageInfo(int))
	);
}
Esempio n. 13
0
int main (int argc, char** argv)
{
    QApplication app(argc, argv);
    QWidget wgt;
    QStringList list;
    list << "1" << "2" << "3" <<"4";

    QTableWidget mytable(4, 5);
    QTableWidgetItem* pw = NULL;
    mytable.setHorizontalHeaderLabels(list);
    mytable.setVerticalHeaderLabels(list);

    QBrush br(Qt::BackgroundColorRole, Qt::NoBrush);


    for(int i(0);i < 4; i++)
        for(int j(0); j < 5; j++){
            pw = new QTableWidgetItem(QString("%10, %11").arg(i).arg(j));
            pw->setBackground(br);
            //pw->setBackgroundColor(QColor::black());
            //pw->setBackgroundColor(&c);
            mytable.setItem(i, j, pw);
        }
    QComboBox* box = new QComboBox;
    box->addItems(list);
    QString str ("111");
    QTabWidget tab;
//    foreach(QString str, list){
//        tab.addTab(new QLabel(str, &tab), str);
//    }
    QLabel* la = new QLabel(str, &tab);
    tab.addTab(la, QString("1"));
    tab.addTab(new QLineEdit, str);
    QToolBox * gg = new QToolBox;
    gg->addItem(new QLineEdit, QString("222"));


    QLabel* plblDisplay = new QLabel;

    plblDisplay->setFrameStyle(QFrame::Box | QFrame::Raised);
    plblDisplay->setLineWidth(5);
    plblDisplay->setFixedHeight(50);

    QLabel* plblText = new QLabel("&Text:");

    QLineEdit* text = new QLineEdit;

    text->setInputMask("0-(000)-000-00-00");
    QLineEdit* text3 = new QLineEdit;

    text3->setInputMask("0-(000)-000-00-00");
    tab.addTab(text3, QString("0-(000)-000-00-00"));
    QWidget::connect(tab.widget(0), SIGNAL(objectNameChanged(QString)),tab.widget(2), SLOT(setEnabled(bool)));




    QTextEdit* text2 = new QTextEdit;
    text2->setHtml("<html><div><center><h3>I wrote the HTML</h3></center></div></html>");
    MyHighlighter* pHighlighter = new MyHighlighter(text2->document());

    QLineEdit* ptxt = new QLineEdit;
    plblText->setBuddy(ptxt);

    QObject::connect(ptxt, SIGNAL(textChanged(const QString&)),
    plblDisplay, SLOT(setText(const QString&))
    );

    QObject::connect(text, SIGNAL(textChanged(const QString&)),
    plblDisplay, SLOT(setText(const QString&))
    );

    QObject::connect(text2, SIGNAL(windowTitleChanged(QString)),
    plblDisplay, SLOT(setText(const QString&))
    );

    QLabel* plblPassword = new QLabel("&Password:");

    QLineEdit* ptxtPassword = new QLineEdit;

    plblPassword->setBuddy(ptxtPassword);
    ptxtPassword->setEchoMode(QLineEdit::Password);
    ptxtPassword->setValidator(new QIntValidator);

    QObject::connect(ptxtPassword, SIGNAL(textChanged(const QString&)),
    plblDisplay, SLOT(setText(const QString&))
    );
    //Layout setup
    QVBoxLayout* pvbxLayout = new QVBoxLayout;

    pvbxLayout->addWidget(plblDisplay);
    pvbxLayout->addWidget(plblText);
    pvbxLayout->addWidget(ptxt);
    pvbxLayout->addWidget(plblPassword);
    pvbxLayout->addWidget(ptxtPassword);
    pvbxLayout->addWidget(text);
    pvbxLayout->addWidget(text2);
    pvbxLayout->addWidget(box);
    pvbxLayout->addWidget(&tab);
    pvbxLayout->addWidget(&mytable);
    pvbxLayout->addWidget(gg);

    wgt.setLayout(pvbxLayout);
    wgt.show();
    return app.exec();
}