settingwindow.cpp

Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** Author:  Jaime Valls Miro <jaime.vallsmiro@eng.uts.edu.au>
00004 **          Hue Tuan Thi <huetuan.thi@uts.edu.au>, (C) 2006
00005 **
00006 ** This file is part of the S3D Viewer Project
00007 **
00008 ** This file may be used under the terms of the GNU General Public
00009 ** License version 2.0 as published by the Free Software Foundation
00010 ** and appearing in the file LICENSE.GPL included in the packaging of
00011 ** this file.  Please review the following information to ensure GNU
00012 ** General Public Licensing requirements will be met:
00013 ** http://www.trolltech.com/products/qt/opensource.html
00014 **
00015 ** If you are unsure which license is appropriate for your use, please
00016 ** review the following information:
00017 ** http://www.trolltech.com/products/qt/licensing.html or contact the
00018 ** sales department at sales@trolltech.com.
00019 **
00020 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00021 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00022 **
00023 ****************************************************************************/
00024 
00032 #include "settingwindow.h"
00033 #include <QVBoxLayout>
00034 
00042 SettingWindow::SettingWindow( QWidget *parent)
00043     : QMainWindow( parent )
00044 {
00045     setWindowTitle("Settings");
00046 
00047     // central widget containing all other components
00048     QWidget *centralWidget = new QWidget(this);
00049 
00050     // use vertical layout for this
00051     QVBoxLayout *vLayout = new QVBoxLayout;
00052 
00053     // visual box with vertical layout as well
00054     visualBox = new QGroupBox("Visualization");
00055     vLayout->addWidget(visualBox, 1);
00056 
00057     camera = new QCheckBox("View Camera");
00058     camera->setChecked(true);
00059     connect(camera, SIGNAL(toggled(bool)), this, SLOT(changeView(bool)));
00060 
00061     bound = new QCheckBox("View bounding box");
00062     bound->setChecked(true);
00063     connect(bound, SIGNAL(toggled(bool)), this, SLOT(changeBound(bool)));
00064 
00065     movingStatus = new QCheckBox("View model while moving");
00066     movingStatus->setChecked(true);
00067     connect(movingStatus, SIGNAL(toggled(bool)), this, SLOT(changeMoving(bool)));
00068 
00069     colorSelector = new QPushButton("Background Color");
00070     connect(colorSelector, SIGNAL(clicked()), this, SLOT(selectColor()));
00071 
00072     initCam = new QPushButton("Init camera");
00073     connect(initCam, SIGNAL(clicked()), this, SLOT(initCamera()));
00074 
00075     QVBoxLayout *vsLayout = new QVBoxLayout;
00076     vsLayout->addWidget(camera);
00077     vsLayout->addWidget(bound);
00078     vsLayout->addWidget(movingStatus);
00079     vsLayout->addWidget(colorSelector);
00080     vsLayout->addWidget(initCam);
00081 
00082     visualBox->setLayout(vsLayout);
00083 
00084     // primitive settings with vertical layout
00085     primitives = new QGroupBox("3D Primitives");
00086     vLayout->addWidget(primitives, 1);
00087 
00088     QRadioButton *pointBtn = new QRadioButton("Points");
00089     pointBtn->setChecked(true);
00090     connect(pointBtn, SIGNAL(toggled(bool)), this, SLOT(toPoint(bool)));
00091 
00092     QRadioButton *cubeBtn = new QRadioButton("Cubes");
00093     connect(cubeBtn, SIGNAL(toggled(bool)), this, SLOT(toCube(bool)));
00094 
00095     QLabel *cubeWidthLbl = new QLabel("Width");
00096     cubeWidthSpin = new QSpinBox;
00097     cubeWidthSpin->setRange( 0 , 60);
00098     cubeWidthSpin->setSingleStep(1);
00099     cubeWidthSpin->setValue(10);
00100     connect(cubeWidthSpin, SIGNAL(valueChanged(int)), this, SLOT(changeCubeWidth(int)));
00101 
00102     QHBoxLayout *cubeLayout = new QHBoxLayout;
00103     cubeLayout->addWidget(cubeBtn);
00104     cubeLayout->addWidget(cubeWidthLbl);
00105     cubeLayout->addWidget(cubeWidthSpin);
00106 
00107     QCheckBox *orgColor = new QCheckBox("Original Color");
00108     orgColor->setChecked(true);
00109     connect(orgColor, SIGNAL(toggled(bool)), this, SLOT(initColor(bool)));
00110 
00111     alterColor = new QPushButton("Change Color");
00112     connect(alterColor, SIGNAL(clicked()), this, SLOT(changeColor()));
00113     alterColor->setEnabled(false);
00114 
00115     QHBoxLayout *colorBoxLo = new QHBoxLayout;
00116     colorBoxLo->addWidget(orgColor);
00117     colorBoxLo->addWidget(alterColor);
00118 
00119     QVBoxLayout *prLayout = new QVBoxLayout;
00120     prLayout->addWidget(pointBtn);
00121     prLayout->addLayout(cubeLayout);
00122     prLayout->addLayout(colorBoxLo);
00123 
00124     primitives->setLayout(prLayout);
00125 
00126     centralWidget->setLayout(vLayout);
00127 
00128     // set centralWidget as main widget
00129     setCentralWidget(centralWidget);
00130 }
00131 
00135 SettingWindow::~SettingWindow()
00136 {
00137 }
00138 
00144 void SettingWindow::initColor(bool status){
00145     point3dWidget->initColor = status;
00146     alterColor->setEnabled(!status);
00147     point3dWidget->updateGL();
00148 }
00149 
00155 void SettingWindow::changeColor(){
00156     QColor newColor = QColorDialog::getColor(point3dWidget->pointColor);
00157     if (newColor.isValid()){
00158         point3dWidget->pointColor = newColor;
00159         point3dWidget->updateGL();
00160     }
00161 }
00162 
00168 void SettingWindow::changeCubeWidth(int cubeWidth){
00169     point3dWidget->cubeWidth = cubeWidth;
00170     point3dWidget->updateGL();
00171 }
00172 
00178 void SettingWindow::toPoint(bool status){
00179     point3dWidget->pointDrawn = status;
00180     point3dWidget->cubeDrawn = !status;
00181     point3dWidget->updateGL();
00182 }
00183 
00189 void SettingWindow::toCube(bool status){
00190     point3dWidget->cubeDrawn = status;
00191     point3dWidget->pointDrawn = !status;
00192     point3dWidget->updateGL();
00193 }
00194 
00200 void SettingWindow::changeMoving(bool status){
00201     point3dWidget->movingClear = !status;
00202     point3dWidget->updateGL();
00203 }
00204 
00210 void SettingWindow::changeBound(bool status){
00211     point3dWidget->bounding = status;
00212     point3dWidget->updateGL();
00213 }
00214 
00220 void SettingWindow::changeView(bool status){
00221     point3dWidget->cameraEnable = status;
00222     point3dWidget->updateGL();
00223 }
00224 
00230 void SettingWindow::initCamera(){
00231     point3dWidget->initCamera();
00232 }
00233 
00239 void SettingWindow::setPointWidget(Point3dWidget *pw){
00240     point3dWidget = pw;
00241     connect(point3dWidget, SIGNAL(cubeWidthChanged(int)), cubeWidthSpin, SLOT(setValue(int)));
00242     point3dWidget->updateGL();
00243 }
00244 
00250 void SettingWindow::selectColor(){
00251     QColor newColor = QColorDialog::getColor(point3dWidget->bColor);
00252     if (newColor.isValid()){
00253         point3dWidget->bColor = newColor;
00254         point3dWidget->updateGL();
00255     }
00256 }

Generated on Mon Aug 14 10:44:20 2006 for S3DViewer by  doxygen 1.4.4