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
int main(int argc, char **argv){
  QApplication window(argc, argv);
  QWidget *mainwindow = new QWidget;

  //make main window
  mainwindow->setWindowTitle("window title");
  mainwindow->setMaximumSize(500,300);
  mainwindow->setMinimumSize(250,150);
  mainwindow->resize(400,240);

  //put label on mainwindow
  QLabel *my_label = new QLabel(mainwindow);
  my_label->setFrameStyle( QFrame::Panel | QFrame::Sunken );
  my_label->setText("Hello World.\nIt's fun to creat a program.");
  my_label->setAlignment(Qt::AlignVCenter | Qt::AlignHCenter);
  my_label->setGeometry(50,10,300,50);

  //put button on mainwindow
  QPushButton *my_button = new QPushButton("Quit", mainwindow);
  my_button->setGeometry(150,100,100,50);
  my_button->setFont(QFont("Times", 20, QFont::Bold));
  QObject::connect(my_button, SIGNAL(clicked()), qApp, SLOT(quit()));

  //window.setMainWidget(mainwindow); //Qt3
  mainwindow->show();
  return window.exec();
}
Example #3
0
QmlWindow::QmlWindow(QUrl qmlSource, bool persistent, QWidget *parent)
    : QWidget(parent)
    , m_view(0)
    , m_lastSize(QSize())
    , m_exiting(false)
    , m_persistent(persistent)
{
    QHBoxLayout *layout = new QHBoxLayout(this);
    layout->setContentsMargins(0,0,0,0);

    m_view = new QQuickView();
    m_view->connect(m_view->engine(), &QQmlEngine::quit, m_view, &QWindow::close);

//    QQmlApplicationEngine *engine = new QQmlApplicationEngine(qmlSource);

    QWidget *container = QWidget::createWindowContainer(m_view);
    container->setMinimumSize(100, 100);
    container->setMaximumSize(60000, 60000);
    container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    container->setFocusPolicy(Qt::StrongFocus);
    m_view->setSource(qmlSource);
    m_view->setResizeMode(QQuickView::SizeRootObjectToView);
    m_view->rootObject()->setProperty("window", QVariant::fromValue(this));

    layout->addWidget(container);
}
Example #4
0
QWidget *ItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option,
                                    const QModelIndex &index) const
{
    ItemWidget *w = m_cache[index.row()];
    QWidget *editor = ( w != NULL) ? w->createEditor(parent) : new QPlainTextEdit(parent);
    if (editor == NULL)
        return NULL;

    editor->setPalette(m_editorPalette);
    editor->setFont(m_editorFont);
    editor->setObjectName("editor");

    // maximal editor size
    QRect w_rect = parent->contentsRect();
    QRect o_rect = option.rect;
    QSize max_size( w_rect.width() - o_rect.left() - 4,
                    w_rect.height() - o_rect.top() - 4 );
    editor->setMaximumSize(max_size);
    editor->setMinimumSize(max_size);

    connect( editor, SIGNAL(destroyed()),
             this, SLOT(editingStops()) );
    connect( editor, SIGNAL(textChanged()),
             this, SLOT(editingStarts()) );

    return editor;
}
Example #5
0
QWidget *popup_param_t::do_create_widgets()
{
    QWidget *top = new QWidget();
    QLabel *label = new QLabel( top);
    menu_ = new QComboBox( top);
    menu_->setFocusPolicy( Qt::NoFocus);

    for( int i = 0; i < menu_items_.size(); ++i)
    {
        if( menu_items_[i] == "--")
            menu_->insertSeparator( menu_->count());
        else
            menu_->addItem( menu_items_[i].c_str());
    }

    QSize s = menu_->sizeHint();

    label->move( 0, 0);
    label->resize( app().ui()->inspector().left_margin() - 5, s.height());
    label->setAlignment( Qt::AlignRight | Qt::AlignVCenter);
    label->setText( name().c_str());
    label->setToolTip( id().c_str());

    menu_->move( app().ui()->inspector().left_margin(), 0);
    menu_->resize( s.width(), s.height());
    menu_->setCurrentIndex( get_value<int>( *this));
    menu_->setEnabled( enabled());
    connect( menu_, SIGNAL( currentIndexChanged( int)), this, SLOT( item_picked( int)));

    top->setMinimumSize( app().ui()->inspector().width(), s.height());
    top->setMaximumSize( app().ui()->inspector().width(), s.height());
    top->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed);
    return top;
}
Example #6
0
void ItemWidget::updateSize(const QSize &maximumSize)
{
    QWidget *w = widget();
    w->setMinimumSize(0, 0);
    w->setMaximumSize(maximumSize);
    w->adjustSize();
    w->setFixedSize( w->size() );
}
Example #7
0
SpecgramPianoroll::SpecgramPianoroll(const Setting &setting, int width, int noteHeight, QWidget *parent)
    : SpecgramView(setting, parent)
{
    _noteHeight = noteHeight;
    setSpecgram(_setting);
    QWidget *w = new stand::gui::VerticalPianoView(this);
    w->setMinimumSize(64, minimumHeight());
    w->setMaximumSize(64, minimumHeight());
}
Example #8
0
QWidget *float2_param_t::do_create_widgets()
{
    QWidget *top = new QWidget();
    QrLabel *label = new QrLabel( top);
    input0_ = new QrDoubleSpinBox( top);
    input1_ = new QrDoubleSpinBox( top);

    QSize s = input0_->sizeHint();

    label->move( 0, 0);
    label->resize( ui::inspector_t::Instance().left_margin() - 5, s.height());
    label->setAlignment( Qt::AlignRight | Qt::AlignVCenter);
    label->setText( name().c_str());

    int xpos = ui::inspector_t::Instance().left_margin();

    float low = absolute_min();
    float high = absolute_max();

    Imath::V2f v = relative_to_absolute( get_value<Imath::V2f>( *this));
    input0_->move( xpos, 0);
    input0_->resize( s.width(), s.height());
    input0_->setRange( low, high);
    input0_->setStep( step());
    input0_->setValue( v.x);
    input0_->setEnabled( enabled());
    connect( input0_, SIGNAL( calculatorValueChanged( double)), this, SLOT( value_changed( double)));
    connect( input0_, SIGNAL( spinBoxPressed()), this, SLOT( spinbox_pressed()));
    connect( input0_, SIGNAL( spinBoxMoved( double)), this, SLOT( spinbox_moved( double)));
    connect( input0_, SIGNAL( spinBoxReleased()), this, SLOT( spinbox_released()));
    xpos += ( s.width() + 5);

    input1_->move( xpos, 0);
    input1_->resize( s.width(), s.height());
    input1_->setRange( low, high);
    input1_->setStep( step());
    input1_->setValue( v.y);
    input1_->setEnabled( enabled());
    connect( input1_, SIGNAL( calculatorValueChanged( double)), this, SLOT( value_changed( double)));
    connect( input1_, SIGNAL( spinBoxPressed()), this, SLOT( spinbox_pressed()));
    connect( input1_, SIGNAL( spinBoxMoved( double)), this, SLOT( spinbox_moved( double)));
    connect( input1_, SIGNAL( spinBoxReleased()), this, SLOT( spinbox_released()));
    xpos += ( s.width() + 2);

    if( proportional())
    {
        create_proportional_button( top);

        if( prop_button_)
            prop_button_->move( xpos, 0);
    }

    top->setMinimumSize( ui::inspector_t::Instance().width(), s.height());
    top->setMaximumSize( ui::inspector_t::Instance().width(), s.height());
    top->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed);
    return top;
}
Example #9
0
void ItemWidget::updateSize(const QSize &maximumSize, int idealWidth)
{
    QWidget *w = widget();
    w->setMaximumSize(maximumSize);
    const int idealHeight = w->heightForWidth(idealWidth);
    const int maximumHeight = w->heightForWidth(maximumSize.width());
    if (idealHeight <= 0 && maximumHeight <= 0)
        w->resize(w->sizeHint());
    else if (idealHeight != maximumHeight)
        w->setFixedSize( maximumSize.width(), maximumHeight );
    else
        w->setFixedSize(idealWidth, idealHeight);
}
Example #10
0
void powerfulTabWidget::feed2Full()
{
    QTabBar* pTabBar = tabBar();
    if (NULL != pTabBar)
    {
        for (int iIndex = 0; iIndex < count(); ++iIndex)
        {
            QWidget *pWidget = new QWidget;
            pWidget->setMaximumSize(pTabBar->width() / count() / 2, pTabBar->height());
            pWidget->setMinimumSize(pTabBar->width() / count() / 2, pTabBar->height());
            pTabBar->setTabButton(iIndex, QTabBar::LeftSide, pWidget);
        }
    }
}
Example #11
0
int main(int argc,char **argv)
{
	QApplication app(argc,argv);

	QWidget mainWindow;
	mainWindow.setMinimumSize(400, 400);
	mainWindow.setMaximumSize(400, 400);
	
	QPushButton hw("Hello World",&mainWindow);
	hw.setGeometry(20,20,160,60);

	//app.setMainWidget(&mainWindow);
	mainWindow.show();
	return app.exec();
}
Example #12
0
Holoview::Holoview(const QMap<QString, QSize> &customSizeHints,
                QWidget *parent, Qt::WindowFlags flags)
	: MainWindow(customSizeHints, parent, flags)
{
	//ui.setupUi(this);

	QSurfaceFormat format;
    format.setSamples(4);
	window.setFormat(format);
    window.resize(640, 480);	
	window.setAnimating(true);

	QWidget *oglContainer = QWidget::createWindowContainer(&window);
	oglContainer->setMinimumSize(640,480);
	oglContainer->setMaximumSize(1280,960);
	oglContainer->setFocusPolicy(Qt::TabFocus);	
	setCentralWidget(oglContainer);
}
Example #13
0
void QmlWindow::finalizeView()
{
    QWidget *container = QWidget::createWindowContainer(m_view);
    container->setMinimumSize(100, 100);
    container->setMaximumSize(60000, 60000);
    container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    container->setFocusPolicy(Qt::StrongFocus);

    m_view->setSource(m_source);
    m_view->setResizeMode(QQuickView::SizeRootObjectToView);

    QVBoxLayout *layout = new QVBoxLayout(this);
    layout->setContentsMargins(0,0,0,0);
    layout->setSpacing(0);
#ifndef Q_OS_MACX
    layout->addWidget(m_menuBar);
#endif
    layout->addWidget(container);
}
Example #14
0
QWidget *aspect_ratio_param_t::do_create_widgets()
{
    QWidget *top = new QWidget();
    QLabel *label = new QLabel( top);
    menu_ = new QComboBox( top);
    input_ = new ui::double_spinbox_t( top);

    QSize s = input_->sizeHint();

    label->move( 0, 0);
    label->resize( app().ui()->inspector().left_margin() - 5, s.height());
    label->setAlignment( Qt::AlignRight | Qt::AlignVCenter);
    label->setText( name().c_str());
    label->setToolTip( id().c_str());

    input_->move( app().ui()->inspector().left_margin(), 0);
    float val = get_value<float>( *this);
    input_->setValue( val);
    input_->setEnabled( enabled());
    input_->setDecimals( 3);
    input_->setMinimum( 0.1);
    input_->setTrackMouse( false);
    connect( input_, SIGNAL( valueChanged( double)), this, SLOT( value_changed( double)));

    menu_->setFocusPolicy( Qt::NoFocus);

    for( int i = 0; i < presets().size(); ++i)
        menu_->addItem( presets()[i].first.c_str());

    menu_->addItem( "Custom");

    menu_->move( app().ui()->inspector().left_margin() + s.width() + 5, 0);
    menu_->setEnabled( enabled());
    menu_->setCurrentIndex( index_for_value( val));
    connect( menu_, SIGNAL( currentIndexChanged( int)), this, SLOT( item_picked( int)));

    top->setMinimumSize( app().ui()->inspector().width(), s.height());
    top->setMaximumSize( app().ui()->inspector().width(), s.height());
    top->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed);
    return top;
}
Example #15
0
QWidget *bool_param_t::do_create_widgets()
{
    QWidget *w = new QWidget();

    button_ = new QCheckBox( w);
    button_->setFocusPolicy( Qt::NoFocus);
    button_->setText( name().c_str());
    QSize s = button_->sizeHint();

    w->setMinimumSize( app().ui()->inspector().width(), s.height());
    w->setMaximumSize( app().ui()->inspector().width(), s.height());

    button_->move( app().ui()->inspector().left_margin(), 0);
    button_->resize( s.width(), s.height());
    button_->setChecked( get_value<bool>( *this));
    button_->setEnabled( enabled());
    button_->setToolTip( id().c_str());

    connect( button_, SIGNAL( stateChanged( int)), this, SLOT( button_checked( int)));
    return w;
}
Example #16
0
RangeSlider::RangeSlider(QWidget *parent) : QWidget(parent)
{
    rightLabel = new QLabel();
    leftLabel = new QLabel();

    mainLayout = new QHBoxLayout();
    refParent = parent;

    QQuickView *view = new QQuickView();
    QWidget *container = QWidget::createWindowContainer(view, this);
    container->setMinimumSize(40,40);
    container->setMaximumSize(400, 50);
    container->setFocusPolicy(Qt::TabFocus);
    view->setSource(QUrl("../applicationOpenImu/app/rangeSlider.qml"));

    // Get pointers to first and second values in range slider
    QQuickItem *object = view->rootObject();

    QObject::connect(object, SIGNAL(firstUpdated(QVariant)),parent, SLOT(firstUpdated(QVariant)));
    QObject::connect(object, SIGNAL(secondUpdated(QVariant)),parent, SLOT(secondUpdated(QVariant)));

    mainLayout->addWidget(leftLabel);
    mainLayout->addWidget(container);
    mainLayout->addWidget(rightLabel);
    mainLayout->setSpacing(0);
    this->setLayout(mainLayout);

    QSizePolicy spLeft(QSizePolicy::Preferred, QSizePolicy::Preferred);
    spLeft.setHorizontalStretch(1);
    leftLabel->setSizePolicy(spLeft);
    rightLabel->setSizePolicy(spLeft);

    QSizePolicy spRight(QSizePolicy::Preferred, QSizePolicy::Preferred);
    spRight.setHorizontalStretch(4);
    container->setSizePolicy(spRight);
}
Example #17
0
QWidget *se_expr_param_t::do_create_widgets()
{
    QWidget *top = new QWidget();
    QLabel *label = new QLabel( top);
    ui::line_edit_t *tmp = new ui::line_edit_t();
    QSize s = tmp->sizeHint();
    delete tmp;

    label->move( 0, 0);
    label->resize( app().ui()->inspector().left_margin() - 5, s.height());
    label->setAlignment( Qt::AlignRight | Qt::AlignVCenter);
    label->setText( name().c_str());
    label->setToolTip( id().c_str());

    int width = app().ui()->inspector().width() - app().ui()->inspector().left_margin() - 10;
    int height = 0;

    std::string str = get_value<std::string>( *this);
    multi_input_ = new ui::text_edit_t( top);
    multi_input_->move( app().ui()->inspector().left_margin(), height);
    multi_input_->resize( width, s.height() * 7);
    multi_input_->setEnabled( enabled());
    multi_input_->setPlainText( str.c_str());

    multi_input_->setContextMenuPolicy( Qt::CustomContextMenu);
    connect( multi_input_, SIGNAL( textHasChanged()), this, SLOT( text_changed()));
    connect( multi_input_, SIGNAL( customContextMenuRequested( const QPoint&)), this, SLOT( show_context_menu( const QPoint&)));
    height += multi_input_->height();

    top->setMinimumSize( app().ui()->inspector().width(), height);
    top->setMaximumSize( app().ui()->inspector().width(), height);
    top->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed);

    top_widget_ = top;
    return top;
}
/*
 * This program accepts the following command line options
 * -lab string: name of file with lab description (default, stdin);
 * -grid string: name of file with start position grid (default, stdin);
 * -log string: name of log file (default, server.log);
 * -nc real: compass noise coeficient (default, 0.0);
 * -nb real: beacon noise coeficient (default, 0.0);
 * -ni real: infrared noise coeficient (default, 0.0);
 * -nm real: motors noise coeficient (default, 0.0);
 * -st integer: simulation time, in number of cycle time units (default, 3000);
 * -ct integer: cycle time, in miliseconds (default, 75).
 */
