/** ****************************************************************** * * Module Name : SVPEdit * * Author/Date : C.B. Lirakis / 10-Jul-05 * * Description : Display a single SVP for graphical editing. * * Restrictions/Limitations : * * Change Descriptions : * * Classification : Unclassified * * References : * * * RCS header info. * ---------------- * $RCSfile: SVPDialog.hh,v $ * $Author: clirakis $ * $Date: 15 Jul 2005 09:33:04 $ * $Locker: $ * $Name: $ * $Revision: 1.9 $ * * $Log: /usr/local/iss60/library/iss60/RTDLib/SVPEdit.hhv $ Rev 1.9 15 Jul 2005 09:33:04 clirakis Added in toolbar and broke up construction of the various pieces into individual functions for ease of reading. Rev 1.8 14 Jul 2005 13:51:56 clirakis Getting ready to install toolbar. Rev 1.7 13 Jul 2005 15:58:54 clirakis SAVE button now works. Rev 1.6 13 Jul 2005 15:25:06 clirakis There was a problem of displaying the profile 'list' due to a signal crossover between SVPEdit and SVPDialog. So the SVPDialog canvas got painted over the SVPEdit canvas. Checking the edit status prevents this. This header now has that status check inline function. Rev 1.5 13 Jul 2005 14:26:10 clirakis Fixed some of the problems associated with the changing of colors in the edit dialog. Enabled reset button. Cancel works. Rev 1.4 13 Jul 2005 07:13:40 clirakis Modified to display current with black line and switch back to original color when new SVP is selected as current. Rev 1.3 12 Jul 2005 18:39:46 clirakis Enabled the edit functions, also display point values in status bar when close or moving. Rev 1.2 12 Jul 2005 15:55:00 clirakis Made SVPGraph class with all the proper mechanisms for signaling points selected and line selected. Rev 1.0 10 Jul 2005 09:58:44 clirakis Initial revision. * * * ******************************************************************* */ #ifndef __SVPEDIT_h_ #define __SVPEDIT_h_ /* ROOT includes. */ # include # include # include # include # include # include # include # include # include # include // Pretty obvious what this one is for, huh? # include # include /* * Make a superclass to TGraph so we have access to the * virtual functions. */ class SVPGraph : public TGraph { ClassDef(SVPGraph, 0); // Exports the name of this class to root. RQ_OBJECT("SVPGraph"); // Allow this class to have signals. public: /// Constructor to extend TGraph functionality. SVPGraph(Int_t n, const Double_t* x, const Double_t* y); /// Overload the TGraph functions so we can gain access /// to the points. virtual Int_t DistancetoPrimitive(Int_t px, Int_t py); /// Trap mouse clicks. virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py); /// Calculate which point in array we are dealing with Int_t PointFromXY(Int_t px, Int_t py); /// Get data about current point Int_t GetSelectedPoint() const {return Ipoint;}; /// void IsSelected(SVPGraph *); //*SIGNAL* inline Coord_t GetWorldX() const { return X;}; inline Coord_t GetWorldY() const { return Y;}; inline Bool_t HasBeenEdited() const { return HasBeenEditedAndNotSaved;}; inline void SetEditFlag(Bool_t flag = kTRUE) {HasBeenEditedAndNotSaved = flag;}; void UnZoom(); private: TPoint screen; Coord_t X,Y; Int_t Ipoint; Bool_t HasBeenEditedAndNotSaved; }; /** * Class to track the individual SVP files as loaded. * Build off the root TObject so we can incorporate these * into lists. */ class TSVP : public TObject { ClassDef(TSVP, 0); // Use for interactive root object public: /// Constructor, provide the path and filename. TSVP(const char *path, const char *filename); /// Destructor, clean up after ourselves. ~TSVP(); /// Get the error associated with the last command. inline Int_t GetLastError() const {return LastError;}; /** * A draw command, kind of a pass through. * The user can specify the line color. * By default it is 0 - no change from creation. */ void Draw(Option_t* chopt, Color_t ColorToUse=0); /** * Access the TGraph directly. Use with care! */ inline SVPGraph *GetTG() {return tg;}; /** * Get the filename associated with this set of points. */ inline TString *GetFileName() const {return Filename;}; /** * All the caller to loop over all instances to * see if this file is in the list already. */ inline bool NameMatches(const TString filetomatch) {return (*Filename == filetomatch);}; /** * Return true if provided */ /// Save the SVP for the class. int SaveSVP(const char *path, const char *filename, bool MoveAndRename); /// Allow set edit void SetEditable(Bool_t editable = kTRUE) {tg->SetEditable(editable);}; void SetCurrent(Bool_t flag = kTRUE); /** * Move the points from the TGraph or editor over * to the GSFProfile. */ int FillGSFProfile(); /** * Move the points from the GSFProfile or editor over * to the TGraph. */ int FillGraph(); /* */ void SVPEditComplete(Bool_t Reset); inline void SetEdit(Bool_t InProgress=kFALSE) {EditInProgress = InProgress;}; inline Bool_t IsBeingEdited() const {return EditInProgress;}; inline void SetLineColor(Color_t c) {MyColor = c;}; private: // Private helper methods. /* * Private data */ bool IsSonde; SVPGraph *tg; TString *Filename; TString *Path; TString *Header; Int_t LastError; bool sample; bool been_sampled; int format; // Format of file we read in. /** * GSF profile, store as void to avoid compilier difficulties. * This is the original read in points. At the moment * that we do a save new profile this is overwritten with any edits. */ void *GSFprofile; /* Display units.*/ int units; /* * Want the current line to be Black, * but when we select a new line, change it * back to the old color. */ Color_t MyColor; Bool_t IsCurrent; Bool_t EditInProgress; }; /* * This class is built on TGCompositeFrame * and will create the canvas to draw upon as well as the * frame. This will allow us to trap the events in the * Canvas */ class SVPDrawingArea : public TGCompositeFrame { ClassDef(SVPDrawingArea, 0); public: SVPDrawingArea(const TGWindow* p = 0, UInt_t w = 1, UInt_t h = 1); ~SVPDrawingArea(); void Update(); void PrintCanvas(); void CanvasSaveAs(char *filename); virtual Bool_t HandleButton(Event_t*); virtual Bool_t HandleMotion(Event_t*); private: /* * This will be the surface we draw on. */ TRootEmbeddedCanvas *fEmbeddedCanvas; TGLayoutHints *fL1; }; /** * Class to handle a Sound Velocity Profile Editing. * No Multiples here! */ class SVPEdit : public TGTransientFrame { ClassDef(SVPEdit, 0); private: TGMenuBar *fMenuBar; TGPopupMenu *fMenuFile, *fMenuHelp; TGCompositeFrame *fFrame1; SVPDrawingArea *fGraphicsFrame; TGButton *fOkButton, *fCloseButton, *fUnZoom, *fReset; TGLayoutHints *fL1, *fL2, *fL3, *fL4, *fMenuBarLayout, *fMenuBarItemLayout, *fMenuBarHelpLayout; /* * Use the status bar to show the name of the * selected SVP, and the point value that the mouse * is over. */ TGStatusBar *fStatusBar; /* * Make a toolbar for editing data */ TGToolBar *fToolBar; TList *fCleanup; /* * This is a pointer to the current SVP selected by the user. */ TSVP *SelectedSVP; // Private functions void ViewPoints(); void CreateMenuBar(); void CreateToolBar(); void CreateButtons(); void CreateStatusBar(); void AddEmbeddedCanvas(); void DoSaveAs(); public: /** * Main constructor with default values. */ SVPEdit(const TGWindow *p, UInt_t w = 1200, UInt_t h = 400, TSVP *tsvp=NULL); /** * Destructor, clean up after ourselves. */ virtual ~SVPEdit(); // slots - Methods by which we handle callbacks. void CloseWindow(); void DoSave(); void DoClose(); void HandleMenu(Int_t id); void HandleToolBar(Int_t id); /** * Calculate the distance from the current mouse * pointer to the nearest object and set the status bar * accordingly. */ Int_t DistancetoPrimitive(Int_t d, Int_t); void ResetPoints(); void UnZoom(); }; #endif