[Thplot-cvs] CVS: thplot/src/Gui ParameterSelect.cpp,1.2,1.3 ParameterSelect.h,1.1.1.1,1.2
Status: Pre-Alpha
Brought to you by:
apeden
From: Tony P. <ap...@us...> - 2002-07-02 17:21:47
|
Update of /cvsroot/thplot/thplot/src/Gui In directory usw-pr-cvs1:/tmp/cvs-serv11461/src/Gui Modified Files: ParameterSelect.cpp ParameterSelect.h Log Message: New parameter select dialog. Index: ParameterSelect.cpp =================================================================== RCS file: /cvsroot/thplot/thplot/src/Gui/ParameterSelect.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** ParameterSelect.cpp 30 Jun 2002 14:37:44 -0000 1.2 --- ParameterSelect.cpp 2 Jul 2002 17:21:44 -0000 1.3 *************** *** 1,24 **** /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Header: ParameterSelect.cpp Author: Tony Peden Date started: 6/15/02 ! ------------- Copyright (C) 2002 Tony Peden (ap...@ea...) ----------- ! This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. ! You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! Further information about the GNU General Public License can also be found on the world wide web at http://www.gnu.org. --- 1,24 ---- /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ! Header: ParameterSelect.cpp Author: Tony Peden Date started: 6/15/02 ! ------------- Copyright (C) 2002 Tony Peden (ap...@ea...) ----------- ! This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. ! You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! Further information about the GNU General Public License can also be found on the world wide web at http://www.gnu.org. *************** *** 27,118 **** #include <FL/Fl.h> #include <Gui/ParameterSelect.h> ! ParameterSelect::ParameterSelect(Globals *g){ global=g; window=NULL; ! flmb=NULL; ok_button=NULL; cancel_button=NULL; run=true; Nitems=0; - Nselected=0; } ! ! ParameterSelect::~ParameterSelect(void) { delete ok_button; delete cancel_button; ! delete flmb; } ! bool ParameterSelect::showDialog(csvData *data) { run=true; ! selected.clear(); Nitems=0; int offset=5; int buttonw=80; ! int buttonh=30; ! int w = 200; ! int h = 300; ! int x = global->getMainWindow()->x() + global->getMainWindow()->w()/2 - w/2; ! int y = global->getMainWindow()->y() + global->getMainWindow()->h()/2 - h/2; ! window = new Fl_Window(x,y,200,300,"Select Parameters to Plot"); ! ! int pswinw=window->w(); ! int pswinh=window->h(); // origin is upper-left corner ! flmb = new Fl_Multi_Browser(offset,offset, ! pswinw - offset, ! pswinh - buttonh - 3*offset, ! 0); ! cancel_button = new Fl_Button(pswinw - buttonw - offset, pswinh - buttonh - offset, buttonw,buttonh, "&Cancel" ); ! cancel_button->callback(static_cancel_callback,this); ! ! ok_button = new Fl_Return_Button(offset, ! pswinh - buttonh - offset, ! buttonw,buttonh, ! "OK"); ok_button->callback(static_ok_callback,this); ! window->end(); ! Nitems=data->getNumParameters(); for(int i=0;i<Nitems;i++) { ! flmb->add( data->getName(i).c_str() ); } ! window->show(); ! while(run) { Fl::wait(); } window->hide(); return true; ! } ! void ParameterSelect::cancel_callback(Fl_Widget* flw) { cout << "In Cancel callback" << endl; run=false; ! selected.clear(); ! } void ParameterSelect::ok_callback(Fl_Widget* flw) { cout << "In OK callback" << endl; ! Nselected=0; ! for(int i=1;i<=Nitems;i++) { ! if(flmb->selected(i)) { ! Nselected++; ! selected.push_back(i); ! } } run=false; - - } ! string ParameterSelect::getSelected(int idx) { ! return string( flmb->text(selected[idx]) ); ! } ! --- 27,194 ---- #include <FL/Fl.h> + #include <FL/fl_draw.h> + #include <Gui/ParameterSelect.h> ! ParameterSelect::ParameterSelect(Globals *g) { global=g; window=NULL; ! available=NULL; ! independent=NULL; ! dependent=NULL; ok_button=NULL; cancel_button=NULL; run=true; + ind_selected=false; + selected=false; Nitems=0; } ! ! ParameterSelect::~ParameterSelect(void) { delete ok_button; delete cancel_button; ! delete available; } ! bool ParameterSelect::showDialog(csvData *data) { run=true; ! dep_names.clear(); ! ind_name = ""; ! selected=false; ! ind_selected=false; Nitems=0; int offset=5; + int boxw=200; + int line_height = 20; int buttonw=80; ! int buttonh=2*offset+line_height; ! int pswinw = 4*offset + 2*boxw + 10; ! int pswinh = 16*line_height + buttonh + 5*offset; ! int x = global->getMainWindow()->x() + ! global->getMainWindow()->w()/2 - pswinw/2; ! int y = global->getMainWindow()->y() + ! global->getMainWindow()->h()/2 - pswinh/2; ! window = new Fl_Window(x,y,pswinw,pswinh,"Select Parameters to Plot"); // origin is upper-left corner ! avbox = new Fl_Box( FL_ENGRAVED_FRAME, ! offset, ! offset, ! boxw, ! 16*line_height+2*offset, ! "Available Parameters"); ! avbox->align(FL_ALIGN_TOP|FL_ALIGN_INSIDE|FL_ALIGN_LEFT); ! ! available = new Fl_Select_Browser( avbox->x()+offset, ! avbox->y()+line_height, ! avbox->w()-2*offset, ! avbox->h()-line_height-offset, ! ""); ! available->callback( static_available_callback,this ); ! ! indbox = new Fl_Box( FL_ENGRAVED_FRAME, ! avbox->x()+avbox->w()+20, ! avbox->y(), ! avbox->w(), ! 2*line_height+2*offset, ! "Selected Independent"); ! indbox->align(FL_ALIGN_TOP|FL_ALIGN_INSIDE|FL_ALIGN_LEFT); ! ! independent = new Fl_Select_Browser( indbox->x()+offset, ! indbox->y()+line_height, ! indbox->w()-2*offset, ! line_height, ! ""); ! independent->callback( static_independent_callback, this ); ! ! depbox = new Fl_Box( FL_ENGRAVED_FRAME, ! indbox->x(), ! indbox->y() + indbox->h() + 3*offset, ! indbox->w(), ! 13*line_height+offset, ! "Selected Dependents"); ! depbox->align(FL_ALIGN_TOP|FL_ALIGN_INSIDE|FL_ALIGN_LEFT); ! ! ! dependent = new Fl_Select_Browser( depbox->x()+offset, ! depbox->y()+line_height, ! depbox->w()-2*offset, ! 12*line_height, ! "" ); ! dependent->callback( static_dependent_callback, this ); ! cancel_button = new Fl_Button(pswinw - buttonw - offset, pswinh - buttonh - offset, buttonw,buttonh, "&Cancel" ); ! cancel_button->callback(static_cancel_callback,this); ! ! ok_button = new Fl_Return_Button( pswinw - 2*buttonw - 2*offset, ! pswinh - buttonh - offset, ! buttonw,buttonh, ! "OK"); ok_button->callback(static_ok_callback,this); ! window->end(); ! Nitems=data->getNumParameters(); for(int i=0;i<Nitems;i++) { ! available->add( data->getName(i).c_str() ); } ! window->show(); ! while(run) { ! Fl::wait(); ! } window->hide(); return true; ! } ! void ParameterSelect::cancel_callback(Fl_Widget* flw) { cout << "In Cancel callback" << endl; run=false; ! ind_name = ""; ! dep_names.clear(); ! } void ParameterSelect::ok_callback(Fl_Widget* flw) { cout << "In OK callback" << endl; ! ! if ( independent->size() ) { ! ind_name = independent->text( 1 ); ! cout << ind_name << ", " << dependent->size() << endl; ! for(int i=1;i<=dependent->size();i++) { ! if(dependent->text(i) ) { ! dep_names.push_back( dependent->text(i) ); ! selected=true; ! } ! } } run=false; + } ! void ParameterSelect::available_callback(Fl_Widget* flw) { ! if ( available->value() ) { ! if( !ind_selected ) { ! independent->add( available->text(available->value()) ); ! ind_selected=true; ! } else { ! dependent->add( available->text(available->value()) ); ! } ! } ! } ! ! ! void ParameterSelect::independent_callback(Fl_Widget* flw) { ! if ( independent->value() ) { ! independent->remove( independent->value() ); ! ind_selected=false; ! } ! } ! ! void ParameterSelect::dependent_callback(Fl_Widget* flw) { ! if ( dependent->value() ) { ! dependent->remove( dependent->value() ); ! } ! } Index: ParameterSelect.h =================================================================== RCS file: /cvsroot/thplot/thplot/src/Gui/ParameterSelect.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -r1.1.1.1 -r1.2 *** ParameterSelect.h 22 Jun 2002 11:57:08 -0000 1.1.1.1 --- ParameterSelect.h 2 Jul 2002 17:21:44 -0000 1.2 *************** *** 31,35 **** #include <FL/Fl_Window.H> ! #include <FL/Fl_Multi_Browser.H> #include <FL/Fl_Button.h> #include <FL/Fl_Return_Button.h> --- 31,36 ---- #include <FL/Fl_Window.H> ! #include <FL/Fl_Box.H> ! #include <FL/Fl_Select_Browser.H> #include <FL/Fl_Button.h> #include <FL/Fl_Return_Button.h> *************** *** 45,50 **** ~ParameterSelect(void); ! // typedef vector<string> ParamList; ! // ParamList& getParameters(void); static void static_ok_callback(Fl_Widget *flw, void *d) { ((ParameterSelect*)d)->ok_callback(flw); --- 46,69 ---- ~ParameterSelect(void); ! ! string getSelectedIndependent(void) { return ind_name; } ! ParamList getSelectedDependents(void) { return dep_names; } ! bool selectionAvailable(void) { return selected; } ! ! static void static_available_callback(Fl_Widget *flw, void *d) { ! ((ParameterSelect*)d)->available_callback(flw); ! } ! void available_callback(Fl_Widget* flw); ! ! static void static_independent_callback(Fl_Widget *flw, void *d) { ! ((ParameterSelect*)d)->independent_callback(flw); ! } ! void independent_callback(Fl_Widget* flw); ! ! static void static_dependent_callback(Fl_Widget *flw, void *d) { ! ((ParameterSelect*)d)->dependent_callback(flw); ! } ! void dependent_callback(Fl_Widget* flw); ! static void static_ok_callback(Fl_Widget *flw, void *d) { ((ParameterSelect*)d)->ok_callback(flw); *************** *** 58,72 **** bool showDialog(csvData *data); - int getNSelected(void) { return Nselected; } - string getSelected(int idx); - private: bool run; ! int Nitems,Nselected; ! vector<int> selected; Globals *global; Fl_Window *window; ! Fl_Multi_Browser* flmb; Fl_Button* cancel_button; Fl_Return_Button* ok_button; --- 77,93 ---- bool showDialog(csvData *data); private: bool run; ! bool ind_selected; ! bool selected; ! int Nitems; ! string ind_name; ! ParamList dep_names; Globals *global; Fl_Window *window; ! Fl_Box *avbox, *indbox, *depbox; ! Fl_Select_Browser *available, *independent, *dependent; ! Fl_Button* cancel_button; Fl_Return_Button* ok_button; |