]> Creatis software - bbtkGEditor.git/blob - lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxEditionDialog.cxx
Setting values in a blackbox and almost setting values in the scene properties
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsWxGUIEditorGraphic / wxEditionDialog.cxx
1 /*=========================================================================                                                                               
2 Program:   bbtk
3 Module:    $RCSfile$
4 Language:  C++
5 Date:      $Date$
6 Version:   $Revision$
7 =========================================================================*/
8
9 /* ---------------------------------------------------------------------
10
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
13 *
14 *  This software is governed by the CeCILL-B license under French law and 
15 *  abiding by the rules of distribution of free software. You can  use, 
16 *  modify and/ or redistribute the software under the terms of the CeCILL-B 
17 *  license as circulated by CEA, CNRS and INRIA at the following URL 
18 *  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
19 *  or in the file LICENSE.txt.
20 *
21 *  As a counterpart to the access to the source code and  rights to copy,
22 *  modify and redistribute granted by the license, users are provided only
23 *  with a limited warranty  and the software's author,  the holder of the
24 *  economic rights,  and the successive licensors  have only  limited
25 *  liability. 
26 *
27 *  The fact that you are presently reading this means that you have had
28 *  knowledge of the CeCILL-B license and that you accept its terms.
29 * ------------------------------------------------------------------------ */                                                                         
30
31 /**
32 *  \file 
33 *  \brief Class bbtk::wxEditionDialog . 
34 */
35
36
37 #include "wxEditionDialog.h"
38
39
40 namespace bbtk
41 {
42         //=========================================================================
43
44         wxEditionDialog::wxEditionDialog(wxGUIEditorGraphicBBS *parent,GBlackBoxModel *model):wxDialog(parent,wxID_ANY,"", wxDefaultPosition, wxSize(480, 640))
45         {
46                 _model=model;
47                 std::string title = "BlackBox Editing - Name:";
48                 title+=_model->getBBTKName();
49                 title+=" Type:";
50                 title+=_model->getBBTKType();
51                 SetTitle(wxT(title));
52
53                 constructBlackBoxEditionDialog();
54         }
55
56         //=========================================================================
57
58         wxEditionDialog::wxEditionDialog(wxGUIEditorGraphicBBS *parent,wxVtkSceneManager* scene):wxDialog(parent, wxID_ANY, "", wxDefaultPosition, wxSize(300, 300))
59         {
60                 
61         }
62
63         //=========================================================================
64
65         wxEditionDialog::~wxEditionDialog()
66         {
67
68         }
69
70         //=========================================================================
71
72         void wxEditionDialog::constructBlackBoxEditionDialog()
73         {
74                 wxBoxSizer *sizerDialog = new wxBoxSizer(wxVERTICAL);
75
76                 wxStaticText *text = new wxStaticText(this, -1, wxT("Input Ports"));
77                                 
78                 std::vector<GPortModel*> lstInputs = _model->getInputPorts();
79                 wxGridSizer *sizer = new wxGridSizer(lstInputs.size(),3,5,5);             
80                 for(int i = 0;i<lstInputs.size();i++)
81                 {
82                         GPortModel* port = lstInputs[i];
83                         wxStaticText *lblName = new wxStaticText(this, -1, wxT(port->getBBTKName()),wxDefaultPosition,wxSize(100,30));
84                         wxStaticText *lblType = new wxStaticText(this, -1, wxT(port->getBBTKType()),wxDefaultPosition,wxSize(150,30));
85                         wxTextCtrl *txtValue = new wxTextCtrl(this, -1, wxT(""),wxDefaultPosition,wxSize(50,15));
86
87                         if(port->getValue()!="")
88                         {
89                                 txtValue->SetLabel(wxT(port->getValue()));
90                         }
91
92                         if(port->isConnected())
93                         {
94                                 std::string connected = "--Port Connected--";
95                                 txtValue->SetLabel(wxT(connected));
96                                 txtValue->SetEditable(false);
97                         }
98
99                         _lstNames.push_back(lblName);
100                         _lstTypes.push_back(lblType);
101                         _lstValues.push_back(txtValue);
102
103                         sizer->Add(lblName,0,wxEXPAND,5);
104                         sizer->Add(lblType,0,wxCENTRE|wxEXPAND,5);
105                         sizer->Add(txtValue,0,wxEXPAND,5);
106
107                 }
108                 
109                 wxBoxSizer *buts = new wxBoxSizer(wxHORIZONTAL);
110                 wxButton *okButton = new wxButton(this, 1003, wxT("Ok"),wxDefaultPosition, wxSize(70, 30));
111                 wxButton *closeButton = new wxButton(this, 1004, wxT("Close"), wxDefaultPosition, wxSize(70, 30));
112
113                 // connect command event handlers
114                 Connect(1003,wxEVT_COMMAND_BUTTON_CLICKED,wxCommandEventHandler(wxEditionDialog::onClickOk));
115                 Connect(1004,wxEVT_COMMAND_BUTTON_CLICKED,wxCommandEventHandler(wxEditionDialog::onClickClose));
116                 
117                 buts->Add(okButton,0,wxCENTRE|wxEXPAND,5);
118                 buts->Add(closeButton,0,wxCENTRE|wxEXPAND,5);
119
120                 sizerDialog->Add(text,0,wxALIGN_TOP,10);
121                 sizerDialog->AddSpacer(5);
122                 sizerDialog->Add(sizer,0,wxALIGN_CENTER,10);
123                 sizerDialog->Add(buts,0,wxALIGN_CENTER | wxTOP | wxBOTTOM,10);
124
125                 SetSizer(sizerDialog);
126
127                 Centre();
128                 ShowModal();
129                 Destroy();
130
131         }
132
133         //=========================================================================
134
135         void wxEditionDialog::onClickOk(wxCommandEvent& event)
136         {
137
138                 for(int i=0;i<_lstValues.size();i++)
139                 {
140                         std::string text = _lstValues[i]->GetLabelText();               
141                         _model->setValueToInputPort(i,text);
142                 }
143
144                 Close(true);
145         }
146
147         //=========================================================================
148
149         void wxEditionDialog::onClickClose(wxCommandEvent& event)
150         {
151                 Close(true);            
152         }
153
154         //=========================================================================
155
156 }  // EO namespace bbtk
157
158 // EOF
159