example/CustomGUIExample/main.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 "Teuchos_ParameterList.hpp"
00029 #include "Teuchos_StandardParameterEntryValidators.hpp"
00030 #include "Teuchos_Array.hpp"  
00031 #include "Teuchos_Version.hpp"
00032 #include "Optika_GUI.hpp"
00033 #include "Teuchos_XMLParameterListHelpers.hpp"
00034 #include "Teuchos_FancyOStream.hpp"
00035 #include "Teuchos_VerboseObject.hpp"
00036 
00037 int main(int argc, char* argv[])
00038 {
00039  /*
00040   * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
00041   * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!              ATTENTION              !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
00042   * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
00043   * !!!!   PLEASE VIEW THE BASIC EXAMPLE FIRST BEFORE READING THIS EXAMPLE. IT PROVIDES FUNDAMENTAL    !!!! 
00044   * !!!!   KNOWLEDGE THAT WILL BE VERY HELPFUL IN UNDERSTANDING THIS EXAMPLE.                          !!!!
00045   * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
00046   * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
00047   */ 
00048 
00049   /*
00050    * Defautls not good enought for you? That's understandable and why we've given
00051    * you a few ways to customize your GUI as you see fit. The purpose of this example is
00052    * to demonstrate those capabilities.
00053    */
00054 
00055   /* 
00056    * So let's setup a list of parameters to obtain. They could be anything really. We'll just reuse the
00057    * list we created in the Basic Example (which you've read already because you're smart and headed the gigantic
00058    * warning I put at the top of this example(.
00059    */
00060   Teuchos::RCP<Teuchos::ParameterList> My_List = Teuchos::RCP<Teuchos::ParameterList>(new Teuchos::ParameterList);
00061 
00062   My_List->set("Max Iters", 1550, "Determines the maximum number of iterations in the solver");
00063   My_List->set("Tolerance", 1e-10, "The tolerance used for the convergence check");
00064   
00065   Teuchos::RCP<Optika::StringValidator> solverValidator = 
00066      Teuchos::RCP<Optika::StringValidator>(new Optika::StringValidator(Teuchos::tuple<std::string>("GMRES", "CG", "TFQMR")));
00067   My_List->set( "Solver", "GMRES", "The type of solver to use.", solverValidator);
00068 
00069   Teuchos::Array<double> doubleArray( 10, 0.0 );
00070   My_List->set("Initial Guess", doubleArray, "The initial guess as a RCP to an array object.");
00071 
00072   Teuchos::ParameterList&
00073     Prec_List = My_List->sublist("Preconditioner",false,"Sublist that defines the preconditioner.");
00074 
00075   Prec_List.set("Type", "ILU", "The tpye of preconditioner to use");
00076   Prec_List.set("Drop Tolerance", 1e-3
00077                 ,"The tolerance below which entries from the\n""factorization are left out of the factors.");
00078 
00079   /*
00080    * Now here's were things get a little differnent. Instead of just calling Optika::getInput(),
00081    * we're actually going to create and OptikaGUI object. It will be the vehical through which
00082    * we customize the GUI.
00083    */
00084    Optika::OptikaGUI myGUI(My_List);
00085 
00086   /*
00087    * Now we can start configuring what our GUI will look like. Let's start with the window
00088    * title.
00089    */
00090    myGUI.setWindowTitle("My Custom GUI");
00091 
00092   /*
00093    * We can set the information that will be displayed in the about dialog for the
00094    * gui.
00095    */
00096    myGUI.setAboutInfo("This is a little GUI I made.");
00097 
00098   /*
00099    * If you have an icon you'd like to use as the WindowIcon you can do that too.
00100    * just specify the path to the file containig the icon. Supported formats will
00101    * vary from system to system and your QT installation, but the following
00102    * should always work:
00103     -BMP   -GIF  -JPG  -JPEG
00104   -MNG   -PNG  -PBM  -PGM
00105   -PPM   -TIFF -XBM  -XPM
00106   -SVG
00107    */
00108    myGUI.setWindowIcon("myIcon.png");
00109 
00110   /*
00111    * Now if you really wanna dive into your GUI design you can use
00112    * QT style sheets. Since optika is build on top of QT, you can
00113    * use QT style sheets to style the various widgets used by
00114    * Optika. The main widges Optika uses thay you'll probably 
00115    * wanna style are:
00116       -QTreeView -QDialog -QMainWindow
00117       -QPushButton -QSpinBox -QMenu
00118     -QMenuBar
00119    * You might need to look at some of the Optika source code to really
00120    * get fine-grained styling control. Once your stylesheet is made,
00121    * all you need to do is specify the filepath to the Optika_GUI
00122    * object. Also note the style sheet provided in this example is 
00123    * exceptionally ugly.
00124    */
00125    myGUI.setStyleSheet("myStyleSheet.qss");
00126 
00127   /*
00128    * Now that we're all ready to go, we just call the exec funtion on
00129    * our Optika_GUI object.
00130    */
00131    myGUI.exec();
00132 
00133    /*
00134     * That's it! You can make even more awesome GUIs now!.
00135   */
00136   return 0;
00137 }
00138 
 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