Skip to content
Browse files

Refactoring: more classes separated from 'navutil' to their own files…

… (cpp, h).
  • Loading branch information...
1 parent 2975281 commit e1602ad91492a5b3f160a5d5d8264dcdb00d9b8e @mariokonrad mariokonrad committed
View
1 .gitignore
@@ -3,3 +3,4 @@ tags
index.sh
include/version.h
build
+cscope.out
View
5 CMakeLists.txt
@@ -342,6 +342,7 @@ SET(HDRS
include/ocpCursor.h
include/Quilt.h
include/Hyperlink.h
+ include/NavObjectCollection.h
include/RoutePoint.h
include/Route.h
include/SelectItem.h
@@ -353,6 +354,7 @@ SET(HDRS
include/OCPN_Sound.h
include/TTYWindow.h
include/TTYScroll.h
+ include/Layer.h
include/concanv.h
include/cutil.h
include/georef.h
@@ -407,6 +409,8 @@ SET(SRCS
src/ChInfoWin.cpp
src/AISTargetQueryDialog.cpp
src/Quilt.cpp
+ src/Hyperlink.cpp
+ src/NavObjectCollection.cpp
src/RoutePoint.cpp
src/Route.cpp
src/SelectItem.cpp
@@ -417,6 +421,7 @@ SET(SRCS
src/OCPN_Sound.cpp
src/TTYWindow.cpp
src/TTYScroll.cpp
+ src/Layer.cpp
src/concanv.cpp
src/cutil.cpp
src/georef.cpp
View
59 include/Layer.h
@@ -0,0 +1,59 @@
+/******************************************************************************
+ *
+ * Project: OpenCPN
+ *
+ ***************************************************************************
+ * Copyright (C) 2010 by David S. Register *
+ * *
+ * 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., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************
+ */
+
+#ifndef __LAYER_H__
+#define __LAYER_H__
+
+#include <wx/string.h>
+#include <wx/list.h>
+#include <wx/datetime.h>
+
+class Layer
+{
+public:
+ Layer(void);
+ ~Layer(void);
+ wxString CreatePropString(void) { return m_LayerFileName; }
+ bool IsVisibleOnChart() { return m_bIsVisibleOnChart; }
+ void SetVisibleOnChart(bool viz = true){ m_bIsVisibleOnChart = viz; }
+ bool IsVisibleOnListing() { return m_bIsVisibleOnListing; }
+ void SetVisibleOnListing(bool viz = true){ m_bIsVisibleOnListing = viz; }
+ bool HasVisibleNames() { return m_bHasVisibleNames; }
+ void SetVisibleNames(bool viz = true){ m_bHasVisibleNames = viz; }
+
+ bool m_bIsVisibleOnChart;
+ bool m_bIsVisibleOnListing;
+ bool m_bHasVisibleNames;
+ long m_NoOfItems;
+ int m_LayerID;
+
+ wxString m_LayerName;
+ wxString m_LayerFileName;
+ wxString m_LayerDescription;
+ wxDateTime m_CreateTime;
+};
+
+WX_DECLARE_LIST(Layer, LayerList);// establish class as list member
+
+#endif
View
49 include/NavObjectCollection.h
@@ -0,0 +1,49 @@
+/******************************************************************************
+ *
+ * Project: OpenCPN
+ *
+ ***************************************************************************
+ * Copyright (C) 2010 by David S. Register *
+ * *
+ * 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., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************
+ */
+
+#ifndef __NAVOBJECTCOLLECTION_H__
+#define __NAVOBJECTCOLLECTION_H__
+
+#include "gpxdocument.h"
+
+class TiXmlNode;
+
+class NavObjectCollection : public GpxDocument
+{
+ public:
+ NavObjectCollection();
+ ~NavObjectCollection();
+
+ bool CreateNavObjGPXPoints(void);
+ bool CreateNavObjGPXRoutes(void);
+ bool CreateNavObjGPXTracks(void);
+
+ bool LoadAllGPXObjects(void);
+
+ private:
+ GpxRootElement *m_pXMLrootnode;
+ TiXmlNode *m_proot_next;
+};
+
+#endif
View
56 include/navutil.h
@@ -69,8 +69,6 @@ class NavObjectCollection;
class wxProgressDialog;
class ocpnDC;
-#define TIMER_TRACK1 778
-
//----------------------------------------------------------------------------
// Track
//----------------------------------------------------------------------------
@@ -133,38 +131,6 @@ DECLARE_EVENT_TABLE()
};
//----------------------------------------------------------------------------
-// Layer
-//----------------------------------------------------------------------------
-
-class Layer
-{
-public:
- Layer(void);
- ~Layer(void);
- wxString CreatePropString(void) { return m_LayerFileName; }
- bool IsVisibleOnChart() { return m_bIsVisibleOnChart; }
- void SetVisibleOnChart(bool viz = true){ m_bIsVisibleOnChart = viz; }
- bool IsVisibleOnListing() { return m_bIsVisibleOnListing; }
- void SetVisibleOnListing(bool viz = true){ m_bIsVisibleOnListing = viz; }
- bool HasVisibleNames() { return m_bHasVisibleNames; }
- void SetVisibleNames(bool viz = true){ m_bHasVisibleNames = viz; }
-
- bool m_bIsVisibleOnChart;
- bool m_bIsVisibleOnListing;
- bool m_bHasVisibleNames;
- long m_NoOfItems;
- int m_LayerID;
-
- wxString m_LayerName;
- wxString m_LayerFileName;
- wxString m_LayerDescription;
- wxDateTime m_CreateTime;
-
-};
-
-WX_DECLARE_LIST(Layer, LayerList);// establish class as list member
-
-//----------------------------------------------------------------------------
// Static XML Helpers
//----------------------------------------------------------------------------
@@ -248,28 +214,6 @@ class MyConfig:public wxFileConfig
};
-
-//---------------------------------------------------------------------------------
-// XML Based NavObjectSet
-//---------------------------------------------------------------------------------
-
-class NavObjectCollection : public GpxDocument
-{
- public:
- NavObjectCollection();
- ~NavObjectCollection();
-
- bool CreateNavObjGPXPoints(void);
- bool CreateNavObjGPXRoutes(void);
- bool CreateNavObjGPXTracks(void);
-
- bool LoadAllGPXObjects(void);
-
- private:
- GpxRootElement *m_pXMLrootnode;
- TiXmlNode *m_proot_next;
-};
-
/*
#include <wx/fontdlg.h>
View
29 src/Hyperlink.cpp
@@ -0,0 +1,29 @@
+/******************************************************************************
+ *
+ * Project: OpenCPN
+ *
+ ***************************************************************************
+ * Copyright (C) 2013 by David S. Register *
+ * *
+ * 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., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************
+ */
+
+#include "Hyperlink.h"
+
+#include <wx/listimpl.cpp>
+WX_DEFINE_LIST ( HyperlinkList ); // toh, 2009.02.22
+
View
53 src/Layer.cpp
@@ -0,0 +1,53 @@
+/******************************************************************************
+ *
+ * Project: OpenCPN
+ *
+ ***************************************************************************
+ * Copyright (C) 2010 by David S. Register *
+ * *
+ * 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., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************
+ */
+
+#include "Layer.h"
+
+#include <wx/listimpl.cpp>
+WX_DEFINE_LIST(LayerList);
+
+extern bool g_bShowLayers;
+extern LayerList *pLayerList;
+
+Layer::Layer( void )
+{
+ m_bIsVisibleOnChart = g_bShowLayers;
+ m_bIsVisibleOnListing = false;
+ m_bHasVisibleNames = true;
+ m_NoOfItems = 0;
+
+ m_LayerName = _T("");
+ m_LayerFileName = _T("");
+ m_LayerDescription = _T("");
+ m_CreateTime = wxDateTime::Now();
+}
+
+Layer::~Layer( void )
+{
+// Remove this layer from the global layer list
+ if( NULL != pLayerList ) pLayerList->DeleteObject( this );
+
+}
+
+
View
145 src/NavObjectCollection.cpp
@@ -0,0 +1,145 @@
+/******************************************************************************
+ *
+ * Project: OpenCPN
+ *
+ ***************************************************************************
+ * Copyright (C) 2010 by David S. Register *
+ * *
+ * 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., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************
+ */
+
+#include "NavObjectCollection.h"
+#include "RoutePoint.h"
+#include "routeman.h"
+#include "navutil.h"
+#include "Select.h"
+
+#include "tinyxml.h"
+
+extern WayPointman *pWayPointMan;
+extern RouteList *pRouteList;
+extern Select *pSelect;
+
+NavObjectCollection::NavObjectCollection()
+ : GpxDocument()
+{
+ m_pXMLrootnode = (GpxRootElement *) RootElement();
+}
+
+NavObjectCollection::~NavObjectCollection()
+{
+// delete m_pXMLrootnode; // done in base class
+}
+
+bool NavObjectCollection::CreateNavObjGPXPoints( void )
+{
+
+ // Iterate over the Routepoint list, creating Nodes for
+ // Routepoints that are not in any Route
+ // as indicated by m_bIsolatedMark == false
+
+ wxRoutePointListNode *node = pWayPointMan->m_pWayPointList->GetFirst();
+
+ RoutePoint *pr;
+
+ while( node ) {
+ pr = node->GetData();
+
+ if( ( pr->m_bIsolatedMark ) && !( pr->m_bIsInLayer ) ) //( !WptIsInRouteList ( pr ) )
+ {
+ m_pXMLrootnode->AddWaypoint( CreateGPXWpt( pr, GPX_WPT_WAYPOINT ) );
+ }
+ node = node->GetNext();
+ }
+
+ return true;
+}
+
+bool NavObjectCollection::CreateNavObjGPXRoutes( void )
+{
+ // Routes
+ wxRouteListNode *node1 = pRouteList->GetFirst();
+ while( node1 ) {
+ Route *pRoute = node1->GetData();
+
+ if( !pRoute->m_bIsTrack && !( pRoute->m_bIsInLayer ) ) // Not tracks
+ {
+ m_pXMLrootnode->AddRoute( CreateGPXRte( pRoute ) );
+ }
+ node1 = node1->GetNext();
+ }
+
+ return true;
+}
+
+bool NavObjectCollection::CreateNavObjGPXTracks( void )
+{
+ // Tracks
+ wxRouteListNode *node1 = pRouteList->GetFirst();
+ while( node1 ) {
+ Route *pRoute = node1->GetData();
+ RoutePointList *pRoutePointList = pRoute->pRoutePointList; //->GetCount(); do if
+
+ if( pRoutePointList->GetCount() ) {
+ if( pRoute->m_bIsTrack && !( pRoute->m_bIsInLayer ) ) // Tracks only
+ {
+ //Redundant - RoutePointList *pRoutePointList = pRoute->pRoutePointList;
+ m_pXMLrootnode->AddTrack( CreateGPXTrk( pRoute ) );
+ }
+ }
+ node1 = node1->GetNext();
+ }
+
+ return true;
+}
+
+bool NavObjectCollection::LoadAllGPXObjects()
+{
+ //FIXME: unite with MyConfig::ImportGPX
+ TiXmlNode *root = RootElement();
+
+ wxString RootName = wxString::FromUTF8( root->Value() );
+ if( RootName == _T ( "gpx" ) ) {
+ TiXmlNode *child;
+ for( child = root->FirstChild(); child != 0; child = child->NextSibling() ) {
+ wxString ChildName = wxString::FromUTF8( child->Value() );
+ if( ChildName == _T ( "trk" ) ) ::GPXLoadTrack( (GpxTrkElement *) child );
+ else
+ if( ChildName == _T ( "rte" ) ) {
+ int m_NextRouteNum = 0; //FIXME: we do not need it for GPX
+ ::GPXLoadRoute( (GpxRteElement *) child, m_NextRouteNum );
+ } else
+ if( ChildName == _T ( "wpt" ) ) {
+ int m_NextWPNum = 0; //FIXME: we do not need it for GPX
+ RoutePoint *pWp = ::LoadGPXWaypoint( (GpxWptElement *) child,
+ _T("circle") );
+ RoutePoint *pExisting = WaypointExists( pWp->GetName(), pWp->m_lat,
+ pWp->m_lon );
+ if( !pExisting ) {
+ if( NULL != pWayPointMan ) pWayPointMan->m_pWayPointList->Append( pWp );
+ pWp->m_bIsolatedMark = true; // This is an isolated mark
+ pSelect->AddSelectableRoutePoint( pWp->m_lat, pWp->m_lon, pWp );
+ pWp->m_ConfigWPNum = m_NextWPNum;
+ m_NextWPNum++;
+ }
+ }
+ }
+ }
+
+ return true;
+}
+
View
3 src/Route.cpp
@@ -42,6 +42,9 @@ extern Select *pSelect;
extern MyConfig *pConfig;
extern Multiplexer *g_pMUX;
+#include <wx/listimpl.cpp>
+WX_DEFINE_LIST ( RouteList );
+
Route::Route( void )
{
m_bRtIsSelected = false;
View
3 src/RoutePoint.cpp
@@ -44,6 +44,9 @@ extern Multiplexer *g_pMUX;
extern MyFrame *gFrame;
extern FontMgr *pFontMgr;
+#include <wx/listimpl.cpp>
+WX_DEFINE_LIST ( RoutePointList );
+
RoutePoint::RoutePoint()
{
m_pbmIcon = NULL;
View
3 src/SelectItem.cpp
@@ -24,6 +24,9 @@
#include "SelectItem.h"
+#include <wx/listimpl.cpp>
+WX_DEFINE_LIST ( SelectableItemList );
+
SelectItem::SelectItem()
{
}
View
2 src/chart1.cpp
@@ -87,6 +87,8 @@
#include "Select.h"
#include "FontMgr.h"
#include "TTYWindow.h"
+#include "Layer.h"
+#include "NavObjectCollection.h"
#include "cutil.h"
#include "routemanagerdialog.h"
View
151 src/navutil.cpp
@@ -72,6 +72,8 @@
#include "FontMgr.h"
#include "OCPN_Sound.h"
#include "TTYWindow.h"
+#include "Layer.h"
+#include "NavObjectCollection.h"
#ifdef USE_S57
#include "s52plib.h"
@@ -316,18 +318,12 @@ extern wxString g_TCData_Dir;
extern Multiplexer *g_pMUX;
extern bool portaudio_initialized;
-//------------------------------------------------------------------------------
-// Some wxWidgets macros for useful classes
-//------------------------------------------------------------------------------
-WX_DEFINE_LIST ( RouteList );
-WX_DEFINE_LIST ( SelectableItemList );
-WX_DEFINE_LIST ( RoutePointList );
-WX_DEFINE_LIST ( HyperlinkList ); // toh, 2009.02.22
-WX_DEFINE_LIST ( LayerList );
-
//---------------------------------------------------------------------------------
// Track Implementation
//---------------------------------------------------------------------------------
+
+#define TIMER_TRACK1 778
+
BEGIN_EVENT_TABLE ( Track, wxEvtHandler )
EVT_TIMER ( TIMER_TRACK1, Track::OnTimerTrack )
END_EVENT_TABLE()
@@ -975,30 +971,6 @@ double Track::GetXTE( RoutePoint *fm1, RoutePoint *fm2, RoutePoint *to )
;
}
-//-----------------------------------------------------------------------------
-// Layer Implementation
-//-----------------------------------------------------------------------------
-
-Layer::Layer( void )
-{
- m_bIsVisibleOnChart = g_bShowLayers;
- m_bIsVisibleOnListing = false;
- m_bHasVisibleNames = true;
- m_NoOfItems = 0;
-
- m_LayerName = _T("");
- m_LayerFileName = _T("");
- m_LayerDescription = _T("");
- m_CreateTime = wxDateTime::Now();
-}
-
-Layer::~Layer( void )
-{
-// Remove this layer from the global layer list
- if( NULL != pLayerList ) pLayerList->DeleteObject( this );
-
-}
-
// Layer helper function
wxString GetLayerName( int id )
@@ -4617,119 +4589,6 @@ void GPXLoadRoute( GpxRteElement* rtenode, int routenum, bool b_fullviz )
}
//---------------------------------------------------------------------------------
-// XML Support for Navigation Objects
-//---------------------------------------------------------------------------------
-
-NavObjectCollection::NavObjectCollection() :
- GpxDocument()
-{
- m_pXMLrootnode = (GpxRootElement *) RootElement();
-}
-
-NavObjectCollection::~NavObjectCollection()
-{
-// delete m_pXMLrootnode; // done in base class
-}
-
-bool NavObjectCollection::CreateNavObjGPXPoints( void )
-{
-
- // Iterate over the Routepoint list, creating Nodes for
- // Routepoints that are not in any Route
- // as indicated by m_bIsolatedMark == false
-
- wxRoutePointListNode *node = pWayPointMan->m_pWayPointList->GetFirst();
-
- RoutePoint *pr;
-
- while( node ) {
- pr = node->GetData();
-
- if( ( pr->m_bIsolatedMark ) && !( pr->m_bIsInLayer ) ) //( !WptIsInRouteList ( pr ) )
- {
- m_pXMLrootnode->AddWaypoint( CreateGPXWpt( pr, GPX_WPT_WAYPOINT ) );
- }
- node = node->GetNext();
- }
-
- return true;
-}
-
-bool NavObjectCollection::CreateNavObjGPXRoutes( void )
-{
- // Routes
- wxRouteListNode *node1 = pRouteList->GetFirst();
- while( node1 ) {
- Route *pRoute = node1->GetData();
-
- if( !pRoute->m_bIsTrack && !( pRoute->m_bIsInLayer ) ) // Not tracks
- {
- m_pXMLrootnode->AddRoute( CreateGPXRte( pRoute ) );
- }
- node1 = node1->GetNext();
- }
-
- return true;
-}
-
-bool NavObjectCollection::CreateNavObjGPXTracks( void )
-{
- // Tracks
- wxRouteListNode *node1 = pRouteList->GetFirst();
- while( node1 ) {
- Route *pRoute = node1->GetData();
- RoutePointList *pRoutePointList = pRoute->pRoutePointList; //->GetCount(); do if
-
- if( pRoutePointList->GetCount() ) {
- if( pRoute->m_bIsTrack && !( pRoute->m_bIsInLayer ) ) // Tracks only
- {
- //Redundant - RoutePointList *pRoutePointList = pRoute->pRoutePointList;
- m_pXMLrootnode->AddTrack( CreateGPXTrk( pRoute ) );
- }
- }
- node1 = node1->GetNext();
- }
-
- return true;
-}
-
-bool NavObjectCollection::LoadAllGPXObjects()
-{
- //FIXME: unite with MyConfig::ImportGPX
- TiXmlNode *root = RootElement();
-
- wxString RootName = wxString::FromUTF8( root->Value() );
- if( RootName == _T ( "gpx" ) ) {
- TiXmlNode *child;
- for( child = root->FirstChild(); child != 0; child = child->NextSibling() ) {
- wxString ChildName = wxString::FromUTF8( child->Value() );
- if( ChildName == _T ( "trk" ) ) ::GPXLoadTrack( (GpxTrkElement *) child );
- else
- if( ChildName == _T ( "rte" ) ) {
- int m_NextRouteNum = 0; //FIXME: we do not need it for GPX
- ::GPXLoadRoute( (GpxRteElement *) child, m_NextRouteNum );
- } else
- if( ChildName == _T ( "wpt" ) ) {
- int m_NextWPNum = 0; //FIXME: we do not need it for GPX
- RoutePoint *pWp = ::LoadGPXWaypoint( (GpxWptElement *) child,
- _T("circle") );
- RoutePoint *pExisting = WaypointExists( pWp->GetName(), pWp->m_lat,
- pWp->m_lon );
- if( !pExisting ) {
- if( NULL != pWayPointMan ) pWayPointMan->m_pWayPointList->Append( pWp );
- pWp->m_bIsolatedMark = true; // This is an isolated mark
- pSelect->AddSelectableRoutePoint( pWp->m_lat, pWp->m_lon, pWp );
- pWp->m_ConfigWPNum = m_NextWPNum;
- m_NextWPNum++;
- }
- }
- }
- }
-
- return true;
-}
-
-//---------------------------------------------------------------------------------
// Private Font Manager and Helpers
//---------------------------------------------------------------------------------
#include <wx/fontdlg.h>
View
1 src/routemanagerdialog.cpp
@@ -41,6 +41,7 @@
#include "routeman.h"
#include "georef.h"
#include "chartbase.h"
+#include "Layer.h"
#define DIALOG_MARGIN 3

0 comments on commit e1602ad

Please sign in to comment.
Something went wrong with that request. Please try again.