/*protected*/ void ReporterItemPanel::makeDndIconPanel(QHash<QString, NamedIcon*>* /*iconMap*/, QString /*displayKey*/) { if (_update) { return; } _reporter = new ReporterIcon(_editor); QGroupBox* panel = new QGroupBox(); QString borderName = tr("Drag to Panel"); QString gbStyleSheet = "QGroupBox { border: 2px solid gray; border-radius: 3px;} QGroupBox::title { /*background-color: transparent;*/ subcontrol-position: top left; /* position at the top left*/ padding:0 0px;} "; panel->setLayout(new QHBoxLayout); panel->setTitle(borderName); panel->setStyleSheet(gbStyleSheet); QWidget* comp; DataFlavor* flavor; try { //comp = getDragger(flavor = new DataFlavor(Editor::POSITIONABLE_FLAVOR)); comp = getDragger(flavor = new DataFlavor(_reporter,"ReporterIcon")); flavor->setMimeTypeParameter("reporter", _reporter->getName()); comp->setToolTip(tr("Drag an icon from this panel to add it to the control panel")); } catch (ClassNotFoundException cnfe) { //cnfe.printStackTrace(); comp = new QWidget(); } comp->setLayout(new FlowLayout); comp->layout()->addWidget(_reporter); panel->layout()->addWidget(comp); //panel.validate(); int width = qMax(100, panel->sizeHint().width()); panel->setMinimumSize( QSize(width, panel->minimumSize().height())); panel->setToolTip(tr("Drag an icon from this panel to add it to the control panel")); _dragIconPanel->layout()->addWidget( panel); _dragIconPanel->setToolTip(tr("Drag an icon from this panel to add it to the control panel")); }
xyPlot::xyPlot(QTScope* caller, QWidget* parent, const char* name, int id, Qt::WindowFlags wflags, int numberOfSamples) : scopePlotPlugin(caller, parent, name, id, wflags,numberOfSamples) { cout << "xyPlot::xyPlot: xyPlot Plugin generated\n"; callingWidget = caller; idThis = id; setWindowTitle( QString().sprintf("Channel %s",name) ); plotLength = numberOfSamples; x=new double[plotLength]; y=new double[plotLength]; // initialize the data arrays clearData(); // allow Docking //setDockEnabled ( Qt::DockTop, TRUE ); //setDockEnabled ( Qt::DockLeft, TRUE ); // conmstruct a toolbar QVBoxLayout *plotTools = new QVBoxLayout(); QGroupBox *groupTools = new QGroupBox(); QLabel *y_max = new QLabel(tr("Y max:")); plotTools->addWidget( y_max ); ymaxCounter = new QwtCounter( ); plotTools->addWidget( ymaxCounter ); ymaxCounter->setRange(-1, 20.0); ymaxCounter->setSingleStep(0.01); ymaxCounter->setNumButtons(2); ymaxCounter->setIncSteps(QwtCounter::Button1, 10); ymaxCounter->setIncSteps(QwtCounter::Button2, 100); ymaxCounter->setValue(1); ymaxCounter->resize(200,200); connect(ymaxCounter, SIGNAL(valueChanged(double)), this, SLOT(slotYmaxChanged(double))); ymaxCounter->setDisabled(TRUE); QLabel *y_min = new QLabel(tr("Y min:")); plotTools->addWidget( y_min ); yminCounter = new QwtCounter( ); plotTools->addWidget( yminCounter ); yminCounter->setRange(-20.0, 1); yminCounter->setSingleStep(0.01); yminCounter->setNumButtons(2); yminCounter->setIncSteps(QwtCounter::Button1, 10); yminCounter->setIncSteps(QwtCounter::Button2, 100); yminCounter->setValue(-1); connect(yminCounter, SIGNAL(valueChanged(double)), this, SLOT(slotYminChanged(double))); yminCounter->setDisabled(TRUE); //plotTools->addSeparator(); QLabel *x_min = new QLabel(tr("X min:")); plotTools->addWidget( x_min ); xminCounter = new QwtCounter( ); plotTools->addWidget( xminCounter ); xminCounter->setRange(-20.0, 1); xminCounter->setSingleStep(0.01); xminCounter->setNumButtons(2); xminCounter->setIncSteps(QwtCounter::Button1, 10); xminCounter->setIncSteps(QwtCounter::Button2, 100); xminCounter->setValue(-1); connect(xminCounter, SIGNAL(valueChanged(double)), this, SLOT(slotXminChanged(double))); xminCounter->setDisabled(TRUE); QLabel *x_max = new QLabel(tr("X max:")); plotTools->addWidget( x_max ); xmaxCounter = new QwtCounter( ); plotTools->addWidget( xmaxCounter ); xmaxCounter->setRange(-1, 20.0); xmaxCounter->setSingleStep(0.01); xmaxCounter->setNumButtons(2); xmaxCounter->setIncSteps(QwtCounter::Button1, 10); xmaxCounter->setIncSteps(QwtCounter::Button2, 100); xmaxCounter->setValue(1); connect(xmaxCounter, SIGNAL(valueChanged(double)), this, SLOT(slotXmaxChanged(double))); xmaxCounter->setDisabled(TRUE); //plotTools->addSeparator(); QLabel *dataPoints = new QLabel(tr("Data Points:")); plotTools->addWidget( dataPoints ); rangeCounter = new QwtCounter( ); plotTools->addWidget( rangeCounter ); rangeCounter->setRange(0, plotLength); rangeCounter->setSingleStep(1); rangeCounter->setNumButtons(2); rangeCounter->setIncSteps(QwtCounter::Button1, 100); rangeCounter->setIncSteps(QwtCounter::Button3, 1000); rangeCounter->setValue(100); connect(rangeCounter, SIGNAL(valueChanged(double)), this, SLOT(slotRangeChanged(double))); rangeCounter->setDisabled(FALSE); //plotTools->addSeparator(); autoscaleCheck = new QCheckBox("Autoscale"); plotTools->addWidget( autoscaleCheck ); autoscaleCheck->setChecked(TRUE); connect(autoscaleCheck, SIGNAL(clicked()), this, SLOT(slotAutoscaleToggled())); //moveDockWindow( plotTools, Qt::DockLeft ); // contruct a QwtPlot Widget plotWidget = new QwtPlot(this); // QwtPlot specific defaults: // colour plotWidget->setCanvasBackground(Qt::white); // outline //plotWidget->enableOutline(FALSE); // no legend //plotWidget->enableLegend(FALSE); // no grid grid = new QwtPlotGrid(); grid->enableX(true); grid->enableXMin(true); // for major grid line grid->setMajorPen( QPen(Qt::black,1) ); // for minor grid line grid->setMinorPen( QPen(Qt::gray,1) ); QwtScaleDiv div; QwtLinearScaleEngine *lineSE = new QwtLinearScaleEngine(); div = lineSE->divideScale(0, 150, 2, 5, 15); grid->attach( plotWidget ); // set some defaults for the axes plotWidget->setAxisTitle(QwtPlot::xBottom, "Amplitude/V"); plotWidget->setAxisTitle(QwtPlot::yLeft, "Amplitude/V"); // default xrange plotWidget->setAxisScale( QwtPlot::xBottom, 0, 1000); // yrange autoscale plotWidget->setAxisAutoScale(QwtPlot::yLeft); plotWidget->setAxisAutoScale(QwtPlot::xBottom); curve = new QwtPlotCurve("Graph"); //set curve color curve->setPen(QPen(Qt::green, 2)); // add curves curve->attach(plotWidget); // copy the data into the curves curve->setRawSamples(x, y, plotLength); // finally, refresh the plot plotWidget->replot(); groupTools->setLayout(plotTools); QSize size = groupTools->sizeHint(); size.setWidth( size.width()*1.3 ); groupTools->setFixedSize( size ); QHBoxLayout *hbox = new QHBoxLayout(); hbox->addWidget(groupTools); hbox->addWidget(plotWidget); setLayout(hbox); }
MainGUI::MainGUI() : current_world(0), custom_world(new QLineEdit), heightmapBox(new QGroupBox("heightmap")), bf(NULL), scene(new QGraphicsScene()), mf(new MainForm(scene, bf)), set(), start_button(new QPushButton("Start rendering", this)), worker_thread(), waiter_thread() { QGroupBox* groupBox = new QGroupBox("select world"); QRadioButton* radio1 = new QRadioButton("World 1"); QRadioButton* radio2 = new QRadioButton("World 2"); QRadioButton* radio3 = new QRadioButton("World 3"); QRadioButton* radio4 = new QRadioButton("World 4"); QRadioButton* radio5 = new QRadioButton("World 5"); QRadioButton* radio6 = new QRadioButton("custom"); radio1->setEnabled(!MinecraftWorld::find_world_path(1).empty()); radio2->setEnabled(!MinecraftWorld::find_world_path(2).empty()); radio3->setEnabled(!MinecraftWorld::find_world_path(3).empty()); radio4->setEnabled(!MinecraftWorld::find_world_path(4).empty()); radio5->setEnabled(!MinecraftWorld::find_world_path(5).empty()); QVBoxLayout *vbox = new QVBoxLayout; vbox->addWidget(radio1); vbox->addWidget(radio2); vbox->addWidget(radio3); vbox->addWidget(radio4); vbox->addWidget(radio5); vbox->addWidget(radio6); groupBox->setLayout(vbox); custom_world->setMaximumWidth(groupBox->sizeHint().width()); custom_world->setEnabled(false); vbox->addWidget(custom_world); QSignalMapper* world_mapper = new QSignalMapper(this); connect(radio1, SIGNAL(clicked()), world_mapper, SLOT(map())); connect(radio2, SIGNAL(clicked()), world_mapper, SLOT(map())); connect(radio3, SIGNAL(clicked()), world_mapper, SLOT(map())); connect(radio4, SIGNAL(clicked()), world_mapper, SLOT(map())); connect(radio5, SIGNAL(clicked()), world_mapper, SLOT(map())); connect(radio6, SIGNAL(clicked()), world_mapper, SLOT(map())); world_mapper->setMapping(radio1, 1); world_mapper->setMapping(radio2, 2); world_mapper->setMapping(radio3, 3); world_mapper->setMapping(radio4, 4); world_mapper->setMapping(radio5, 5); world_mapper->setMapping(radio6, 0); connect(world_mapper, SIGNAL(mapped(int)), this, SLOT(set_current_world(int))); connect(radio6, SIGNAL(toggled(bool)), custom_world, SLOT(setEnabled(bool))); connect(radio6, SIGNAL(clicked()), this, SLOT(load_custom_world())); QGroupBox* renderBox = new QGroupBox("render mode"); QRadioButton* render1 = new QRadioButton("top down"); QRadioButton* render2 = new QRadioButton("oblique"); QRadioButton* render3 = new QRadioButton("isometric"); render1->setChecked(true); QVBoxLayout *vbox_render = new QVBoxLayout; vbox_render->addWidget(render1); vbox_render->addWidget(render2); vbox_render->addWidget(render3); renderBox->setLayout(vbox_render); QSignalMapper* render_mapper = new QSignalMapper(this); connect(render1, SIGNAL(clicked()), render_mapper, SLOT(map())); connect(render2, SIGNAL(clicked()), render_mapper, SLOT(map())); connect(render3, SIGNAL(clicked()), render_mapper, SLOT(map())); render_mapper->setMapping(render1, 0); render_mapper->setMapping(render2, 1); render_mapper->setMapping(render3, 2); connect(render_mapper, SIGNAL(mapped(int)), this, SLOT(set_render_mode(int))); QGroupBox* shadowBox = new QGroupBox("shadow quality"); QRadioButton* shadow1 = new QRadioButton("normal"); QRadioButton* shadow2 = new QRadioButton("high"); QRadioButton* shadow3 = new QRadioButton("ultra"); shadow1->setChecked(true); QVBoxLayout *vbox_shadow = new QVBoxLayout; vbox_shadow->addWidget(shadow1); vbox_shadow->addWidget(shadow2); vbox_shadow->addWidget(shadow3); shadowBox->setLayout(vbox_shadow); QSignalMapper* shadow_mapper = new QSignalMapper(this); connect(shadow1, SIGNAL(clicked()), shadow_mapper, SLOT(map())); connect(shadow2, SIGNAL(clicked()), shadow_mapper, SLOT(map())); connect(shadow3, SIGNAL(clicked()), shadow_mapper, SLOT(map())); shadow_mapper->setMapping(shadow1, 0); shadow_mapper->setMapping(shadow2, 1); shadow_mapper->setMapping(shadow3, 2); connect(shadow_mapper, SIGNAL(mapped(int)), this, SLOT(set_shadow_quality(int))); QGroupBox *lightBox = new QGroupBox("sun direction"); QRadioButton* light0 = new QRadioButton(); QRadioButton* light1 = new QRadioButton(); QRadioButton* light2 = new QRadioButton(); QRadioButton* light3 = new QRadioButton(); QRadioButton* light4 = new QRadioButton(); QRadioButton* light5 = new QRadioButton(); QRadioButton* light6 = new QRadioButton(); QRadioButton* light7 = new QRadioButton(); QGridLayout *light_grid = new QGridLayout; light_grid->addWidget(light0, 0, 0); light_grid->addWidget(light1, 1, 0); light_grid->addWidget(light2, 2, 0); light_grid->addWidget(light3, 2, 1); light_grid->addWidget(light4, 2, 2); light_grid->addWidget(light5, 1, 2); light_grid->addWidget(light6, 0, 2); light_grid->addWidget(light7, 0, 1); lightBox->setLayout(light_grid); QSignalMapper* light_mapper = new QSignalMapper(this); connect(light0, SIGNAL(clicked()), light_mapper, SLOT(map())); connect(light1, SIGNAL(clicked()), light_mapper, SLOT(map())); connect(light2, SIGNAL(clicked()), light_mapper, SLOT(map())); connect(light3, SIGNAL(clicked()), light_mapper, SLOT(map())); connect(light4, SIGNAL(clicked()), light_mapper, SLOT(map())); connect(light5, SIGNAL(clicked()), light_mapper, SLOT(map())); connect(light6, SIGNAL(clicked()), light_mapper, SLOT(map())); connect(light7, SIGNAL(clicked()), light_mapper, SLOT(map())); light_mapper->setMapping(light0, 0); light_mapper->setMapping(light1, 1); light_mapper->setMapping(light2, 2); light_mapper->setMapping(light3, 3); light_mapper->setMapping(light4, 4); light_mapper->setMapping(light5, 5); light_mapper->setMapping(light6, 6); light_mapper->setMapping(light7, 7); connect(light_mapper, SIGNAL(mapped(int)), this, SLOT(set_sun_direction(int))); light0->click(); QGroupBox *rotateBox = new QGroupBox("rotation"); QRadioButton* rotate0 = new QRadioButton(); QRadioButton* rotate1 = new QRadioButton(); QRadioButton* rotate2 = new QRadioButton(); QRadioButton* rotate3 = new QRadioButton(); QGridLayout *rotate_grid = new QGridLayout; rotate_grid->addWidget(rotate0, 0, 1); rotate_grid->addWidget(rotate1, 1, 0); rotate_grid->addWidget(rotate2, 2, 1); rotate_grid->addWidget(rotate3, 1, 2); rotateBox->setLayout(rotate_grid); QSignalMapper* rotate_mapper = new QSignalMapper(this); connect(rotate0, SIGNAL(clicked()), rotate_mapper, SLOT(map())); connect(rotate1, SIGNAL(clicked()), rotate_mapper, SLOT(map())); connect(rotate2, SIGNAL(clicked()), rotate_mapper, SLOT(map())); connect(rotate3, SIGNAL(clicked()), rotate_mapper, SLOT(map())); rotate_mapper->setMapping(rotate0, 1); rotate_mapper->setMapping(rotate1, 0); rotate_mapper->setMapping(rotate2, 3); rotate_mapper->setMapping(rotate3, 2); connect(rotate_mapper, SIGNAL(mapped(int)), this, SLOT(set_rotate(int))); rotate0->click(); QSpinBox* relief_strength = new QSpinBox(this); connect(relief_strength, SIGNAL(valueChanged(int)), this, SLOT(set_relief_strength(int))); relief_strength->setValue(10); QSpinBox* shadow_strength = new QSpinBox(this); connect(shadow_strength, SIGNAL(valueChanged(int)), this, SLOT(set_shadow_strength(int))); shadow_strength->setValue(60); QLabel* relief_label = new QLabel("relief strength:"); QLabel* shadow_label = new QLabel("shadow strength:"); QBoxLayout* global = new QHBoxLayout(this); QScrollArea* left_scroll_area = new QScrollArea; left_scroll_area->setFrameStyle(QFrame::NoFrame | QFrame::Plain); left_scroll_area->setLineWidth(0); QBoxLayout* left_side = new QVBoxLayout; left_side->addWidget(groupBox); left_side->addWidget(renderBox); left_side->addWidget(shadowBox); left_side->addWidget(lightBox); left_side->addWidget(shadow_label); left_side->addWidget(shadow_strength); left_side->addWidget(relief_label); left_side->addWidget(relief_strength); left_side->addWidget(rotateBox); QCheckBox* night_mode_box = new QCheckBox("night mode"); left_side->addWidget(night_mode_box); connect(night_mode_box, SIGNAL(stateChanged(int)), this, SLOT(set_night_mode(int))); heightmapBox->setCheckable(true); heightmapBox->setChecked(false); QRadioButton* heightmap_box1 = new QRadioButton("grey"); heightmap_box1->setChecked(true); QRadioButton* heightmap_box2 = new QRadioButton("color"); QVBoxLayout *vbox_heightmap = new QVBoxLayout; vbox_heightmap->addWidget(heightmap_box1); vbox_heightmap->addWidget(heightmap_box2); heightmapBox->setLayout(vbox_heightmap); left_side->addWidget(heightmapBox); connect(heightmapBox, SIGNAL(toggled(bool)), this, SLOT(set_heightmap(bool))); connect(heightmap_box1, SIGNAL(toggled(bool)), this, SLOT(set_heightmap_grey(bool))); connect(heightmap_box2, SIGNAL(toggled(bool)), this, SLOT(set_heightmap_color(bool))); left_side->addStretch(1); QWidget* left_widget = new QWidget; left_widget->setLayout(left_side); left_scroll_area->setWidget(left_widget); QVBoxLayout* left_side_all = new QVBoxLayout; left_side_all->addWidget(left_scroll_area); left_side_all->addWidget(start_button); QPushButton* save_button = new QPushButton("Save image"); left_side_all->addWidget(save_button); connect(save_button, SIGNAL(clicked()), this, SLOT(save_image())); left_side_all->setMargin(0); QWidget* left_side_all_widget = new QWidget; left_side_all_widget->setLayout(left_side_all); left_side_all_widget->setFixedWidth(left_side_all_widget->sizeHint().width() + left_scroll_area->verticalScrollBar() ->sizeHint().width() + 3); global->addWidget(left_side_all_widget); global->addWidget(mf); /* constraints */ connect(render1, SIGNAL(toggled(bool)), heightmapBox, SLOT(setEnabled(bool))); connect(render1, SIGNAL(toggled(bool)), this, SLOT(disable_shadow_elements(bool))); connect(this, SIGNAL(disable_shadow_elements_signal(bool)), shadowBox, SLOT(setDisabled(bool))); connect(this, SIGNAL(disable_shadow_elements_signal(bool)), shadow_label, SLOT(setDisabled(bool))); connect(this, SIGNAL(disable_shadow_elements_signal(bool)), shadow_strength, SLOT(setDisabled(bool))); connect(this, SIGNAL(disable_shadow_elements_signal(bool)), lightBox, SLOT(setDisabled(bool))); connect(heightmapBox, SIGNAL(toggled(bool)), shadowBox, SLOT(setDisabled(bool))); connect(heightmapBox, SIGNAL(toggled(bool)), shadow_label, SLOT(setDisabled(bool))); connect(heightmapBox, SIGNAL(toggled(bool)), shadow_strength, SLOT(setDisabled(bool))); connect(heightmapBox, SIGNAL(toggled(bool)), lightBox, SLOT(setDisabled(bool))); connect(start_button, SIGNAL(clicked()), this, SLOT(set_new_world())); connect(this, SIGNAL(toggle_rendering_signal(bool)), this, SLOT(toggle_rendering(bool))); connect(this, SIGNAL(save_image_with_filename_signal(QString)), this, SLOT(save_image_with_filename(QString))); }