FlowVis 1.0

FlowVis/SettingsWidget.cpp

00001 #include "SettingsWidget.h"
00002 #include <iostream>
00003 
00004 SettingsWidget::SettingsWidget(QWidget *parent)
00005         : QWidget(parent)
00006 {
00007         this->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding);
00008         Init();
00009         ConnectSignals();
00010 }
00011 
00012 void SettingsWidget::Init()
00013 {
00014         int sliderwidth = 150;
00015         layout = new QVBoxLayout(); //main layout
00016         
00017 
00019         arrows = new QGroupBox("Arrows");       //Arrows
00020         
00021         //arrows->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
00022         gridArrows = new QGridLayout();
00023         gridArrows->addWidget(new QLabel("Count:"),0,0,Qt::AlignLeft);
00024         gridArrows->addWidget(new QLabel("Size:"),1,0,Qt::AlignLeft);
00025 
00026         sliderArrowsCount = new QSlider(Qt::Horizontal);
00027         sliderArrowsCount->setMinimumWidth(sliderwidth);
00028         sliderArrowsCount->setRange(0,100);
00029         sliderArrowsCount->setValue(50);
00030         sliderArrowsSize = new QSlider(Qt::Horizontal);
00031         sliderArrowsSize->setMinimumWidth(sliderwidth);
00032         sliderArrowsSize->setRange(0,100);
00033         sliderArrowsSize->setValue(50);
00034         gridArrows->addWidget(sliderArrowsCount,0,1,Qt::AlignRight);
00035         gridArrows->addWidget(sliderArrowsSize,1,1,Qt::AlignRight);
00036 
00037         arrows->setLayout(gridArrows);
00039 
00040 
00042         texture = new QGroupBox("Texture");     //Texture
00043         //texture->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
00044         gridTexture = new QGridLayout();
00045         gridTexture->addWidget(new QLabel("Resolution:"),0,0,Qt::AlignLeft);
00046         sliderTextureResolution = new QSlider(Qt::Horizontal);
00047         sliderTextureResolution->setMinimumWidth(sliderwidth);
00048         sliderTextureResolution->setRange(0,100);
00049         sliderTextureResolution->setValue(20);
00050         gridTexture->addWidget(sliderTextureResolution,0,1,Qt::AlignRight);
00051 
00052         texture->setLayout(gridTexture);
00054 
00055 
00057         streamlines = new QGroupBox("Streamlines");     //Streamlines
00058         //streamlines->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed);
00059         gridStreamlines = new QGridLayout();
00060 
00061         QGroupBox* boxSlider = new QGroupBox("Parameters");
00062         QGridLayout *slider = new QGridLayout();
00063         slider->addWidget(new QLabel("d_sep:"),0,0,Qt::AlignLeft);
00064         slider->addWidget(new QLabel("d_test:"),1,0,Qt::AlignLeft);
00065         slider->addWidget(new QLabel("d_t:"),2,0,Qt::AlignLeft);
00066 
00067         sliderSLdsep = new QSlider(Qt::Horizontal);
00068         sliderSLdsep->setMinimumWidth(sliderwidth);
00069         sliderSLdsep->setRange(0,100);
00070         sliderSLdsep->setValue(50);
00071         sliderSLdtest = new QSlider(Qt::Horizontal);
00072         sliderSLdtest->setMinimumWidth(sliderwidth);
00073         sliderSLdtest->setRange(0,100);
00074         sliderSLdtest->setValue(50);
00075         sliderSLdt = new QSlider(Qt::Horizontal);
00076         sliderSLdt->setMinimumWidth(sliderwidth);
00077         sliderSLdt->setRange(0,100);
00078         sliderSLdt->setValue(50);
00079         slider->addWidget(sliderSLdsep,0,1,Qt::AlignRight);
00080         slider->addWidget(sliderSLdtest,1,1,Qt::AlignRight);
00081         slider->addWidget(sliderSLdt,2,1,Qt::AlignRight);
00082 
00083         computeButton = new QPushButton("Apply");
00084         slider->addWidget(computeButton,3,1,Qt::AlignRight);
00085 
00086         boxSlider->setLayout(slider);
00087 
00088         QHBoxLayout* checkboxes = new QHBoxLayout();
00089         //TODO checkboxes
00090         
00091         radioSNormal = new QRadioButton("Standard");
00092         radioSLtapering = new QRadioButton("Tapering");
00093         radioSLglyph = new QRadioButton("Glyph");
00094         radioSLtexture = new QRadioButton("Texture");
00095         checkboxes->addWidget(radioSNormal,Qt::AlignLeft);
00096         checkboxes->addWidget(radioSLtapering,Qt::AlignLeft);
00097         checkboxes->addWidget(radioSLglyph,Qt::AlignLeft);
00098         checkboxes->addWidget(radioSLtexture,Qt::AlignLeft);
00099         checkboxes->addStretch();
00100 
00101         QGroupBox* box = new QGroupBox("Mode");
00102         box->setLayout(checkboxes);
00103         checkboxGroup = new QButtonGroup();
00104         checkboxGroup->addButton(radioSLtapering,1);
00105         checkboxGroup->addButton(radioSLglyph,2);
00106         checkboxGroup->addButton(radioSLtexture,3);
00107         checkboxGroup->addButton(radioSNormal,0);
00108         radioSNormal->setChecked(true);
00109         //gridStreamlines->setRowMinimumHeight(3,40);
00110 
00111         gridStreamlines->addWidget(boxSlider,2,0);
00112         gridStreamlines->addWidget(box,0,0);
00113 
00114 
00115         QHBoxLayout* interpolation = new QHBoxLayout();
00116         radioEuler = new QRadioButton("Euler");
00117         radioRK2 = new QRadioButton("RK2");
00118         radioRK4 = new QRadioButton("RK4");
00119         interpolation->addWidget(radioEuler);
00120         interpolation->addWidget(radioRK2);
00121         interpolation->addWidget(radioRK4);
00122         interpolation->addStretch();
00123 
00124         QGroupBox* ibox = new QGroupBox("Interpolation");
00125         ibox->setLayout(interpolation);
00126         
00127         interpolationGroup = new QButtonGroup();
00128         interpolationGroup->addButton(radioEuler,0);
00129         interpolationGroup->addButton(radioRK2,1);
00130         interpolationGroup->addButton(radioRK4,2);
00131         radioEuler->setChecked(true);
00132 
00133         gridStreamlines->addWidget(ibox,1,0);
00134 
00135         streamlines->setLayout(gridStreamlines);
00137 
00138         layout->addWidget(arrows);
00139         layout->addWidget(texture);
00140         layout->addWidget(streamlines);
00141         layout->addStretch();
00142         this->setLayout(layout);
00143 
00144 }
00145 
00146 void SettingsWidget::updateSlider(int value, int slider)
00147 {
00148         std::cout << "Slider " << slider << " changed to " << value << std::endl;
00149 
00150         switch(slider)
00151         {
00152         case 0:
00153                 sliderArrowsCount->setValue(value);
00154                 break;
00155                 
00156         case 1:
00157                 sliderArrowsSize->setValue(value);
00158                 break;
00159 
00160         case 2:
00161                 sliderTextureResolution->setValue(value);
00162                 break;
00163 
00164         case 3:
00165                 sliderSLdsep->setValue(value);
00166                 break;
00167 
00168         case 4:
00169                 sliderSLdtest->setValue(value);
00170                 break;
00171 
00172         case 5: 
00173                 sliderSLdt->setValue(value);
00174                 break;
00175         }
00176 }
00177 void SettingsWidget::ConnectSignals()
00178 {
00179         QObject::connect(sliderArrowsCount,SIGNAL(valueChanged(int)),this,SLOT(arrowsCountSliderChanged(int)));
00180         QObject::connect(sliderArrowsSize,SIGNAL(valueChanged(int)),this,SLOT(arrowsSizeSliderChanged(int)));
00181         QObject::connect(sliderTextureResolution,SIGNAL(valueChanged(int)),this,SLOT(textureResolutionSliderChanged(int)));
00182         QObject::connect(sliderSLdsep,SIGNAL(valueChanged(int)),this,SLOT(sldsepSliderChanged(int)));
00183         QObject::connect(sliderSLdtest,SIGNAL(valueChanged(int)),this,SLOT(sldtestSliderChanged(int)));
00184         QObject::connect(sliderSLdt,SIGNAL(valueChanged(int)),this,SLOT(sldtSliderChanged(int)));
00185         QObject::connect(checkboxGroup,SIGNAL(buttonClicked(int)),this,SIGNAL(streamlineModeChanged(int)));
00186         QObject::connect(interpolationGroup,SIGNAL(buttonClicked(int)),this,SIGNAL(streamlineInterpolationChanged(int)));
00187         QObject::connect(computeButton,SIGNAL(clicked()),this,SIGNAL(streamlineComputeClicked()));
00188 }
00189 SettingsWidget::~SettingsWidget()
00190 {
00191 
00192 }
 All Classes Functions Variables Friends