[Insight-users] Problems building the example from "Introduction to FLTK" by Luis Ibanez

Lino Ramirez Lino Ramirez" <ramirez at ece . ualberta . ca
Fri, 7 Nov 2003 10:01:06 -0700


Hi Luis,

It worked!

Thank you so much!

Lino

----- Original Message ----- 
From: "Luis Ibanez" <luis . ibanez at kitware . com>
To: "Lino Ramirez" <ramirez at ece . ualberta . ca>
Cc: <Insight-users at public . kitware . com>
Sent: Thursday, November 06, 2003 8:26 PM
Subject: Re: [Insight-users] Problems building the example from
"Introduction to FLTK" by Luis Ibanez


> Hi Lino,
>
> Thanks for sending your files.
>
> Here are the problems with your code:
>
> 1) You were passing
>
>         o->value
>
>     instead of
>
>         0->value()
>
>     "value" is a FLTK method for the
>     valuators Widgets. When you return
>     the name of a function without "()"
>     you are passing the pointer to the
>     function instead of its return value.
>
>
> 2) In the window widget in the fluid
>     file, you were defining the window
>     to be of class "CalculatorGUI".
>     That's incorrect, you don't need to
>     change the type of the widget.
>
>
> 3) The signatures of the BaseCalculator
>     types were 'float', while the return
>     types of FLTK valuator is 'double'.
>
>
>
> Please find attached the files that are
> working fine.
>
> Regards,
>
>
>     Luis
>
>
> --------------------
> Lino Ramirez wrote:
> > Hi Luis,
> >
> > Here are all the files I am using.
> >
> > Thank you for your help
> >
> > Lino
> >
> > ----- Original Message ----- 
> > From: "Luis Ibanez" <luis . ibanez at kitware . com>
> > To: "Lino Ramirez" <ramirez at ece . ualberta . ca>
> > Cc: <insight-users at itk . org>
> > Sent: Thursday, November 06, 2003 2:10 PM
> > Subject: Re: [Insight-users] Problems building the example from
> > "Introduction to FLTK" by Luis Ibanez
> >
> >
> >
> >>Hi Lino,
> >>
> >>This is basic C++,
> >>
> >>You have a mismatch between the types used in the
> >>definition of the SetOperandA() method and its
> >>invocation.
> >>
> >> >: 'SetOperandA' : cannot convert parameter 1
> >> >   from 'int (double)' to 'float'
> >>
> >>The definition of the types in your base class
> >>do not match the ones in CalculatorGUI.
> >>
> >>---
> >>
> >>The other errors are due to missing include FLTK
> >>headers.
> >>
> >>--
> >>
> >>Please send me the full set of files that
> >>you are putting together for this basic demo.
> >>It will be faster than solving error by error
> >>in the users list.
> >>
> >>
> >>Thanks
> >>
> >>
> >>   Luis
> >>
> >>
> >>------------------------
> >>Lino Ramirez wrote:
> >>
> >>>Hi Luis,
> >>>
> >>>
> >>>
> >>>Thank you again. However, I still don't get it to work :-(
> >>>
> >>>Now, I am getting 23 errors (see below). I am including the
> >>
> > CMakeLists.txt
> >
> >>>and the CalculatorGUI.fld. Please, keep helping me to make it work.
> >>>
> >>>
> >>>
> >>>Thank you so much for your help.
> >>>
> >>>
> >>>
> >>>Lino
> >>>
> >>>
> >>>
> >>>--------------------Configuration: TestCalculator - Win32
> >>>Debug--------------------
> >>>Compiling...
> >>>CalculatorGUI.cxx
> >>>C:\Lino\PhD\2003\SummerWork\fltk\testCalculator\CalculatorGUI.cxx(6) :
> >>
> > error
> >
> >>>C2664: 'SetOperandA' : cannot convert parameter 1 from 'int (double)'
to
> >>>'float'
> >>>        Context does not allow for disambiguation of overloaded
function
> >>>C:\Lino\PhD\2003\SummerWork\fltk\testCalculator\CalculatorGUI.cxx(9) :
> >>
> > error
> >
> >>>C2027: use of undefined type 'Fl_Group'
> >>>        C:\FLTK\FL/Fl_Widget.H(33) : see declaration of 'Fl_Group'
> >>>C:\Lino\PhD\2003\SummerWork\fltk\testCalculator\CalculatorGUI.cxx(9) :
> >>
> > error
> >
> >>>C2227: left of '->user_data' must point to class/struct/union
> >>>C:\Lino\PhD\2003\SummerWork\fltk\testCalculator\CalculatorGUI.cxx(9) :
> >>
> > error
> >
> >>>C2227: left of '->cb_OperandAInputValue_i' must point to
> >>
> > class/struct/union
> >
> >>>C:\Lino\PhD\2003\SummerWork\fltk\testCalculator\CalculatorGUI.cxx(13) :
> >>>error C2664: 'SetOperandB' : cannot convert parameter 1 from 'int
> >>
> > (double)'
> >
> >>>to 'float'
> >>>        Context does not allow for disambiguation of overloaded
function
> >>>C:\Lino\PhD\2003\SummerWork\fltk\testCalculator\CalculatorGUI.cxx(16) :
> >>>error C2027: use of undefined type 'Fl_Group'
> >>>        C:\FLTK\FL/Fl_Widget.H(33) : see declaration of 'Fl_Group'
> >>>C:\Lino\PhD\2003\SummerWork\fltk\testCalculator\CalculatorGUI.cxx(16) :
> >>>error C2227: left of '->user_data' must point to class/struct/union
> >>>C:\Lino\PhD\2003\SummerWork\fltk\testCalculator\CalculatorGUI.cxx(16) :
> >>>error C2227: left of '->cb_OperandBInputValue_i' must point to
> >>>class/struct/union
> >>>C:\Lino\PhD\2003\SummerWork\fltk\testCalculator\CalculatorGUI.cxx(23) :
> >>>error C2027: use of undefined type 'Fl_Group'
> >>>        C:\FLTK\FL/Fl_Widget.H(33) : see declaration of 'Fl_Group'
> >>>C:\Lino\PhD\2003\SummerWork\fltk\testCalculator\CalculatorGUI.cxx(23) :
> >>>error C2227: left of '->user_data' must point to class/struct/union
> >>>C:\Lino\PhD\2003\SummerWork\fltk\testCalculator\CalculatorGUI.cxx(23) :
> >>>error C2227: left of '->cb__i' must point to class/struct/union
> >>>C:\Lino\PhD\2003\SummerWork\fltk\testCalculator\CalculatorGUI.cxx(28) :
> >>>error C2661: 'CalculatorGUI::CalculatorGUI' : no overloaded function
> >>
> > takes 4
> >
> >>>parameters
> >>>C:\Lino\PhD\2003\SummerWork\fltk\testCalculator\CalculatorGUI.cxx(30) :
> >>>error C2039: 'box' : is not a member of 'CalculatorGUI'
> >>>
> >>
> > C:\Lino\PhD\2003\SummerWork\fltk\testCalculator\CalculatorGUI.h(11)
> >
> >>>: see declaration of 'CalculatorGUI'
> >>>C:\Lino\PhD\2003\SummerWork\fltk\testCalculator\CalculatorGUI.cxx(31) :
> >>>error C2039: 'color' : is not a member of 'CalculatorGUI'
> >>>
> >>
> > C:\Lino\PhD\2003\SummerWork\fltk\testCalculator\CalculatorGUI.h(11)
> >
> >>>: see declaration of 'CalculatorGUI'
> >>>C:\Lino\PhD\2003\SummerWork\fltk\testCalculator\CalculatorGUI.cxx(32) :
> >>>error C2039: 'selection_color' : is not a member of 'CalculatorGUI'
> >>>
> >>
> > C:\Lino\PhD\2003\SummerWork\fltk\testCalculator\CalculatorGUI.h(11)
> >
> >>>: see declaration of 'CalculatorGUI'
> >>>C:\Lino\PhD\2003\SummerWork\fltk\testCalculator\CalculatorGUI.cxx(33) :
> >>>error C2039: 'labeltype' : is not a member of 'CalculatorGUI'
> >>>
> >>
> > C:\Lino\PhD\2003\SummerWork\fltk\testCalculator\CalculatorGUI.h(11)
> >
> >>>: see declaration of 'CalculatorGUI'
> >>>C:\Lino\PhD\2003\SummerWork\fltk\testCalculator\CalculatorGUI.cxx(34) :
> >>>error C2039: 'labelfont' : is not a member of 'CalculatorGUI'
> >>>
> >>
> > C:\Lino\PhD\2003\SummerWork\fltk\testCalculator\CalculatorGUI.h(11)
> >
> >>>: see declaration of 'CalculatorGUI'
> >>>C:\Lino\PhD\2003\SummerWork\fltk\testCalculator\CalculatorGUI.cxx(35) :
> >>>error C2039: 'labelsize' : is not a member of 'CalculatorGUI'
> >>>
> >>
> > C:\Lino\PhD\2003\SummerWork\fltk\testCalculator\CalculatorGUI.h(11)
> >
> >>>: see declaration of 'CalculatorGUI'
> >>>C:\Lino\PhD\2003\SummerWork\fltk\testCalculator\CalculatorGUI.cxx(36) :
> >>>error C2039: 'labelcolor' : is not a member of 'CalculatorGUI'
> >>>
> >>
> > C:\Lino\PhD\2003\SummerWork\fltk\testCalculator\CalculatorGUI.h(11)
> >
> >>>: see declaration of 'CalculatorGUI'
> >>>C:\Lino\PhD\2003\SummerWork\fltk\testCalculator\CalculatorGUI.cxx(37) :
> >>>error C2039: 'user_data' : is not a member of 'CalculatorGUI'
> >>>
> >>
> > C:\Lino\PhD\2003\SummerWork\fltk\testCalculator\CalculatorGUI.h(11)
> >
> >>>: see declaration of 'CalculatorGUI'
> >>>C:\Lino\PhD\2003\SummerWork\fltk\testCalculator\CalculatorGUI.cxx(38) :
> >>>error C2039: 'align' : is not a member of 'CalculatorGUI'
> >>>
> >>
> > C:\Lino\PhD\2003\SummerWork\fltk\testCalculator\CalculatorGUI.h(11)
> >
> >>>: see declaration of 'CalculatorGUI'
> >>>C:\Lino\PhD\2003\SummerWork\fltk\testCalculator\CalculatorGUI.cxx(39) :
> >>>error C2039: 'when' : is not a member of 'CalculatorGUI'
> >>>
> >>
> > C:\Lino\PhD\2003\SummerWork\fltk\testCalculator\CalculatorGUI.h(11)
> >
> >>>: see declaration of 'CalculatorGUI'
> >>>C:\Lino\PhD\2003\SummerWork\fltk\testCalculator\CalculatorGUI.cxx(50) :
> >>>error C2039: 'end' : is not a member of 'CalculatorGUI'
> >>>
> >>
> > C:\Lino\PhD\2003\SummerWork\fltk\testCalculator\CalculatorGUI.h(11)
> >
> >>>: see declaration of 'CalculatorGUI'
> >>>main.cxx
> >>>Generating Code...
> >>>Error executing cl.exe.
> >>>
> >>>ALL_BUILD - 23 error(s), 0 warning(s)
> >>>
> >>>
> >>>
> >>
>
>>--------------------------------------------------------------------------
> >
> > --
> >
> >>>-----
> >>>
> >>>CMakeLists.txt
> >>>
> >>>
> >>>
> >>>PROJECT( TestCalculator )
> >>>
> >>>INCLUDE (${CMAKE_ROOT}/Modules/FindFLTK.cmake)
> >>>
> >>>INCLUDE_DIRECTORIES(
> >>>  ${FLTK_INCLUDE_PATH}
> >>>
> >>>)
> >>>
> >>>SET( TestCalculator_SRCS
> >>>  CalculatorGUI.cxx
> >>>  main.cxx
> >>>
> >>>)
> >>>
> >>>
> >>>ADD_EXECUTABLE( TestCalculator TestCalculator_SRCS )
> >>>
> >>>
> >>>TARGET_LINK_LIBRARIES( TestCalculator ${FLTK_LIBRARIES})
> >>>
> >>>
> >>
>
>>--------------------------------------------------------------------------
> >
> > --
> >
> >>>---
> >>>
> >>>CalculatorGUI.fld
> >>>
> >>># data file for the Fltk User Interface Designer (fluid)
> >>>
> >>>version 1.0104
> >>>
> >>>header_name {.h}
> >>>
> >>>code_name {.cxx}
> >>>
> >>>class CalculatorGUI {open : {public BaseCalculator}
> >>>
> >>>} {
> >>>
> >>>Function {CalculatorGUI()} {open
> >>>
> >>>} {
> >>>
> >>>Fl_Window CalculatorPanel {open
> >>>
> >>>xywh {509 160 282 221}
> >>>
> >>>code0 {\#include "BaseCalculator.h"}
> >>>
> >>>class CalculatorGUI visible
> >>>
> >>>} {
> >>>
> >>>Fl_Value_Input OperandAInputValue {
> >>>
> >>>label {A:}
> >>>
> >>>callback {SetOperandA( o->value );}
> >>>
> >>>xywh {25 25 25 25}
> >>>
> >>>}
> >>>
> >>>Fl_Value_Input OperandBInputValue {
> >>>
> >>>label {B:}
> >>>
> >>>callback {SetOperandB( o->value );}
> >>>
> >>>xywh {105 25 25 25}
> >>>
> >>>}
> >>>
> >>>Fl_Button {} {
> >>>
> >>>label {+}
> >>>
> >>>callback {Add();}
> >>>
> >>>xywh {60 25 25 25}
> >>>
> >>>}
> >>>
> >>>Fl_Value_Output ResultOutputValue {
> >>>
> >>>label {=} selected
> >>>
> >>>xywh {145 25 25 25}
> >>>
> >>>}
> >>>
> >>>}
> >>>
> >>>}
> >>>
> >>>Function {~CalculatorGUI()} {open return_type virtual
> >>>
> >>>} {}
> >>>
> >>>Function {show()} {open return_type virtual
> >>>
> >>>} {}
> >>>
> >>>Function {hide()} {open return_type virtual
> >>>
> >>>} {}
> >>>
> >>>}
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>----- Original Message ----- 
> >>>From: "Luis Ibanez" <luis . ibanez at kitware . com>
> >>>To: "Lino Ramirez" <ramirez at ece . ualberta . ca>
> >>>Cc: <insight-users at itk . org>
> >>>Sent: Thursday, November 06, 2003 1:10 PM
> >>>Subject: Re: [Insight-users] Problems building the example from
> >>>"Introduction to FLTK" by Luis Ibanez
> >>>
> >>>
> >>>
> >>>
> >>>>Hi Lino,
> >>>>
> >>>>The compilation errors that you get show
> >>>>that you are not including the header file
> >>>>CalculatorGUI.h from CalculatorGUI.cxx.
> >>>>
> >>>>That's why the compiler cannot find the
> >>>>definition of the CalculatorGUI class and
> >>>>complains with:
> >>>>
> >>>>
> >>>>
> >>>>>Compiling...
> >>>>>CalculatorGUI.cxx
> >>>>>C:\Lino\PhD\2003\SummerWork\fltk\testCalculator\CalculatorGUI.cxx(3)
> >>>>>: error
> >>>>>C2653: 'CalculatorGUI' : is not a class or namespace name
> >>>>
> >>>>
> >>>>When you created the FLUID file CalculatorGUI.fld
> >>>>you clicked in the option :
> >>>>
> >>>>    "Include header from Code"
> >>>>
> >>>>This is shown at the top of your fluid file
> >>>>
> >>>>
> >>>>>>># data file for the Fltk User Interface Designer (fluid)
> >>>>>>>
> >>>>>>>version 1.0104
> >>>>>>>
> >>>>>>>do_not_include_H_from_C    <<<==========={{{ HERE
> >>>>>>>
> >>>>>>>header_name {.h}
> >>>>>>>
> >>>>>>>code_name {.cxx}
> >>>>>>
> >>>>
> >>>>
> >>>>So, the solution is:
> >>>>
> >>>>
> >>>>       *Don't do that !*
> >>>>
> >>>>
> >>>>Open the .fld file again with FLUID,
> >>>>Go to the "Edit" menu, then select
> >>>>"Project setting" and make sure that
> >>>>you enable the button
> >>>>
> >>>>    "Include header from Code"
> >>>>
> >>>>
> >>>>Then, save the fluid file and regenerate
> >>>>the .cxx and .h files.
> >>>>
> >>>>Finally, reload the project in VisualStudio
> >>>>and rebuild it.
> >>>>
> >>>>
> >>>>Regards,
> >>>>
> >>>>
> >>>>
> >>>>  Luis
> >>>>
> >>>>
> >>>
> >>>
> >>>_______________________________________________
> >>>Insight-users mailing list
> >>>Insight-users at itk . org
> >>>http://www . itk . org/mailman/listinfo/insight-users
> >>>
> >>
> >>
> >>
> >>
> >>------------------------------------------------------------------------
> >>
> >>PROJECT( TestCalculator )
> >>
> >>INCLUDE (${CMAKE_ROOT}/Modules/FindFLTK.cmake)
> >>
> >>INCLUDE_DIRECTORIES(
> >>  ${FLTK_INCLUDE_PATH}
> >>
> >>)
> >>
> >>SET( TestCalculator_SRCS
> >>  CalculatorGUI.cxx
> >>  main.cxx
> >>
> >>)
> >>
> >>
> >>ADD_EXECUTABLE( TestCalculator TestCalculator_SRCS )
> >>
> >>
> >>TARGET_LINK_LIBRARIES( TestCalculator ${FLTK_LIBRARIES})
> >>
> >>
> >
>
>
>


----------------------------------------------------------------------------
----


> # data file for the Fltk User Interface Designer (fluid)
> version 1.0104
> header_name {.h}
> code_name {.cxx}
> class CalculatorGUI {open : {public BaseCalculator}
> } {
>   Function {CalculatorGUI()} {open
>   } {
>     Fl_Window CalculatorPanel {open selected
>       xywh {355 333 375 106} type Double
>       code0 {\#include "BaseCalculator.h"} visible
>     } {
>       Fl_Value_Input OperandAInputValue {
>         label {A:}
>         callback {SetOperandA( o->value() );}
>         xywh {51 40 70 25}
>       }
>       Fl_Value_Input OperandBInputValue {
>         label {B:}
>         callback {SetOperandB( o->value() );}
>         xywh {185 40 62 25}
>       }
>       Fl_Button {} {
>         label {+}
>         callback {Add();}
>         xywh {132 40 25 25}
>       }
>       Fl_Value_Output ResultOutputValue {
>         label {=}
>         xywh {263 40 70 25}
>       }
>     }
>   }
>   Function {~CalculatorGUI()} {open return_type virtual
>   } {}
>   Function {show()} {open return_type virtual
>   } {}
>   Function {hide()} {open return_type virtual
>   } {}
> }
>


----------------------------------------------------------------------------
----


> #ifndef BaseCalculator_h
> #define BaseCalculator_h
>
> class BaseCalculator
> {
> public:
> BaseCalculator() {}
> virtual ~BaseCalculator(){}
>
> virtual void SetOperandA( double val )
> {
> operandA = val;
> resultIsValid = false;
> }
>
> virtual void SetOperandB( double val )
> {
> operandB = val;
> resultIsValid = false;
> }
>
> double GetResult( void ) const
> {
> return result;
> }
>
> virtual void Add( void )
> {
> result = operandA + operandB;
> resultIsValid = true;
> }
>
> virtual void Sub( void )
> {
> result = operandA - operandB;
> resultIsValid = true;
> }
>
>
> bool GetValid( void )
> {
> return resultIsValid;
> }
>
> private:
> bool resultIsValid;
> double operandA;
> double operandB;
> double result;
> }; //end of class
>
> #endif
>
>


----------------------------------------------------------------------------
----


> // generated by Fast Light User Interface Designer (fluid) version 1.0104
>
> #include "CalculatorGUI.h"
>
> inline void CalculatorGUI::cb_OperandAInputValue_i(Fl_Value_Input* o,
void*) {
>   SetOperandA( o->value() );
> }
> void CalculatorGUI::cb_OperandAInputValue(Fl_Value_Input* o, void* v) {
>
((CalculatorGUI*)(o->parent()->user_data()))->cb_OperandAInputValue_i(o,v);
> }
>
> inline void CalculatorGUI::cb_OperandBInputValue_i(Fl_Value_Input* o,
void*) {
>   SetOperandB( o->value() );
> }
> void CalculatorGUI::cb_OperandBInputValue(Fl_Value_Input* o, void* v) {
>
((CalculatorGUI*)(o->parent()->user_data()))->cb_OperandBInputValue_i(o,v);
> }
>
> inline void CalculatorGUI::cb__i(Fl_Button*, void*) {
>   Add();
> }
> void CalculatorGUI::cb_(Fl_Button* o, void* v) {
>   ((CalculatorGUI*)(o->parent()->user_data()))->cb__i(o,v);
> }
>
> CalculatorGUI::CalculatorGUI() {
>   Fl_Double_Window* w;
>   { Fl_Double_Window* o = CalculatorPanel = new Fl_Double_Window(375,
106);
>     w = o;
>     o->user_data((void*)(this));
>     { Fl_Value_Input* o = OperandAInputValue = new Fl_Value_Input(51, 40,
70, 25, "A:");
>       o->callback((Fl_Callback*)cb_OperandAInputValue);
>     }
>     { Fl_Value_Input* o = OperandBInputValue = new Fl_Value_Input(185, 40,
62, 25, "B:");
>       o->callback((Fl_Callback*)cb_OperandBInputValue);
>     }
>     { Fl_Button* o = new Fl_Button(132, 40, 25, 25, "+");
>       o->callback((Fl_Callback*)cb_);
>     }
>     ResultOutputValue = new Fl_Value_Output(263, 40, 70, 25, "=");
>     o->end();
>   }
> }
>
> CalculatorGUI::~CalculatorGUI() {
> }
>
> void CalculatorGUI::show() {
> }
>
> void CalculatorGUI::hide() {
> }
>


----------------------------------------------------------------------------
----


> // generated by Fast Light User Interface Designer (fluid) version 1.0104
>
> #ifndef CalculatorGUI_h
> #define CalculatorGUI_h
> #include <FL/Fl.H>
> #include <FL/Fl_Double_Window.H>
> #include "BaseCalculator.h"
> #include <FL/Fl_Value_Input.H>
> #include <FL/Fl_Button.H>
> #include <FL/Fl_Value_Output.H>
>
> class CalculatorGUI : public BaseCalculator {
> public:
>   CalculatorGUI();
>   Fl_Double_Window *CalculatorPanel;
>   Fl_Value_Input *OperandAInputValue;
> private:
>   inline void cb_OperandAInputValue_i(Fl_Value_Input*, void*);
>   static void cb_OperandAInputValue(Fl_Value_Input*, void*);
> public:
>   Fl_Value_Input *OperandBInputValue;
> private:
>   inline void cb_OperandBInputValue_i(Fl_Value_Input*, void*);
>   static void cb_OperandBInputValue(Fl_Value_Input*, void*);
>   inline void cb__i(Fl_Button*, void*);
>   static void cb_(Fl_Button*, void*);
> public:
>   Fl_Value_Output *ResultOutputValue;
>   virtual ~CalculatorGUI();
>   virtual void show();
>   virtual void hide();
> };
> #endif
>