// inputwin.hpp -- window for importing and calibrating map fragments // // Written by Frederic Bouvier, started October 2001. // // Copyright (C) 2001 Frederic Bouvier - fredb@users.sourceforge.net // // 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., 675 Mass Ave, Cambridge, MA 02139, USA. // // $Id: inputwin.hpp,v 1.15 2005/05/09 07:01:52 fredb Exp $ #ifndef _inputwin_hpp_ #define _inputwin_hpp_ #include #include #include "window.hpp" #include #include #include #include #include #include #include #include #include #include #include "inputglwin.hpp" // #include "mapfragment.hpp" class FGSD_MapFragment; class Flu_Progress; class FGSD_InputWindow { public: FGSD_InputWindow( int w, int h ); ~FGSD_InputWindow(); void show( /* int argc, char **argv */ ); bool exec(); bool visible(); void loadImage(); void layout_(); void mouseMove( int x, int y, int e, int s ); void mouseClick( int x, int y, int b ); void drawGL(); double zLevel() const; double posx() const; double posy() const; void centerPosition( double x, double y ); FGSD_MapFragment *fragment() const; void clearFragment( bool __clear = false ); bool checkModified(); void setTitle(); void setButtonImage( Fl_Widget *w, int n, bool grayed ); void setCursor( Fl_Cursor __cursor ); void gotoPosition( int px, int py, int x, int y ); bool computeFetchParameters( int &xstart, int &ystart, int &xrange, int &yrange, int &zone, int &scale, double &size ); void openFetchDialog( double lon, double lat ); static void close_cb(Fl_Widget *, void *); static void new_cb(Fl_Widget *, void *); static void openFragment_cb(Fl_Widget *, void *); static void openImage_cb(Fl_Widget *, void *); static void fetchTerraserverUsa_cb(Fl_Widget *, void *); static void save_cb(Fl_Widget *, void *); static void saveAs_cb(Fl_Widget *, void *); static void removePoint_cb(Fl_Widget *, void *); private: void new_cb(); void openFragment_cb(); void openImage_cb(); void fetchTerraserverUsa_cb(); bool saveFragment( bool __saveAs ); void close_cb(); void removePoint_cb(); static void hscroll_cb(Fl_Widget *o, void *v); void hscroll_cb(); static void vscroll_cb(Fl_Widget *o, void *v); void vscroll_cb(); static void zoom_cb(Fl_Widget *o, void *v); void zoom_cb(); static void rot_plus_cb(Fl_Widget *o, void *v); static void rot_minus_cb(Fl_Widget *o, void *v); void rotation_cb( bool plus ); static void system_cb(Fl_Widget *o, void *v); void system_cb( Fl_Widget *o ); static void markok_cb(Fl_Widget *o, void *v); static void markcan_cb(Fl_Widget *o, void *v); void mark_cb( bool ok ); static void xradiusChange_cb(Fl_Widget *o, void *v); static void yradiusChange_cb(Fl_Widget *o, void *v); static void checkFetch_cb(Fl_Widget *o, void *v); static void fetchok_cb(Fl_Widget *o, void *v); static void fetchcan_cb(Fl_Widget *o, void *v); void fetch_cb( bool ok ); void xradiusChange_cb(); void yradiusChange_cb(); static void differed_fetch( void* v ); static void cancelFetch_cb(Fl_Widget *o, void *v); void cancelFetch_cb(); void checkValid(); void computeFetchParameters( const Fl_Menu_Item *l, double utm_x, double utm_y, int xradius, int yradius, int &xstart, int &ystart, int &xrange, int &yrange, int &scale, double &size ); static size_t writeFetchData( void *buffer, size_t size, size_t nmemb, void *userp ); private: FGSD_Window *_window; Fl_Scrollbar *_vscroll; Fl_Scrollbar *_hscroll; Fl_Value_Slider *_zoom; Fl_Button *_nbutton; Fl_Button *_ofbutton; Fl_Button *_oibutton; Fl_Button *_vbutton; Fl_Button *_marker; Fl_Button *_curve; Fl_Button *_rotplus; Fl_Button *_rotminus; Fl_Output *_xentry; Fl_Output *_yentry; Flu_Progress *_progress; Fl_Button *_fcancel; Fl_Menu_Bar *_menubar; Fl_Group *_tools; FGSD_InputGLWindow *_input; Fl_Menu_Button *_popup; FGSD_Window *_markWindow; Fl_Choice *_syst; Fl_Choice *_zone; Fl_Check_Button *_hemi; Fl_Input *_lon; Fl_Input *_lat; Fl_Input *_hgt; Fl_Choice *_datum; Fl_Button *_markOk; Fl_Button *_markCancel; FGSD_Window *_fetchWindow; Fl_Input *_flon; Fl_Input *_flat; Fl_Int_Input *_xradius; Fl_Int_Input *_yradius; Fl_Choice *_resolution; Fl_Choice *_type; Fl_Output *_xsize; Fl_Output *_ysize; Fl_Output *_weight; Fl_Button *_fetchOk; Fl_Button *_fetchCancel; bool _yradiusChanged; bool _fetchDialogRequested; double _lonRequested; double _latRequested; bool _fetchCancelled; FGSD_MapFragment *_fragment; std::string _fragmentFileName; double _posx; double _posy; double _visw; double _vish; double _zLevel; bool _modified; bool _modifiedImage; std::string _windowTitle; bool _dragging; Fl_Cursor _currentCursor; bool _dragMove; int _dragMoveX; int _dragMoveY; void * _currentContourPos; bool _dragContour; enum { New_i, OpenF_i, OpenI_i, Save_i, Marker_i, Contour_i, RotPlus_i, RotMoins_i, NbImages }; static Fl_Image *_images[ NbImages ][ 2 ]; std::stringstream fetchStream; long file_size; }; inline bool FGSD_InputWindow::visible() { bool ret = false; if ( _window ) ret = ( _window->visible() != 0 ); return ret; } inline bool FGSD_InputWindow::exec() { bool ret = false; if ( _window ) ret = ( _window->exec() != 0 ); return ret; } inline double FGSD_InputWindow::zLevel() const { return _zLevel; } inline double FGSD_InputWindow::posx() const { return _posx; } inline double FGSD_InputWindow::posy() const { return _posy; } inline FGSD_MapFragment *FGSD_InputWindow::fragment() const { return _fragment; } inline void FGSD_InputWindow::setButtonImage( Fl_Widget *w, int n, bool grayed ) { if ( n < NbImages ) w->image( _images[ n ][ grayed ? 1 : 0 ] ); } #endif