/home/enzo/treballs/fib/pfc/nanocomp/src/resultsView.cpp

Go to the documentation of this file.
00001 /*
00002  *                                                                         *
00003  *   This program is free software; you can redistribute it and/or modify  *
00004  *   it under the terms of the GNU General Public License as published by  *
00005  *   the Free Software Foundation; either version 2 of the License, or     *
00006  *   (at your option) any later version.                                   *
00007  *                                                                         *
00008  *   This program is distributed in the hope that it will be useful,       *
00009  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00010  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00011  *   GNU General Public License for more details.                          *
00012  *                                                                         *
00013  *   You should have received a copy of the GNU General Public License     *
00014  *   along with this program; if not, write to the                         *
00015  *   Free Software Foundation, Inc.,                                       *
00016  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00017                                                                           */
00018 
00019 // $Revision: 1.4 $
00020 
00021 #include "resultsView.hpp"
00022 #include "nanoStatusBar.hpp"
00023 #include <wx/statline.h>
00024 
00025 enum
00026 {
00027     ID_LISTROWS = 0,
00028     ID_LISTINFORMATION,
00029     ID_LISTPATH,
00030     ID_CANVAS, 
00031     ID_CANVASINITIAL,
00032     ID_TABLE
00033 };
00034 
00035 BEGIN_EVENT_TABLE(ResultsView, wxFrame)
00036     EVT_LISTBOX (ID_LISTROWS, ResultsView::OnRowsSelected)
00037     EVT_LISTBOX (ID_LISTINFORMATION, ResultsView::OnInformationSelected)
00038     EVT_LISTBOX (ID_LISTPATH, ResultsView::OnPathSelected)
00039 END_EVENT_TABLE()
00040 
00042 
00047 ResultsView::ResultsView(wxWindow* parent, wxWindowID id, SimulationManager *controller)
00048     :wxFrame(parent, id, _("Simulation Results"))
00049 {
00050     this->controller = controller;
00051     Maximize();
00052     initControls();
00053     initSizers();
00054     NanoStatusBar *statusBar = new NanoStatusBar(this);
00055     SetStatusBar(statusBar);
00056     SetMinSize(wxSize(640, 480));
00057     Center();
00058     SetStatusText(_("Click on a row and an event to see the simulation trace"), 0);
00059 }
00060 
00061 
00063 ResultsView::~ResultsView()
00064 {
00065 }
00066 
00067 
00069 void ResultsView::initControls()
00070 {
00071     listRows = new wxListBox(this, ID_LISTROWS, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_SINGLE);
00072     listInformation = new wxListBox(this, ID_LISTINFORMATION, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_SINGLE);
00073     listPath = new wxListBox(this, ID_LISTPATH, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_SINGLE);
00074     labelResult = new wxStaticText(this, wxID_ANY, _("Simulation result: "), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE);
00075     labelRows = new wxStaticText(this, wxID_ANY, _("Select row"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE);
00076     labelInformation = new wxStaticText(this, wxID_ANY, _("Select event"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE);
00077     labelPath = new wxStaticText(this, wxID_ANY, _("Simulation trace"), wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE);
00078     canvasResult = new LayoutCanvas(this, ID_CANVAS, Grid());
00079     canvasInitial = new LayoutCanvas(this, ID_CANVASINITIAL, Grid());
00080     tCanvas = new TruthTableCanvas(this, ID_TABLE, TruthTable());
00081     tCanvas->setEditable(false);
00082 }
00083 
00084 
00086 void ResultsView::initSizers()
00087 {
00088     wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);
00089     
00090     mainSizer->Add(labelResult, 0, wxEXPAND | wxALL, 10);
00091     mainSizer->Add(new wxStaticLine(this, wxID_ANY), 
00092                                 0, 
00093                                 wxEXPAND | wxALL, 
00094                                 5);
00095     
00096     wxGridSizer *gridSizer = new wxGridSizer(2, 2);
00097     
00098     wxStaticBoxSizer *listSizer = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Simulation information"));
00099     
00100     wxBoxSizer *rowSizer = new wxBoxSizer(wxVERTICAL);
00101     rowSizer->Add(labelRows, 0, wxEXPAND | wxALL, 2);
00102     rowSizer->Add(listRows, 1, wxEXPAND | wxALL, 2);
00103     
00104     wxBoxSizer *informationSizer = new wxBoxSizer(wxVERTICAL);
00105     informationSizer->Add(labelInformation, 0, wxEXPAND | wxALL, 2);
00106     informationSizer->Add(listInformation, 1, wxEXPAND | wxALL, 2);
00107     
00108     wxBoxSizer *pathSizer = new wxBoxSizer(wxVERTICAL);
00109     pathSizer->Add(labelPath, 0, wxEXPAND | wxALL, 2);
00110     pathSizer->Add(listPath, 1, wxEXPAND | wxALL, 2);
00111     
00112     listSizer->Add(rowSizer, 1, wxEXPAND | wxALL, 2);
00113     listSizer->Add(informationSizer, 1, wxEXPAND | wxALL, 2);
00114     listSizer->Add(pathSizer, 1, wxEXPAND | wxALL, 2);
00115     
00116     gridSizer->Add(listSizer, 1, wxEXPAND | wxALL, 2);
00117     
00118     wxStaticBoxSizer *canvasSizer = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Simulation step"));
00119     canvasSizer->Add(canvasResult, 1, wxEXPAND | wxALL, 2);
00120     gridSizer->Add(canvasSizer, 1, wxEXPAND | wxALL, 2);
00121     
00122     wxStaticBoxSizer *tableSizer = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Truth table"));
00123     tableSizer->Add(tCanvas, 1, wxEXPAND | wxALL, 2);
00124     gridSizer->Add(tableSizer, 1, wxEXPAND | wxALL, 2);
00125     
00126     wxStaticBoxSizer *initialCanvasSizer = new wxStaticBoxSizer(wxHORIZONTAL, this, _("Initial configuration"));
00127     initialCanvasSizer->Add(canvasInitial, 1, wxEXPAND | wxALL, 2);
00128     gridSizer->Add(initialCanvasSizer, 1, wxEXPAND | wxALL, 2);
00129     
00130     mainSizer->Add(gridSizer, 1, wxEXPAND | wxALL, 2);
00131     
00132     SetSizer(mainSizer);
00133 }
00134 
00135 
00137 
00142 void ResultsView::updateGrid(Grid grid, bool changed)
00143 {
00144     canvasResult->setGrid(grid, changed);
00145 }
00146 
00147 
00149 
00154 void ResultsView::updateInitialGrid(Grid grid, bool changed)
00155 {
00156     canvasInitial->setGrid(grid, changed);
00157 }
00158 
00159 
00161 
00164 void ResultsView::updateRowList(wxArrayString strings)
00165 {
00166     listRows->Set(strings);
00167 }
00168 
00169 
00171 
00174 void ResultsView::selectRow(unsigned int row)
00175 {
00176     listRows->SetSelection(row);
00177 }
00178 
00179 
00181 
00184 void ResultsView::updateInformationList(wxArrayString strings)
00185 {
00186     listInformation->Set(strings);
00187 }
00188 
00189 
00191 
00194 void ResultsView::selectInformation(unsigned int information)
00195 {
00196     listInformation->SetSelection(information);
00197 }
00198 
00199 
00201 
00204 void ResultsView::updatePathList(wxArrayString strings)
00205 {
00206     listPath->Set(strings);
00207 }
00208 
00209 
00211 
00214 void ResultsView::selectPath(unsigned int path)
00215 {
00216     listPath->SetSelection(path);
00217 }
00218 
00219 
00221 
00224 void ResultsView::errorMsg(wxString message)
00225 {
00226     
00227 }
00228 
00229 
00231 
00234 void ResultsView::OnRowsSelected(wxCommandEvent &event)
00235 {
00236     controller->rowSelected(event.GetInt());
00237 }
00238 
00239 
00241 
00244 void ResultsView::OnInformationSelected(wxCommandEvent &event)
00245 {
00246     controller->informationSelected(event.GetInt());
00247 }
00248 
00249 
00251 
00254 void ResultsView::OnPathSelected(wxCommandEvent &event)
00255 {
00256     controller->pathSelected(event.GetInt());
00257 }
00258 
00259 
00261 
00264 void ResultsView::setTable(TruthTable table)
00265 {
00266     tCanvas->setNewTable(table);
00267     Layout();
00268 }
00269 
00270 
00272 
00275 void ResultsView::setResult(bool success)
00276 {
00277     if (success)
00278     {
00279         labelResult->SetLabel(_("Simulation result: SUCCESS"));
00280         labelResult->SetForegroundColour(*wxGREEN);
00281     }
00282     else
00283     {
00284         labelResult->SetLabel(_("Simulation result: FAILURE"));
00285         labelResult->SetForegroundColour(*wxRED);
00286     }
00287     Layout();
00288 }
00289 
00290 
00292 
00295 void ResultsView::setInputs(vector <coordinate> inputs)
00296 {
00297     canvasInitial->setAssignedInputs(inputs);
00298 }
00299 
00300 
00302 
00305 void ResultsView::setOutputs(vector <coordinate> outputs)
00306 {
00307     canvasInitial->setAssignedOutputs(outputs);
00308 }

Generated on Fri Sep 1 23:55:14 2006 for NanoComp by  doxygen 1.4.6