Optika_GUI.cpp

Go to the documentation of this file.
00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 //         Optika: A Tool For Developing Parameter Obtaining GUIs
00005 //                Copyright (2009) Sandia Corporation
00006 // 
00007 // Under terms of Contract DE-AC04-94AL85000, with Sandia Corporation, the 
00008 // U.S. Government retains certain rights in this software.
00009 // 
00010 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //  
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //  
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Kurtis Nusbaum (klnusbaum@gmail.com) 
00025 // 
00026 // ***********************************************************************
00027 // @HEADER
00028 #include <QApplication>
00029 #include <QtGui>
00030 #include "Optika_GUI.hpp"
00031 #include <iostream>
00032 namespace Optika{
00033 
00034 void getInput(Teuchos::RCP<Teuchos::ParameterList> validParameters){
00035   {
00036     using namespace Qt;
00037     int argNum=1;
00038     char* args[1];
00039     std::string appName ="Optika";
00040     args[0] = &appName[0];
00041     QApplication a(argNum,args);
00042     MetaWindow *theWindow = new MetaWindow(validParameters);
00043     theWindow->show();
00044     a.exec();
00045   }
00046 }
00047 
00048 void getInput(Teuchos::RCP<Teuchos::ParameterList> validParameters, void (*customFunc)(Teuchos::RCP<const Teuchos::ParameterList>)){
00049   {
00050     using namespace Qt;
00051     int argNum=1;
00052     char* args[1];
00053     std::string appName ="Optika";
00054     args[0] = &appName[0];
00055     QApplication a(argNum,args);
00056     MetaWindow *theWindow = new MetaWindow(validParameters, customFunc);
00057     theWindow->show();
00058     a.exec();
00059   }
00060 }
00061 
00062 void getInput(Teuchos::RCP<Teuchos::ParameterList> validParameters, Teuchos::RCP<DependencySheet> dependencySheet){ 
00063   {
00064     using namespace Qt;
00065     int argNum=1;
00066     char* args[1];
00067     std::string appName ="Optika";
00068     args[0] = &appName[0];
00069     QApplication a(argNum,args);
00070     MetaWindow *theWindow = new MetaWindow(validParameters, dependencySheet);
00071     theWindow->show();
00072     a.exec();
00073   }
00074 }
00075 
00076 void getInput(Teuchos::RCP<Teuchos::ParameterList> validParameters, Teuchos::RCP<DependencySheet> dependencySheet, void (*customFunc)(Teuchos::RCP<const Teuchos::ParameterList>)){ 
00077   {
00078     using namespace Qt;
00079     int argNum=1;
00080     char* args[1];
00081     std::string appName ="Optika";
00082     args[0] = &appName[0];
00083     QApplication a(argNum,args);
00084     MetaWindow *theWindow = new MetaWindow(validParameters, dependencySheet, customFunc);
00085     theWindow->show();
00086     a.exec();
00087   }
00088 }
00089 
00090 OptikaGUI::OptikaGUI(Teuchos::RCP<Teuchos::ParameterList> validParameters):
00091   validParameters(validParameters){}
00092 
00093 
00094 OptikaGUI::OptikaGUI(Teuchos::RCP<Teuchos::ParameterList> validParameters, Teuchos::RCP<DependencySheet> dependencySheet):
00095   validParameters(validParameters),
00096   dependencySheet(dependencySheet){}
00097 
00098 void OptikaGUI::exec(){
00099   {
00100     using namespace Qt;
00101     int argNum=1;
00102     char* args[1];
00103     std::string appName ="Optika";
00104     args[0] = &appName[0];
00105     QApplication a(argNum,args);
00106     MetaWindow *theWindow;
00107     if(Teuchos::is_null(dependencySheet)){
00108       theWindow = new MetaWindow(validParameters, customFunc);
00109     }
00110     else{
00111       theWindow = new MetaWindow(validParameters, dependencySheet, customFunc);
00112     }
00113     if(title != ""){
00114       theWindow->setWindowTitle(QString::fromStdString(title));
00115     }
00116     if(iconFilePath != ""){
00117       QIcon windowIcon(QString::fromStdString(iconFilePath));
00118       QApplication::setWindowIcon(windowIcon);
00119     }
00120     if(styleSheetFilePath != ""){
00121       QString str;
00122       QFile file(QString::fromStdString(styleSheetFilePath));
00123       if (file.open(QIODevice::ReadOnly | QIODevice::Text)){
00124         QTextStream in(&file);
00125         while (!in.atEnd()) {
00126           str += in.readLine();
00127         }
00128         a.setStyleSheet(str);
00129       }
00130     }
00131     if(aboutInfo != ""){
00132       theWindow->setAboutInfo(QString::fromStdString(aboutInfo));
00133     }
00134     theWindow->show();
00135     theWindow->activateWindow();
00136     a.exec();
00137   }
00138   
00139 }
00140 
00141 void OptikaGUI::setWindowTitle(std::string title){
00142   this->title = title;
00143 }
00144 
00145 void OptikaGUI::setWindowIcon(std::string filePath){
00146   this->iconFilePath = filePath;
00147 }
00148 
00149 void OptikaGUI::setStyleSheet(std::string filePath){
00150   this->styleSheetFilePath = filePath;
00151 } 
00152 
00153 void OptikaGUI::setCustomFunction(void (*customFunc)(Teuchos::RCP<const Teuchos::ParameterList>)){
00154   this->customFunc = customFunc;
00155 }
00156 
00157 void OptikaGUI::setAboutInfo(std::string aboutInfo){
00158   this->aboutInfo = aboutInfo;
00159 }
00160 
00161 std::string OptikaGUI::getWindowTitle(){
00162   return title;
00163 }
00164 
00165 std::string OptikaGUI::getWindowIcon(){
00166   return iconFilePath;
00167 }
00168 
00169 std::string OptikaGUI::getStyleSheet(){
00170   return styleSheetFilePath;
00171 }
00172 
00173 std::string  OptikaGUI::getAboutInfo(){
00174   return aboutInfo;
00175 }
00176 
00177 }
00178 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends
Generated on Wed Apr 13 10:05:58 2011 for Optika GUI Toolik by  doxygen 1.6.3