Optika GUI Toolik  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
example/CustomGUIExample/main.cpp
Go to the documentation of this file.
1 // @HEADER
2 // ***********************************************************************
3 //
4 // Optika: A Tool For Developing Parameter Obtaining GUIs
5 // Copyright (2009) Sandia Corporation
6 //
7 // Under terms of Contract DE-AC04-94AL85000, with Sandia Corporation, the
8 // U.S. Government retains certain rights in this software.
9 //
10 // Redistribution and use in source and binary forms, with or without
11 // modification, are permitted provided that the following conditions are
12 // met:
13 //
14 // 1. Redistributions of source code must retain the above copyright
15 // notice, this list of conditions and the following disclaimer.
16 //
17 // 2. Redistributions in binary form must reproduce the above copyright
18 // notice, this list of conditions and the following disclaimer in the
19 // documentation and/or other materials provided with the distribution.
20 //
21 // 3. Neither the name of the Corporation nor the names of the
22 // contributors may be used to endorse or promote products derived from
23 // this software without specific prior written permission.
24 //
25 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // Questions? Contact Kurtis Nusbaum (klnusbaum@gmail.com)
38 //
39 // ***********************************************************************
40 // @HEADER
43 #include "Teuchos_Array.hpp"
44 #include "Teuchos_Version.hpp"
45 #include "Optika_GUI.hpp"
47 #include "Teuchos_FancyOStream.hpp"
49 
50 int main(int argc, char* argv[])
51 {
52  /*
53  * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
54  * !!!!!!!!!!!!!!!! ATTENTION !!!!!!!!!!!!!!!!!!!!!!
55  * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
56  * !!!! PLEASE VIEW THE BASIC EXAMPLE FIRST BEFORE READING THIS !!!!!!
57  * !!!! EXAMPLE. IT PROVIDES FUNDAMENTAL KNOWLEDGE THAT WILL BE VERY !!!!!!
58  * !!!! HELPFUL IN UNDERSTANDING THIS EXAMPLE. !!!!!!
59  * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
60  * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
61  */
62 
63  /*
64  * Defautls not good enought for you, eh? Well I guess That's understandable
65  * and why we've given you a few ways to customize your GUI as you see fit.
66  * The purpose of this example is to demonstrate those capabilities.
67  */
68 
69  /*
70  * So let's setup a list of parameters to obtain. They could be anything
71  * really. We'll just reuse the list we created in the Basic Example
72  * (which you've read already because you're smart and headed the gigantic
73  * warning I put at the top of this example.
74  */
75  using Teuchos::RCP;
78  using Teuchos::tuple;
79  using Teuchos::Array;
80  using Teuchos::rcp;
81  RCP<ParameterList> My_List = rcp(new ParameterList);
82 
83  My_List->set(
84  "Max Iters",
85  1550,
86  "Determines the maximum number of iterations in the solver");
87  My_List->set(
88  "Tolerance",
89  1e-10,
90  "The tolerance used for the convergence check");
91 
92  RCP<StringValidator> solverValidator =
93  rcp(new StringValidator(tuple<std::string>("GMRES", "CG", "TFQMR")));
94  My_List->set(
95  "Solver",
96  "GMRES",
97  "The type of solver to use.",
98  solverValidator);
99 
100  Array<double> doubleArray( 10, 0.0 );
101  My_List->set(
102  "Initial Guess",
103  doubleArray,
104  "The initial guess as a RCP to an array object.");
105 
106  ParameterList& Prec_List = My_List->sublist(
107  "Preconditioner",
108  false,
109  "Sublist that defines the preconditioner.");
110 
111  Prec_List.set("Type", "ILU", "The tpye of preconditioner to use");
112  Prec_List.set(
113  "Drop Tolerance",
114  1e-3,
115  "The tolerance below which entries from the"
116  "factorization are left out of the factors.");
117 
124  Optika::OptikaGUI myGUI(My_List);
125 
130  myGUI.setWindowTitle("My Custom GUI");
131 
136  myGUI.setAboutInfo("This is a little GUI I made.");
137 
148  myGUI.setWindowIcon("myIcon.png");
149 
165  myGUI.setStyleSheet("myStyleSheet.qss");
166 
172  myGUI.exec();
173 
177  return 0;
178 }
179 
int main(int argc, char *argv[])
A collection of functions and an Object that serve as the primary interface to the Optika package all...
A class that allows the user to create and customize their Optika GUI.
Definition: Optika_GUI.hpp:147
void setWindowIcon(const std::string &filePath)
Sets the window icon to the image specified in the filePath.
Definition: Optika_GUI.cpp:221
TEUCHOS_DEPRECATED RCP< T > rcp(T *p, Dealloc_T dealloc, bool owns_mem)
void setStyleSheet(const std::string &filePath)
Sets the QT style sheet that should be used for the GUI.
Definition: Optika_GUI.cpp:225
void setWindowTitle(const std::string &title)
Sets the title of the GUI window that is displayed to the user.
Definition: Optika_GUI.cpp:217
void exec()
Runs the GUI and gets the user input.
Definition: Optika_GUI.cpp:177
void setAboutInfo(const std::string &aboutInfo)
Adds the information specified to the about dialog of the GUI.
Definition: Optika_GUI.cpp:233