]> Creatis software - bbtkGEditor.git/blob - lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxBlackBoxEditionDialog.cxx
A little bug to delete the boxes (only boxes) was fixed
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsWxGUIEditorGraphic / wxBlackBoxEditionDialog.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::wxBlackBoxEditionDialog . 
34 */
35
36 #include "wxBlackBoxEditionDialog.h"
37 #include "creaWx.h"
38
39 namespace bbtk
40 {
41         //=========================================================================
42
43         wxBlackBoxEditionDialog::wxBlackBoxEditionDialog(wxGUIEditorGraphicBBS *parent,GBlackBoxModel *model):wxDialog(parent,wxID_ANY,_T(""), wxDefaultPosition, wxSize(480, 640))
44         {
45                 _model=model;
46                 std::string title("BlackBox Editing - Name:");
47                 title+=_model->getBBTKName();
48                 title+=" Type:";
49                 title+=_model->getBBTKType();
50                 SetTitle(std2wx(title));
51
52                 constructBlackBoxEditionDialog();
53         }
54
55         //=========================================================================
56
57         wxBlackBoxEditionDialog::wxBlackBoxEditionDialog(wxGUIEditorGraphicBBS *parent,wxVtkSceneManager* scene):wxDialog(parent, wxID_ANY, _T(""), wxDefaultPosition, wxSize(300, 300))
58         {
59                 
60         }
61
62         //=========================================================================
63
64         wxBlackBoxEditionDialog::~wxBlackBoxEditionDialog()
65         {
66
67         }
68
69         //=========================================================================
70
71         void wxBlackBoxEditionDialog::constructBlackBoxEditionDialog()
72         {
73                 wxBoxSizer *sizerDialog = new wxBoxSizer(wxVERTICAL);
74
75                 wxStaticText *text = new wxStaticText(this, -1, _T("Input Ports"));
76                                 
77                 std::vector<GPortModel*> lstInputs = _model->getInputPorts();
78                 wxGridSizer *sizer = new wxGridSizer(lstInputs.size(),3,5,5);             
79                 for(int i = 0;i<lstInputs.size();i++)
80                 {
81                         GPortModel* port = lstInputs[i];
82                         wxStaticText *lblName = new wxStaticText(this, -1, std2wx(port->getBBTKName()),wxDefaultPosition,wxSize(100,30));
83                         wxStaticText *lblType = new wxStaticText(this, -1, std2wx(port->getBBTKType()),wxDefaultPosition,wxSize(150,30));
84                         wxTextCtrl *txtValue = new wxTextCtrl(this, -1, _T(""),wxDefaultPosition,wxSize(50,15));
85
86                         if(port->getValue()!="")
87                         {
88                                 txtValue->SetLabel(crea::std2wx(port->getValue()));
89                         }
90
91                         if(port->isConnected())
92                         {
93                                 std::string connected("--Port Connected--");
94                                 txtValue->SetLabel(crea::std2wx(connected));
95                                 txtValue->SetEditable(false);
96                         }
97
98                         _lstNames.push_back(lblName);
99                         _lstTypes.push_back(lblType);
100                         _lstValues.push_back(txtValue);
101
102                         sizer->Add(lblName,0,wxEXPAND,5);
103                         sizer->Add(lblType,0,wxCENTRE|wxEXPAND,5);
104                         sizer->Add(txtValue,0,wxEXPAND,5);
105                 }
106                 
107                 wxBoxSizer *buts = new wxBoxSizer(wxHORIZONTAL);
108                 wxButton *okButton = new wxButton(this, 1003, _T("Ok"),wxDefaultPosition, wxSize(70, 30));
109                 wxButton *closeButton = new wxButton(this, 1004, _T("Close"), wxDefaultPosition, wxSize(70, 30));
110
111                 // connect command event handlers
112                 Connect(1003,wxEVT_COMMAND_BUTTON_CLICKED,wxCommandEventHandler(wxBlackBoxEditionDialog::onClickOk));
113                 Connect(1004,wxEVT_COMMAND_BUTTON_CLICKED,wxCommandEventHandler(wxBlackBoxEditionDialog::onClickClose));
114                 
115                 buts->Add(okButton,0,wxCENTRE|wxEXPAND,5);
116                 buts->Add(closeButton,0,wxCENTRE|wxEXPAND,5);
117
118                 sizerDialog->Add(text,0,wxALIGN_TOP,10);
119                 sizerDialog->AddSpacer(5);
120                 sizerDialog->Add(sizer,0,wxALIGN_CENTER,10);
121                 sizerDialog->Add(buts,0,wxALIGN_CENTER | wxTOP | wxBOTTOM,10);
122
123                 SetSizer(sizerDialog);
124
125                 Centre();
126                 ShowModal();
127                 Destroy();
128         }
129
130         //=========================================================================
131
132         void wxBlackBoxEditionDialog::onClickOk(wxCommandEvent& event)
133         {
134
135                 for(int i=0;i<_lstValues.size();i++)
136                 {
137                         std::string text = wx2std(_lstValues[i]->GetLabelText());               
138                         _model->setValueToInputPort(i,text);
139                 }
140
141                 Close(true);
142         }
143
144         //=========================================================================
145
146         void wxBlackBoxEditionDialog::onClickClose(wxCommandEvent& event)
147         {
148                 Close(true);            
149         }
150
151         //=========================================================================
152
153 }  // EO namespace bbtk
154
155 // EOF