int main(int argc, char *argv[])
{
	/* Copyright and wellcome message */
	printf(" CiberRato 2013 Logplayer\n Copyright (C) 2003-2013 Universidade de Aveiro\n");

	/* extract option values */
	char *logFilename = 0;
	int port = 6000;

    QApplication app(argc,argv);


    //cout << "Parsing command line..."

    int p=1;
	while (p < argc) 
	{
        if (strcmp(argv[p], "-log") == 0) {
            if (p+1 < argc) {
                logFilename = argv[p+1];
                p+=2;
            }
            else CommandLineError();
		}
        else if (strcmp(argv[p], "-port") == 0)	{
            if (p+1 < argc) {
                sscanf(argv[p+1], "%d", &port);
                p+=2;
            }
            else CommandLineError();
		}
        else {
            CommandLineError();
		}
	}
	
	//cout << " done.\n";

	/* create lab object and parse lab file */
	//cout << "Creating lab object...";
	QXmlInputSource *source;

    if(logFilename) {
        QFile srcFile(logFilename);

        if(!srcFile.exists())
        {
            cerr << "Could not open log file " << logFilename << "\n";
            QMessageBox::critical(0,"Error", QString("Could not open log file ") + logFilename,
                                  QMessageBox::Ok,Qt::NoButton,Qt::NoButton);
            return 1;
        }
        if ((source = new QXmlInputSource(&srcFile)) == 0)
        {
            cerr << "Fail sourcing log file\n";
                        QMessageBox::critical(0,"Error", QString("Failed sourcing log file "),
                               QMessageBox::Ok,Qt::NoButton,Qt::NoButton);
            return 1;
        }

        cbLogHandler *logHandler = new cbLogHandler(&xmlParser);
        xmlParser.setContentHandler(logHandler);

        if( ! xmlParser.parse(*source) )
        {
            cerr << "Error parsing log file\n";
                        QMessageBox::critical(0,"Error", QString("Error parsing log file"),
                                              QMessageBox::Ok,Qt::NoButton,Qt::NoButton);
            return 1;
        }
        vector< vector <cbRobot> > *log = logHandler->parsedLog();
        logplayer.setLog(log);
        if(logHandler->getLab()!=0)
            logplayer.setLab(logHandler->getLab());
        else
        {
            cerr << "Error parsing log file\n";
            QMessageBox::critical(0,"Error", QString("Error parsing log file"),
                                  QMessageBox::Ok,Qt::NoButton,Qt::NoButton);
            return 1;
        }
        if(logHandler->getGrid()!=0)
            logplayer.setGrid(logHandler->getGrid());
        else
        {
            cerr << "Error parsing log file\n";
            QMessageBox::critical(0,"Error", QString("Error parsing log file"),
                                  QMessageBox::Ok,Qt::NoButton,Qt::NoButton);
            return 1;
        }
        if(logHandler->getParameters()!=0)
            logplayer.setParameters(logHandler->getParameters());
        else
        {
            cerr << "Error parsing log file\n";
            QMessageBox::critical(0,"Error", QString("Error parsing log file"),
                                  QMessageBox::Ok,Qt::NoButton,Qt::NoButton);
            return 1;
        }
        delete logHandler;
        delete source;
    }
    else {
        CommandLineError();
        return 1;
    }

	/* preparing the receptionist */
	//cout << "Launching the receptionist...";
	cbReceptionist *receptionist = new cbReceptionist(port);
	if (receptionist == 0 || receptionist->bad())
    {
        QMessageBox::critical(0,"Error", QString("Error creating socket"),
                              QMessageBox::Ok,Qt::NoButton,Qt::NoButton);
		//cerr << "fail\n";
		return 1;
	}
	receptionist->setXmlParser(&xmlParser);
	logplayer.setReceptionist(receptionist);
	//cout << " done.\n";
	
	/* preparing the random generator */
#ifndef MicWindows
	srand(getpid());
#else
	srand(_getpid());
#endif

    /* preparing ALARM timer */
	QTimer timer;
	timer.start(logplayer.cycleTime());
	QObject::connect(&timer,SIGNAL(timeout()),&logplayer,SLOT(step()));

    QWidget *gui = new QWidget;
    Ui::logplayerGUI ui;
    ui.setupUi(gui);

    QObject::connect(ui.QuitButton,SIGNAL(clicked()),&app,SLOT(quit()));
    logplayer.setGUI(&ui);
    gui->setMaximumSize(gui->size());
    gui->setMinimumSize(gui->size());
    gui->show();

	app.exec();

	return 0;
}
Example #19
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent), ui(new Ui::MainWindow),
    logNewMessages(0), logHasErrors(false), showNewLogNumber(true)
{
    ui->setupUi(this);

    setWindowIcon(QIcon(c_icon_app));
    setWindowTitle(c_qtau_name);
    setAcceptDrops(true);
    setContextMenuPolicy(Qt::NoContextMenu);

    //-----------------------------------------

    QLabel *meterLabel = new QLabel(QString("%1/%2") .arg(ns.notesInBar).arg(ns.noteLength), this);
    QLabel *tempoLabel = new QLabel(QString("%1 %2").arg(ns.tempo).arg(tr("bpm")),           this);

    QHBoxLayout *bpmHBL = new QHBoxLayout();
    bpmHBL->setContentsMargins(0,0,0,0);
    bpmHBL->addSpacing(5);
    bpmHBL->addWidget(meterLabel);
    bpmHBL->addWidget(tempoLabel);
    bpmHBL->addSpacing(5);

    QFrame *tempoPanel = new QFrame(this);
    tempoPanel->setMinimumSize(c_piano_min_width, c_meter_min_height);
    tempoPanel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
    tempoPanel->setContentsMargins(1,0,1,1);
    tempoPanel->setFrameStyle(QFrame::Panel | QFrame::Raised);

    tempoPanel->setLayout(bpmHBL);

    meter = new qtauMeterBar(this);
    meter->setMinimumHeight(c_meter_min_height);
    meter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
    meter->setContentsMargins(0,0,0,0);

    piano = new qtauPiano(ui->centralWidget);
    piano->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding);
    piano->setMinimumSize(c_piano_min_width, c_piano_min_height);
    piano->setContentsMargins(0,0,0,0);

    zoom = new QSlider(Qt::Horizontal, ui->centralWidget);
    zoom->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
    zoom->setRange(0, c_zoom_num - 1);
    zoom->setSingleStep(1);
    zoom->setPageStep(1);
    zoom->setValue(cdef_zoom_index);
    zoom->setMinimumWidth(c_piano_min_width);
    zoom->setGeometry(0,0,c_piano_min_width,10);
    zoom->setContentsMargins(0,0,0,0);

    noteEditor = new qtauNoteEditor(ui->centralWidget);
    noteEditor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    noteEditor->setContentsMargins(0,0,0,0);

    hscr = new QScrollBar(Qt::Horizontal, ui->centralWidget);
    vscr = new QScrollBar(Qt::Vertical,   ui->centralWidget);

    hscr->setContentsMargins(0,0,0,0);
    vscr->setContentsMargins(0,0,0,0);
    hscr->setRange(0, ns.note.width() * ns.notesInBar * cdef_bars);
    vscr->setRange(0, ns.note.height() * 12 * ns.numOctaves);
    hscr->setSingleStep(ns.note.width());
    vscr->setSingleStep(ns.note.height());
    hscr->setContextMenuPolicy(Qt::NoContextMenu);
    vscr->setContextMenuPolicy(Qt::NoContextMenu);

    //---- vocal and music waveform panels, hidden until synthesized (vocal wave) and/or loaded (music wave)

    QScrollBar *dummySB = new QScrollBar(this);
    dummySB->setOrientation(Qt::Vertical);
    dummySB->setRange(0,0);
    dummySB->setEnabled(false);

    QFrame *vocalControls = new QFrame(this);
    vocalControls->setContentsMargins(0,0,0,0);
    vocalControls->setMinimumSize(c_piano_min_width, c_waveform_min_height);
    vocalControls->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding);
    vocalControls->setFrameStyle(QFrame::Panel | QFrame::Raised);

    vocalWave = new qtauWaveform(this);
    vocalWave->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
    vocalWave->setMinimumHeight(c_waveform_min_height);
    vocalWave->setContentsMargins(0,0,0,0);

    QHBoxLayout *vocalWaveL = new QHBoxLayout();
    vocalWaveL->setContentsMargins(0,0,0,0);
    vocalWaveL->setSpacing(0);
    vocalWaveL->addWidget(vocalControls);
    vocalWaveL->addWidget(vocalWave);
    vocalWaveL->addWidget(dummySB);

    vocalWavePanel = new QWidget(this);
    vocalWavePanel->setContentsMargins(0,0,0,0);
    vocalWavePanel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);

    vocalWavePanel->setLayout(vocalWaveL);
    vocalWavePanel->setVisible(false);

    //---------

    QScrollBar *dummySB2 = new QScrollBar(this);
    dummySB2->setOrientation(Qt::Vertical);
    dummySB2->setRange(0,0);
    dummySB2->setEnabled(false);

    QFrame *musicControls = new QFrame(this);
    musicControls->setContentsMargins(0,0,0,0);
    musicControls->setMinimumSize(c_piano_min_width, c_waveform_min_height);
    musicControls->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding);
    musicControls->setFrameStyle(QFrame::Panel | QFrame::Raised);

    musicWave = new qtauWaveform(this);
    musicWave->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
    musicWave->setMinimumHeight(c_waveform_min_height);
    musicWave->setContentsMargins(0,0,0,0);

    QHBoxLayout *musicWaveL = new QHBoxLayout();
    musicWaveL->setContentsMargins(0,0,0,0);
    musicWaveL->setSpacing(0);
    musicWaveL->addWidget(musicControls);
    musicWaveL->addWidget(musicWave);
    musicWaveL->addWidget(dummySB2);

    musicWavePanel = new QWidget(this);
    musicWavePanel->setContentsMargins(0,0,0,0);
    musicWavePanel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);

    musicWavePanel->setLayout(musicWaveL);
    musicWavePanel->setVisible(false);

    //---- notes' dynamics setup area --------------

    QGridLayout *dynBtnL = new QGridLayout();

    QString btnNames[c_dynbuttons_num] = {"VEL", "DYN", "BRE", "BRI", "CLE", "OPE", "GEN", "POR", "PIT", "PBS"};

    for (int i = 0; i < c_dynbuttons_num; ++i)
    {
        qtauDynLabel *l = new qtauDynLabel(btnNames[i], this);
        l->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
        dynBtnL->addWidget(l, i / 2, i % 2, 1, 1);

        l->setStyleSheet(c_dynlbl_css_off);
        l->setFrameStyle(QFrame::Box);
        l->setLineWidth(1);

        connect(l, SIGNAL(leftClicked()),  SLOT(dynBtnLClicked()));
        connect(l, SIGNAL(rightClicked()), SLOT(dynBtnRClicked()));
    }

    dynBtnL->setRowStretch(c_dynbuttons_num / 2, 100);

    QFrame *dynBtnPanel = new QFrame(this);
    dynBtnPanel->setContentsMargins(0,0,0,0);
    dynBtnPanel->setMinimumSize(c_piano_min_width, c_drawzone_min_height);
    dynBtnPanel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding);
    dynBtnPanel->setFrameStyle(QFrame::Panel | QFrame::Raised);

    dynBtnPanel->setLayout(dynBtnL);

    drawZone = new qtauDynDrawer(ui->centralWidget);
    drawZone->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
    drawZone->setMinimumHeight(c_drawzone_min_height);
    drawZone->setContentsMargins(0,0,0,0);

    QScrollBar *dummySB3 = new QScrollBar(this);
    dummySB3->setOrientation(Qt::Vertical);
    dummySB3->setRange(0,0);
    dummySB3->setEnabled(false);

    QHBoxLayout *singParamsL = new QHBoxLayout();
    singParamsL->setContentsMargins(0,0,0,0);
    singParamsL->setSpacing(0);
    singParamsL->addWidget(dynBtnPanel);
    singParamsL->addWidget(drawZone);
    singParamsL->addWidget(dummySB3);

    drawZonePanel = new QWidget(this);
    drawZonePanel->setContentsMargins(0,0,0,0);
    drawZonePanel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);

    drawZonePanel->setLayout(singParamsL);

    //---- Combining editor panels into hi-level layout ------

    QGridLayout *gl = new QGridLayout();
    gl->setContentsMargins(0,0,0,0);
    gl->setSpacing(0);

    gl->addWidget(tempoPanel, 0, 0, 1, 1);
    gl->addWidget(meter,      0, 1, 1, 1);
    gl->addWidget(piano,      1, 0, 1, 1);
    gl->addWidget(zoom,       2, 0, 1, 1);
    gl->addWidget(noteEditor, 1, 1, 1, 1);
    gl->addWidget(hscr,       2, 1, 1, 1);
    gl->addWidget(vscr,       1, 2, 1, 1);

    QWidget *editorUpperPanel = new QWidget(this);
    editorUpperPanel->setContentsMargins(0,0,0,0);
    editorUpperPanel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    editorUpperPanel->setMaximumSize(9000,9000);

    editorUpperPanel->setLayout(gl);

    editorSplitter = new QSplitter(Qt::Vertical, this);
    editorSplitter->setContentsMargins(0,0,0,0);
    editorSplitter->addWidget(editorUpperPanel);
    editorSplitter->addWidget(vocalWavePanel);
    editorSplitter->addWidget(musicWavePanel);
    editorSplitter->addWidget(drawZonePanel);
    editorSplitter->setStretchFactor(0, 1);
    editorSplitter->setStretchFactor(1, 0);
    editorSplitter->setStretchFactor(2, 0);
    editorSplitter->setStretchFactor(3, 0);

    QVBoxLayout *edVBL = new QVBoxLayout();
    edVBL->setContentsMargins(0,0,0,0);
    edVBL->addWidget(editorSplitter);

    QWidget *editorPanel = new QWidget(this);
    editorPanel->setContentsMargins(0,0,0,0);
    editorPanel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    editorPanel->setMaximumSize(9000,9000);

    editorPanel->setLayout(edVBL);

    //---- Voicebank setup tab ---------------------

    QWidget *voicesPanel = new QWidget(this);
    voicesPanel->setContentsMargins(0,0,0,0);
    voicesPanel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    voicesPanel->setMaximumSize(9000,9000);

    //---- Plugins setup tab -----------------------

    QWidget *pluginsPanel = new QWidget(this);
    pluginsPanel->setContentsMargins(0,0,0,0);
    pluginsPanel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    pluginsPanel->setMaximumSize(9000,9000);

    //---- Settings tab ----------------------------

    QWidget *settingsPanel = new QWidget(this);
    settingsPanel->setContentsMargins(0,0,0,0);
    settingsPanel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    settingsPanel->setMaximumSize(9000,9000);

    //---- Documentation tab -----------------------

    QWidget *docsPanel = new QWidget(this);
    docsPanel->setContentsMargins(0,0,0,0);
    docsPanel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    docsPanel->setMaximumSize(9000,9000);

    QTextEdit *docpad = new QTextEdit(this);
    docpad->setReadOnly(true);
    docpad->setUndoRedoEnabled(false);
    docpad->setContextMenuPolicy(Qt::NoContextMenu);

    QFile embeddedDocTxt(c_doc_txt);

    if (embeddedDocTxt.open(QFile::ReadOnly))
    {
        QTextStream ts(&embeddedDocTxt);
        ts.setAutoDetectUnicode(true);
        ts.setCodec("UTF-8");

        docpad->setText(ts.readAll());
        embeddedDocTxt.close();
    }

    QGridLayout *docL = new QGridLayout();
    docL->setContentsMargins(0,0,0,0);
    docL->addWidget(docpad, 0, 0, 1, 1);

    docsPanel->setLayout(docL);

    //---- Log tab ---------------------------------

    QWidget *logPanel = new QWidget(this);
    logPanel->setContentsMargins(0,0,0,0);
    logPanel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    logPanel->setMaximumSize(9000,9000);

    logpad = new QTextEdit(this);
    logpad->setReadOnly(true);
    logpad->setUndoRedoEnabled(false);
    logpad->setContextMenuPolicy(Qt::NoContextMenu);
    logpad->setStyleSheet("p, pre { white-space: 1.2; }");

    QGridLayout *logL = new QGridLayout();
    logL->setContentsMargins(0,0,0,0);
    logL->addWidget(logpad, 0, 0, 1, 1);

    logPanel->setLayout(logL);

    //---- Combining tabs togeter ------------------

    tabs = new QTabWidget(this);
    tabs->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    tabs->setContentsMargins(0,0,0,0);
    tabs->setMaximumSize(9000, 9000);
    tabs->setTabPosition(QTabWidget::South);
    tabs->setMovable(false); // just to be sure

    tabs->addTab(editorPanel,   QIcon(c_icon_editor),   tr("Editor"));
    tabs->addTab(voicesPanel,   QIcon(c_icon_voices),   tr("Voices"));
    tabs->addTab(pluginsPanel,  QIcon(c_icon_plugins),  tr("Plugins"));
    tabs->addTab(settingsPanel, QIcon(c_icon_settings), tr("Settings"));
    tabs->addTab(docsPanel,     QIcon(c_icon_doc),      tr("Documentation"));
    tabs->addTab(logPanel,      QIcon(c_icon_log),      tr("Log"));

    tabs->widget(0)->setContentsMargins(0,0,0,0);
    tabs->widget(1)->setContentsMargins(0,0,0,0);
    tabs->widget(2)->setContentsMargins(0,0,0,0);
    tabs->widget(3)->setContentsMargins(0,0,0,0);
    tabs->widget(4)->setContentsMargins(0,0,0,0);
    tabs->widget(5)->setContentsMargins(0,0,0,0);

    logTabTextColor = tabs->tabBar()->tabTextColor(5);

    connect(tabs, SIGNAL(currentChanged(int)), SLOT(onTabSelected(int)));

    QVBoxLayout *vbl = new QVBoxLayout();
    vbl->setContentsMargins(0,0,0,0);
    vbl->addWidget(tabs);
    ui->centralWidget->setContentsMargins(0,0,0,0);
    ui->centralWidget->setLayout(vbl);

    //---- Toolbars --------------------------------

    QToolBar *fileTB   = new QToolBar("Fileops",  this);
    QToolBar *playerTB = new QToolBar("Playback", this);
    QToolBar *toolsTB  = new QToolBar("Toolset",  this);

    fileTB  ->setFloatable(false);
    playerTB->setFloatable(false);
    toolsTB ->setFloatable(false);

    fileTB->addAction(ui->actionSave);
    fileTB->addAction(ui->actionSave_audio_as);
    fileTB->addAction(ui->actionUndo);
    fileTB->addAction(ui->actionRedo);

    playerTB->addAction(ui->actionPlay);
    playerTB->addAction(ui->actionStop);
    playerTB->addAction(ui->actionBack);
    playerTB->addAction(ui->actionRepeat);

    volume = new QSlider(Qt::Horizontal, this);
    volume->setMaximum(100);
    volume->setSingleStep(1);
    volume->setPageStep(1);
    volume->setValue(settings.value(c_key_sound, 50).toInt());
    volume->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
    connect(playerTB, SIGNAL(orientationChanged(Qt::Orientation)), volume, SLOT(setOrientation(Qt::Orientation)));

    muteBtn = new QAction(QIcon(c_icon_sound), "", this);
    muteBtn->setCheckable(true);
    connect(muteBtn, SIGNAL(toggled(bool)), SLOT(onMute(bool)));

    playerTB->addWidget(volume);
    playerTB->addAction(muteBtn);

    QComboBox *quantizeCombo = new QComboBox(this);
    QComboBox *lengthCombo   = new QComboBox(this);
    quantizeCombo->addItems(QStringList() << "Q/4" << "Q/8" << "Q/16" << "Q/32" << "Q/64");
    lengthCombo  ->addItems(QStringList() << "♪/4" << "♪/8" << "♪/16" << "♪/32" << "♪/64");
    quantizeCombo->setCurrentIndex(3);
    lengthCombo  ->setCurrentIndex(3);

    toolsTB->addAction(ui->actionEdit_Mode);
    toolsTB->addAction(ui->actionGrid_Snap);
    toolsTB->addSeparator();
    toolsTB->addWidget(quantizeCombo);
    toolsTB->addWidget(lengthCombo);

    addToolBar(fileTB);
    addToolBar(playerTB);
    addToolBar(toolsTB);

    toolbars.append(fileTB);
    toolbars.append(playerTB);
    toolbars.append(toolsTB);

    //----------------------------------------------
    connect(quantizeCombo, SIGNAL(currentIndexChanged(int)), SLOT(onQuantizeSelected(int)));
    connect(lengthCombo,   SIGNAL(currentIndexChanged(int)), SLOT(onNotelengthSelected(int)));

    connect(vsLog::instance(), &vsLog::message,             this, &MainWindow::onLog);

    connect(piano,      &qtauPiano      ::heightChanged,    this, &MainWindow::onPianoHeightChanged);
    connect(noteEditor, &qtauNoteEditor ::widthChanged,     this, &MainWindow::onNoteEditorWidthChanged);

    connect(meter,      &qtauMeterBar   ::scrolled,         this, &MainWindow::notesHScrolled);
    connect(piano,      &qtauPiano      ::scrolled,         this, &MainWindow::notesVScrolled);
    connect(drawZone,   &qtauDynDrawer  ::scrolled,         this, &MainWindow::notesHScrolled);
    connect(noteEditor, &qtauNoteEditor ::vscrolled,        this, &MainWindow::notesVScrolled);
    connect(noteEditor, &qtauNoteEditor ::hscrolled,        this, &MainWindow::notesHScrolled);
    connect(vocalWave,  &qtauWaveform   ::scrolled,         this, &MainWindow::notesHScrolled);
    connect(musicWave,  &qtauWaveform   ::scrolled,         this, &MainWindow::notesHScrolled);
    connect(vscr,       &QScrollBar     ::valueChanged,     this, &MainWindow::vertScrolled);
    connect(hscr,       &QScrollBar     ::valueChanged,     this, &MainWindow::horzScrolled);

    connect(noteEditor, &qtauNoteEditor ::rmbScrolled,      this, &MainWindow::onEditorRMBScrolled);
    connect(noteEditor, &qtauNoteEditor ::requestsOffset,   this, &MainWindow::onEditorRequestOffset);

    connect(zoom,       &QSlider        ::valueChanged,     this, &MainWindow::onZoomed);
    connect(meter,      &qtauMeterBar   ::zoomed,           this, &MainWindow::onEditorZoomed);
    connect(noteEditor, &qtauNoteEditor ::zoomed,           this, &MainWindow::onEditorZoomed);
    connect(drawZone,   &qtauDynDrawer  ::zoomed,           this, &MainWindow::onEditorZoomed);
    connect(vocalWave,  &qtauWaveform   ::zoomed,           this, &MainWindow::onEditorZoomed);
    connect(musicWave,  &qtauWaveform   ::zoomed,           this, &MainWindow::onEditorZoomed);

    connect(ui->actionQuit,      &QAction::triggered, [=]() { this->close(); });
    connect(ui->actionOpen,      &QAction::triggered, this, &MainWindow::onOpenUST);
    connect(ui->actionSave,      &QAction::triggered, this, &MainWindow::onSaveUST);
    connect(ui->actionSave_as,   &QAction::triggered, this, &MainWindow::onSaveUSTAs);

    connect(ui->actionUndo,      &QAction::triggered, this, &MainWindow::onUndo);
    connect(ui->actionRedo,      &QAction::triggered, this, &MainWindow::onRedo);
    connect(ui->actionDelete,    &QAction::triggered, this, &MainWindow::onDelete);

    connect(ui->actionEdit_Mode, &QAction::triggered, this, &MainWindow::onEditMode);
    connect(ui->actionGrid_Snap, &QAction::triggered, this, &MainWindow::onGridSnap);

    connect(ui->actionSave_audio_as, &QAction::triggered, this, &MainWindow::onSaveAudioAs);

    //----------------------------------------------

    lastScoreDir     = settings.value(c_key_dir_score,   "").toString();
    lastAudioDir     = settings.value(c_key_dir_audio,   "").toString();
    audioExt         = settings.value(c_key_audio_codec, "").toString();
    showNewLogNumber = settings.value(c_key_show_lognum, true).toBool();

    if (!settings.value(c_key_dynpanel_on, true).toBool())
    {
        QList<int> panelSizes = editorSplitter->sizes();
        panelSizes.last() = 0;
        editorSplitter->setSizes(panelSizes);
    }

    if (settings.value(c_key_win_max, false).toBool())
        showMaximized();
    else
    {
        QRect winGeom = geometry();
        QRect setGeom = settings.value(c_key_win_size, QRect(winGeom.topLeft(), minimumSize())).value<QRect>();

        if (setGeom.width() >= winGeom.width() && setGeom.height() >= setGeom.height())
            setGeometry(setGeom);
    }

    //----------------------------------------------

    vsLog::instance()->enableHistory(false);
    onLog(QString("\t%1 %2 @ %3").arg(tr("Launching QTau")).arg(c_qtau_ver).arg(__DATE__), ELog::success);

    onLog("\t---------------------------------------------", ELog::info);
    vsLog::r(); // print stored messages from program startup
    onLog("\t---------------------------------------------", ELog::info);
    vsLog::n();
}
Example #20
0
void FLUIQ::CollapsibleWidgetHeader::mouseMoveEvent( QMouseEvent * _event )
{
	if( m_pressed )
	{
		m_moved = true;

		QPoint pos = _event->globalPos();

		Splitter * s = NULL;
		if( m_parent->parentWidget() &&
			( s = qobject_cast<Splitter *>
					( m_parent->parentWidget() ) ) )
		{
			int idx = s->indexOf( m_parent );
			QWidget * sibling = NULL;
			CollapsibleWidget * collapsibleSibling;

			// look whether we have expanded left-hand siblings
			while( idx > 0 && sibling == NULL )
			{
				--idx;
				sibling = s->widget( idx );
				collapsibleSibling =
					qobject_cast<CollapsibleWidget *>(
								sibling );
				if( collapsibleSibling &&
					collapsibleSibling->isCollapsed() )
				{
					sibling = NULL;
				}
			}

			// found one?
			if( sibling )
			{
				QSize minSizeHint = sibling->minimumSizeHint();
				QSize sizeHint = sibling->sizeHint();
				QSize minSize = sibling->size();
				QSize maxSize = sibling->maximumSize();
				// then increase size according to orientation
				if( m_parent->orientation() == Qt::Vertical )
				{
const int dy = pos.y() - m_origMousePos.y();
minSize.setHeight( qMax( minSizeHint.height(), minSize.height() + dy ) );
// implement snapping when reaching size hint
if( dy < 0 && ( ( minSize.height() < sizeHint.height() &&
				sizeHint.height() - minSize.height() < 20 )
		 || ( sibling->size().height() == minSize.height() ) ) )
{
	return;
}
maxSize.setHeight( minSize.height() );
				}
				else
				{
const int dx = pos.x() - m_origMousePos.x();
minSize.setWidth( qMax( minSizeHint.width(), minSize.width() + dx ) );
// implement snapping when reaching size hint
if( dx < 0 && ( ( minSize.width() < sizeHint.width() &&
				sizeHint.width() - minSize.width() < 20 )
		 || ( sibling->size().width() == minSize.width()  ) ) )
{
	return;
}
maxSize.setWidth( minSize.width() );
				}
				sibling->setMinimumSize( minSize );
				sibling->setMaximumSize( maxSize );
				s->updateGeometry();
			}
			m_origMousePos = pos;
		}
	}
}
Example #21
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();
}
ScheduleScreen::ScheduleScreen(QWidget *parent) :
    QWidget(parent)
{
    setObjectName("ScheduleScreen");
    //get an instance of the global configuration
    m_globalSettings = GlobalSettings::getInstance();

    // seqNumber will track the number of points that have been created
    seqNumber = 0;

    // allow user to click off points to remove blur and see all
    connect(this, SIGNAL(clicked()), this, SLOT(unselectDay()));
    //allow valueChanged signal to trigger updateData() slot
    connect(this, SIGNAL(valueChanged()), this, SLOT(updateData()));
    // create title
    QLabel *title = new QLabel("Set your WEEKLY SCHEDULE");
    title->setObjectName("title");

    // create time represented by current point
    currentTime = new QLabel();
    currentTime->setObjectName("currentTime");
    currentTime->setMinimumWidth(80);

    // create back button
    QPushButton *backButton = new QPushButton();
    backButton->setIcon(QIcon(":/Images/glossy-blue-orb-icon-arrowback.png"));
    backButton->setIconSize(QSize(40,40));
    backButton->setFocusPolicy(Qt::NoFocus);
    backButton->setObjectName("backButton");
    connect(backButton,SIGNAL(clicked()),this,SLOT(close()));

    // create layout for top of screen
    QHBoxLayout *topLayout = new QHBoxLayout;
    topLayout->addWidget(currentTime);
    topLayout->addStretch();
    topLayout->addWidget(title);
    topLayout->addStretch();
    topLayout->addWidget(backButton);

    view = new QGraphicsView();
    view->setBackgroundBrush(QBrush(Qt::black));
    view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    view->setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing);
    view->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);


    // create final layout

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->addLayout(topLayout);
    QHBoxLayout* viewLayout = new QHBoxLayout;
    viewLayout->addWidget(view);
    viewLayout->setContentsMargins(0,0,0,0);
    viewLayout->setSpacing(0);
    mainLayout->addLayout(viewLayout);
    mainLayout->setContentsMargins(0,0,0,0);
    mainLayout->setSpacing(0);

    QWidget *sizeLimiterWidget = new QWidget;
    sizeLimiterWidget->setMaximumSize(800, 450);

    sizeLimiterWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    sizeLimiterWidget->setLayout(mainLayout);
    sizeLimiterWidget->setContentsMargins(0,0,0,0);
    QHBoxLayout* contentsBox = new QHBoxLayout;
    contentsBox->setContentsMargins(0,0,0,0);
    contentsBox->addWidget(sizeLimiterWidget);

    // show final layout
    setLayout(contentsBox);

    resize(qApp->desktop()->size());
    updateGeometry();

    scene = NULL;
    m_initialized = false;
    currentPoint  = NULL;
}
Example #23
0
int main(int argc, char **argv)
{
    QApplication app(argc, argv);
    Window *view = new Window();
    QWidget *container = QWidget::createWindowContainer(view);
    QSize screenSize = view->screen()->size();
    container->setMinimumSize(QSize(200, 100));
    container->setMaximumSize(screenSize);

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

    widget->setWindowTitle(QStringLiteral("Basic shapes"));

    Qt3DCore::QAspectEngine engine;
    engine.registerAspect(new Qt3DRender::QRenderAspect());
    Qt3DInput::QInputAspect *input = new Qt3DInput::QInputAspect;
    engine.registerAspect(input);
    QVariantMap data;
    data.insert(QStringLiteral("surface"), QVariant::fromValue(static_cast<QSurface *>(view)));
    data.insert(QStringLiteral("eventSource"), QVariant::fromValue(view));
    engine.setData(data);

    // Root entity
    Qt3DCore::QEntity *rootEntity = new Qt3DCore::QEntity();

    // Camera
    Qt3DCore::QCamera *cameraEntity = new Qt3DCore::QCamera(rootEntity);
    cameraEntity->setObjectName(QStringLiteral("cameraEntity"));

    cameraEntity->lens()->setPerspectiveProjection(45.0f, 16.0f/9.0f, 0.1f, 1000.0f);
    cameraEntity->setPosition(QVector3D(0, 0, -20.0f));
    cameraEntity->setUpVector(QVector3D(0, 1, 0));
    cameraEntity->setViewCenter(QVector3D(0, 0, 0));
    input->setCamera(cameraEntity);

    // FrameGraph
    Qt3DRender::QFrameGraph *frameGraph = new Qt3DRender::QFrameGraph();
    Qt3DRender::QForwardRenderer *forwardRenderer = new Qt3DRender::QForwardRenderer();

    forwardRenderer->setCamera(cameraEntity);
    forwardRenderer->setClearColor(QColor(QRgb(0x4d4d4f)));
    frameGraph->setActiveFrameGraph(forwardRenderer);

    // Setting the FrameGraph
    rootEntity->addComponent(frameGraph);

    // Scenemodifier
    SceneModifier *modifier = new SceneModifier(rootEntity);

    // Set root object of the scene
    engine.setRootEntity(rootEntity);

    // Create control widgets
    QCommandLinkButton *info = new QCommandLinkButton();
    info->setText(QStringLiteral("Qt3D ready-made meshes"));
    info->setDescription(QStringLiteral("Qt3D provides several ready-made meshes, like torus, cylinder, cube and sphere."));
    info->setIconSize(QSize(0,0));

    QCheckBox *torusCB = new QCheckBox(widget);
    torusCB->setChecked(true);
    torusCB->setText(QStringLiteral("Torus"));

    QCheckBox *cylinderCB = new QCheckBox(widget);
    cylinderCB->setChecked(true);
    cylinderCB->setText(QStringLiteral("Cylinder"));

    QCheckBox *cuboidCB = new QCheckBox(widget);
    cuboidCB->setChecked(true);
    cuboidCB->setText(QStringLiteral("Cuboid"));

    QCheckBox *sphereCB = new QCheckBox(widget);
    sphereCB->setChecked(true);
    sphereCB->setText(QStringLiteral("Sphere"));

    vLayout->addWidget(info);
    vLayout->addWidget(torusCB);
    vLayout->addWidget(cylinderCB);
    vLayout->addWidget(cuboidCB);
    vLayout->addWidget(sphereCB);

    QObject::connect(torusCB, &QCheckBox::stateChanged,
                     modifier, &SceneModifier::enableTorus);
    QObject::connect(cylinderCB, &QCheckBox::stateChanged,
                     modifier, &SceneModifier::enableCylinder);
    QObject::connect(cuboidCB, &QCheckBox::stateChanged,
                     modifier, &SceneModifier::enableCuboid);
    QObject::connect(sphereCB, &QCheckBox::stateChanged,
                     modifier, &SceneModifier::enableSphere);

    torusCB->setChecked(true);
    cylinderCB->setChecked(true);
    cuboidCB->setChecked(true);
    sphereCB->setChecked(true);

    // Show window
    widget->show();
    widget->resize(1200, 800);

    // Update the aspect ratio
    QSize widgetSize =  container->size();
    float aspectRatio = float(widgetSize.width()) / float(widgetSize.height());
    cameraEntity->lens()->setPerspectiveProjection(45.0f, aspectRatio, 0.1f, 1000.0f);

    return app.exec();
}
Example #24
0
Test_Drag_Drop::Test_Drag_Drop(QWidget *parent)
	: QMainWindow(parent)
{
	ui.setupUi(this);
	
	//
	QStandardItem* itm = new QStandardItem("1");
	itm->setFlags(itm->flags() & ~(Qt::ItemIsDropEnabled));
	modelStandard.setItem(0, 0, itm);

	itm = new QStandardItem("2");
	itm->setFlags(itm->flags() & ~(Qt::ItemIsDropEnabled));
	modelStandard.setItem(0, 1, itm);
	
	itm = new QStandardItem("3");
	Qt::ItemFlags f = itm->flags() & ~(Qt::ItemIsDropEnabled);
	Qt::ItemFlags f2 = itm->flags();
	itm->setFlags(itm->flags() & ~(Qt::ItemIsDropEnabled));
	modelStandard.setItem(1, 0, itm);
	
	itm = new QStandardItem("4");
	itm->setFlags(itm->flags() & ~(Qt::ItemIsDropEnabled));
	modelStandard.setItem(1, 1, itm);

	ui.tableView->setModel(&modelStandard);
	ui.tableView->setDragDropOverwriteMode(false);
	ui.tableView->setDragEnabled(true);
	ui.tableView->setDragDropMode(QAbstractItemView::InternalMove);


	////
	//ui.tableWidget->setColumnCount(2);
	//ui.tableWidget->setRowCount(2);
	//ui.tableWidget->setItem(0, 0, new QTableWidgetItem("1"));
	//ui.tableWidget->setItem(0, 1, new QTableWidgetItem("2"));
	//ui.tableWidget->setItem(1, 0, new QTableWidgetItem("3"));
	//ui.tableWidget->setItem(1, 1, new QTableWidgetItem("4"));

	////
	myTableView = new MyTableView(ui.centralWidget);
	ui.verticalLayout->addWidget(myTableView);
	myTableView->setModel(&modelStandard);

	//
	myTableView = new MyTableView(ui.centralWidget);
	ui.verticalLayout->addWidget(myTableView);

	myModel = new MyModel(myTableView);
	myModel->setItem(0, 0, new QStandardItem("1"));
	myModel->setItem(0, 1, new QStandardItem("2"));
	myModel->setItem(1, 0, new QStandardItem("3"));
	myModel->setItem(1, 1, new QStandardItem("4"));
	myTableView->setModel(myModel);



	TicketExtendedUiQML* ticketExtendedUiQML = new TicketExtendedUiQML;

	QQuickView *view = new QQuickView();
	QWidget *container = QWidget::createWindowContainer(view, this);
	container->setMinimumSize(200, 200);
	container->setMaximumSize(200, 200);
	container->setFocusPolicy(Qt::TabFocus);
	view->rootContext()->setContextProperty("ticketExtended", ticketExtendedUiQML);
	view->setSource(QUrl("main.qml"));
	ui.verticalLayout->addWidget(container);

	ticketExtendedUiQML->setProperty("idTicket", 125478);
}
Example #25
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 #26
0
analyserQ::analyserQ(QWidget *parent)
	: QWidget(parent)
{
	ui.setupUi(this);

	QSettings settings(QString("config.ini"), QSettings::IniFormat);
	dbUrl = settings.value("db/url", "http://localhost:32768").toString(); // settings.value() returns QVariant

	qDebug() << "db: "+dbUrl;
	QQuickView *view = new QQuickView();
	QWidget *map = new QWidget();
	QWidget *container = QWidget::createWindowContainer(view, map);
	container->setMinimumSize(400, 450);
	container->setMaximumSize(800, 800);
	container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
	container->setFocusPolicy(Qt::TabFocus	);
	view->setSource(QUrl("map.qml"));

	button = new QPushButton(tr("&Load..."), this);
	connect(button, &QAbstractButton::clicked, this, &analyserQ::loadPoI);


	label = new QLabel(tr("Choix Trajets."), this);
	labelMaxH = new QLabel(tr("Plus haute humidite du trajet"), this);
	labelMaxA = new QLabel(tr("Plus fort choc du trajet"), this);
	labelMaxT = new QLabel(tr("Plus haute temperature du trajet"), this);

	liste = new QComboBox;
	liste->setEditable(false);
	//liste->addItem("1");

	loadCombobox();

	QGridLayout *mainLayout = new QGridLayout;
	mainLayout->addWidget(button, 0, 0);
	mainLayout->addWidget(map, 1, 0);

	mainLayout->addWidget(label, 5, 0);
	mainLayout->addWidget(labelMaxH, 1, 4);
	mainLayout->addWidget(labelMaxA, 2, 4);
	mainLayout->addWidget(labelMaxT, 3, 4);

	mainLayout->addWidget(liste, 5,1);


	setLayout(mainLayout);
	rootObj = view->rootObject();

	QVariant returnedValue;
	QVariant lat = 59.9485;
	QVariant longi = 10.7686;
	QVariant type = 0;

	//QObject *object1 = view->rootObject();

	/*
	QMetaObject::invokeMethod(rootObj, "addPoi",
		Q_RETURN_ARG(QVariant, returnedValue),
		Q_ARG(QVariant, lat), Q_ARG(QVariant, longi), Q_ARG(QVariant, type));
	qDebug() << "QML function returned:" << returnedValue.toString();

	longi = 10.8686;
	type = 1;
	QMetaObject::invokeMethod(rootObj, "addPoi",
		Q_RETURN_ARG(QVariant, returnedValue),
		Q_ARG(QVariant, lat), Q_ARG(QVariant, longi), Q_ARG(QVariant, type));*/

	
}
Example #27
0
// ui
QWidget *image_channels_param_t::do_create_widgets()
{
    QWidget *top = new QWidget();
    int current_height = 0;

    // popups
    {
		QLabel *label = new QLabel( top);
		red_combo_ = new QComboBox( top);
		red_combo_->setFocusPolicy( Qt::NoFocus);
		QSize s = red_combo_->sizeHint();

		label->move( 0, current_height);
		label->resize( app().ui()->inspector().left_margin() - 5, s.height());
		label->setAlignment( Qt::AlignRight | Qt::AlignVCenter);
		label->setText( "Red");

		red_combo_->move( app().ui()->inspector().left_margin(), current_height);
		red_combo_->resize( app().ui()->inspector().width() - app().ui()->inspector().left_margin() - 10, s.height());
		connect( red_combo_, SIGNAL( currentIndexChanged( int)), this, SLOT( channel_picked( int)));
		current_height = s.height() + 5;
    }

    {
		QLabel *label = new QLabel( top);
		green_combo_ = new QComboBox( top);
		green_combo_->setFocusPolicy( Qt::NoFocus);

		QSize s = green_combo_->sizeHint();

		label->move( 0, current_height);
		label->resize( app().ui()->inspector().left_margin() - 5, s.height());
		label->setAlignment( Qt::AlignRight | Qt::AlignVCenter);
		label->setText( "Green");

		green_combo_->move( app().ui()->inspector().left_margin(), current_height);
		green_combo_->resize( app().ui()->inspector().width() - app().ui()->inspector().left_margin() - 10, s.height());
		connect( green_combo_, SIGNAL( currentIndexChanged( int)), this, SLOT( channel_picked( int)));
		current_height += s.height() + 5;
    }

    {
		QLabel *label = new QLabel( top);
		blue_combo_ = new QComboBox( top);
		blue_combo_->setFocusPolicy( Qt::NoFocus);

		QSize s = blue_combo_->sizeHint();

		label->move( 0, current_height);
		label->resize( app().ui()->inspector().left_margin() - 5, s.height());
		label->setAlignment( Qt::AlignRight | Qt::AlignVCenter);
		label->setText( "Blue");

		blue_combo_->move( app().ui()->inspector().left_margin(), current_height);
		blue_combo_->resize( app().ui()->inspector().width() - app().ui()->inspector().left_margin() - 10, s.height());
		connect( blue_combo_, SIGNAL( currentIndexChanged( int)), this, SLOT( channel_picked( int)));
		current_height += s.height() + 5;
    }

    {
		QLabel *label = new QLabel( top);
		alpha_combo_ = new QComboBox( top);
		alpha_combo_->setFocusPolicy( Qt::NoFocus);

		QSize s = alpha_combo_->sizeHint();

		label->move( 0, current_height);
		label->resize( app().ui()->inspector().left_margin() - 5, s.height());
		label->setAlignment( Qt::AlignRight | Qt::AlignVCenter);
		label->setText( "Alpha");

		alpha_combo_->move( app().ui()->inspector().left_margin(), current_height);
		alpha_combo_->resize( app().ui()->inspector().width() - app().ui()->inspector().left_margin() - 10, s.height());
		connect( alpha_combo_, SIGNAL( currentIndexChanged( int)), this, SLOT( channel_picked( int)));
		current_height += s.height() + 5;
    }

    top->setMinimumSize( app().ui()->inspector().width(), current_height);
    top->setMaximumSize( app().ui()->inspector().width(), current_height);
    top->setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed);

	tuple4i_t ch( get_value<tuple4i_t>( *this));
	update_popup( red_combo_   , boost::get<0>( ch));
	update_popup( green_combo_ , boost::get<1>( ch));
	update_popup( blue_combo_  , boost::get<2>( ch));
	update_popup( alpha_combo_ , boost::get<3>( ch));
    return top;
}
Example #28
0
AboutDialog::AboutDialog(QWidget *parent) :
    QDialog(parent)
{
    setWindowIcon(QIcon(":/core/images/librepilot_logo_32.png"));
    setWindowTitle(tr("About %1").arg(ORG_BIG_NAME));
    setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
    setMinimumSize(600, 400);
    setMaximumSize(800, 600);

    const QString description = tr(
        "Revision: <b>%1</b><br/>"
        "UAVO Hash: <b>%2</b><br/>"
        "<br/>"
        "Built from %3<br/>"
        "Built on %4 at %5<br/>"
        "Based on Qt %6 (%7 bit)<br/>"
        "<br/>"
        "\u00A9 The %8 Project, 2015-%9. All rights reserved.<br/>"
        "\u00A9 The OpenPilot Project, 2010-2015. All rights reserved.<br/>"
        ).arg(
        VersionInfo::revision().left(60), // %1
        VersionInfo::uavoHash().left(8), // %2
        VersionInfo::origin(), // $3
        QLatin1String(__DATE__), // %4
        QLatin1String(__TIME__), // %5
        QLatin1String(QT_VERSION_STR), // %6
        QString::number(QSysInfo::WordSize), // %7
        QLatin1String(ORG_BIG_NAME), // %8
        VersionInfo::year() // %9
        );

    // %1 = name, %2 = description, %3 = url, %4 = image url (not used)
    // <td><img src=\"%4\" size=\"32\"></td>
    QString creditRow     = "<tr padding=10><td><b>%1</b>%2<br/></td><td><a href=\"%3\">%3</a></td></tr>";

    // uses Text.StyledText (see http://doc.qt.io/qt-5/qml-qtquick-text.html#textFormat-prop)
    const QString credits = "<table width=\"100%\">"
                            + creditRow.arg("Tau Labs", "", "http://www.taulabs.org")
                            + creditRow.arg("dRonin", "", "http://www.dronin.org")
                            + creditRow.arg("OpenSceneGraph", "<br/>Open source high performance 3D graphics toolkit", "http://www.openscenegraph.org")
                            + creditRow.arg("osgEarth", "<br/>Geospatial SDK for OpenSceneGraph", "http://osgearth.org")
                            + creditRow.arg("MSYS2", "<br/>An independent rewrite of MSYS", "https://sourceforge.net/p/msys2/wiki/Home")
                            + creditRow.arg("The Qt Company", "", "http://www.qt.io")
                            + "</table>";

    // uses Text.StyledText (see http://doc.qt.io/qt-5/qml-qtquick-text.html#textFormat-prop)
    const QString license = tr("This program is free software; you can redistribute it and/or "
                               "modify it under the terms of the GNU General Public License "
                               "as published by the Free Software Foundation; either version 3 "
                               "of the License, or (at your option) any later version.\n"
                               "The program is provided AS IS with NO WARRANTY OF ANY KIND, "
                               "INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE."
                               );


    QQuickView *view = new QQuickView();
    view->rootContext()->setContextProperty("dialog", this);
    view->rootContext()->setContextProperty("version", description);
    view->rootContext()->setContextProperty("credits", credits);
    view->rootContext()->setContextProperty("license", license);
    view->setResizeMode(QQuickView::SizeRootObjectToView);
    view->setSource(QUrl("qrc:/core/qml/AboutDialog.qml"));

    QWidget *container = QWidget::createWindowContainer(view);
    container->setMinimumSize(600, 400);
    container->setMaximumSize(800, 600);
    container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    QVBoxLayout *lay = new QVBoxLayout();
    lay->setContentsMargins(0, 0, 0, 0);
    setLayout(lay);
    layout()->addWidget(container);
}
Example #29
0
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->addLayout(vLayout);
    hLayout->addWidget(container, 1);
    vLayout->setAlignment(Qt::AlignTop);
    widget->setWindowTitle(QStringLiteral("Интерполяция"));
    QGroupBox *modelGroupBox = new QGroupBox(QStringLiteral("Графики"));
    QRadioButton *InitPlotModelRB = new QRadioButton(widget);
    InitPlotModelRB->setText(QStringLiteral("Начальный график"));
    InitPlotModelRB->setChecked(false);
    QRadioButton *InterpModelRB = new QRadioButton(widget);
    InterpModelRB->setText(QStringLiteral("Интерполяция"));
    InterpModelRB->setChecked(false);
    QRadioButton *InitInterpModelRB = new QRadioButton(widget);
    InitInterpModelRB->setText(QStringLiteral("Изначальный и интерполяция"));
    InitInterpModelRB->setChecked(false);
    QRadioButton *ResidModelRB = new QRadioButton(widget);
    ResidModelRB->setText(QStringLiteral("Невязка"));
    ResidModelRB->setChecked(false);
    QVBoxLayout *modelVBox = new QVBoxLayout;
    modelVBox->addWidget(InitPlotModelRB);
    modelVBox->addWidget(InterpModelRB);
    modelVBox->addWidget(InitInterpModelRB);
    modelVBox->addWidget(ResidModelRB);
    modelGroupBox->setLayout(modelVBox);
    QLabel *countN = new QLabel(widget);
    QLabel *countM = new QLabel(widget);
    vLayout->addWidget(modelGroupBox);
    vLayout->addWidget(new QLabel(QStringLiteral("точек на оси Х")));
    vLayout->addWidget(countN);
    vLayout->addWidget(new QLabel(QStringLiteral("точек на оси Z")));
    vLayout->addWidget(countM);
    vLayout->addWidget((new QLabel(QStringLiteral("1-графики\n"
                                                  "2-больше точек на Х\n"
                                                  "3-больше точек на Z\n"
                                                  "4-увеличить диапазон X\n"
                                                  "5-уменьшить диапазон X\n"
                                                  "6-увеличить диапазон Z\n"
                                                  "7-уменьшить диапазон Z\n"
                                                  "8-меньше точек на X\n"
                                                  "9-меньше точек на Z"))));
    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()));
    modifier->key6 = new QShortcut(widget);
    modifier->key6->setKey(Qt::Key_6);
    QObject::connect(modifier->key6, SIGNAL(activated()), modifier, SLOT(slotShortcut6()));
    modifier->key7 = new QShortcut(widget);
    modifier->key7->setKey(Qt::Key_7);
    QObject::connect(modifier->key7, SIGNAL(activated()), modifier, SLOT(slotShortcut7()));
    modifier->key8 = new QShortcut(widget);
    modifier->key8->setKey(Qt::Key_8);
    QObject::connect(modifier->key8, SIGNAL(activated()), modifier, SLOT(slotShortcut8()));
    modifier->key9 = new QShortcut(widget);
    modifier->key9->setKey(Qt::Key_9);
    QObject::connect(modifier->key9, SIGNAL(activated()), modifier, SLOT(slotShortcut9()));


    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);
    InitPlotModelRB->setChecked(true);
    modifier->setCount(countN, countM);
    modifier->setKol(InitPlotModelRB,InterpModelRB, InitInterpModelRB,ResidModelRB);  //изначально выставим точки
    return app.exec();
}
 // major buttons
 // javax.swing.JButton addButton = new javax.swing.JButton();
 /*public*/ SchedulesTableFrame::SchedulesTableFrame(QWidget* parent)
     : OperationsFrame(tr("Schedules"), parent)
 {
     //super(tr("TitleSchedulesTable"));
  log = new Logger("SchedulesTableFrame");
  schedulesModel = new SchedulesTableModel();
  schedulesTable = new JTable(schedulesModel);
  schedulesTable->setObjectName("SchedulesTable");
 //JScrollPane schedulesPane;

 // labels
  textSort = new QLabel();
  textSep = new QLabel();

 // radio buttons
  sortByName = new QRadioButton(tr("Name"));
  sortById = new QRadioButton(tr("Id"));

  // general GUI config

  //getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
QVBoxLayout* thisLayout = new QVBoxLayout(getContentPane());
  // Set up the jtable in a Scroll Pane..
//        schedulesPane = new JScrollPane(schedulesTable);
//        schedulesPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
//        schedulesPane
//                .setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  schedulesModel->initTable(this, schedulesTable);
  thisLayout->addWidget(/*schedulesPane*/schedulesTable);

  // Set up the control panel
  QWidget* controlPanel = new QWidget();
  controlPanel->setLayout(new FlowLayout());

  textSort->setText(tr("SortBy"));
  controlPanel->layout()->addWidget(textSort);
  controlPanel->layout()->addWidget(sortByName);
  sortByName->setChecked(true);
  controlPanel->layout()->addWidget(sortById);
  textSep->setText("          ");
  controlPanel->layout()->addWidget(textSep);

  // TODO allow user to add schedule to a spur
  // addButton.setText(tr("Add"));
  // addButton.setVisible(true);
  // controlPanel.add (addButton);
  controlPanel->setMaximumSize(QSize(Control::panelWidth1025, 50));
  thisLayout->addWidget(controlPanel);

  // setup buttons
  // addButtonAction(addButton);
  addRadioButtonAction(sortByName);
  addRadioButtonAction(sortById);

  // build menu
  QMenuBar* menuBar = new QMenuBar();
  QMenu* toolMenu = new QMenu("Tools");
  toolMenu->addAction(new ScheduleCopyAction(this));
  toolMenu->addAction(new SchedulesByLoadAction(tr("Show Schedules By Load"),this));
  toolMenu->addAction(new SchedulesResetHitsAction(tr("Reset Hit Counts"),this));
  toolMenu->addAction(new PrintLocationsAction(tr("Print"), false,this));
  toolMenu->addAction(new PrintLocationsAction(tr("Preview"), true,this));

  menuBar->addMenu(toolMenu);
  setMenuBar(menuBar);
  addHelpMenu("package.jmri.jmrit.operations.Operations_LocationSchedules", true); // NOI18N

  initMinimumSize();
  // make panel a bit wider than minimum if the very first time opened
  if (width() == Control::panelWidth500)
  {
   resize(Control::panelWidth1025, height());
  }
  setLocation(10,20);

 }