mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-07-25 12:15:32 +03:00
273 lines
11 KiB
Diff
273 lines
11 KiB
Diff
From 9ac4ad6ff62dd449d8e1e6abef98521cae3e1839 Mon Sep 17 00:00:00 2001
|
|
From: Pavel Kalian <pavel@kalian.cz>
|
|
Date: Thu, 21 Jun 2018 17:08:06 -0300
|
|
Subject: [PATCH] Replace some wx arrays with std::vector (Fixes build with
|
|
current wxWidgets codebase)
|
|
|
|
---
|
|
include/s57chart.h | 2 +-
|
|
src/routemanagerdialog.cpp | 38 ++++++++---------
|
|
src/s57chart.cpp | 61 +++++++++++++---------------
|
|
src/wxsvg/include/wxSVG/NodeList.h | 2 +-
|
|
src/wxsvg/include/wxSVG/SVGElement.h | 2 +
|
|
5 files changed, 51 insertions(+), 54 deletions(-)
|
|
|
|
diff --git a/include/s57chart.h b/include/s57chart.h
|
|
index 42af908c71..2b8eefc014 100644
|
|
--- a/include/s57chart.h
|
|
+++ b/include/s57chart.h
|
|
@@ -160,7 +160,7 @@ class s57chart : public ChartBase
|
|
bool IsPointInObjArea(float lat, float lon, float select_radius, S57Obj *obj);
|
|
wxString GetObjectAttributeValueAsString( S57Obj *obj, int iatt, wxString curAttrName );
|
|
static wxString GetAttributeValueAsString( S57attVal *pAttrVal, wxString AttrName );
|
|
- static int CompareLights( const void** l1, const void** l2 );
|
|
+ static bool CompareLights( const S57Light* l1, const S57Light* l2 );
|
|
wxString CreateObjDescriptions( ListOfObjRazRules* rule);
|
|
static wxString GetAttributeDecode(wxString& att, int ival);
|
|
|
|
diff --git a/src/routemanagerdialog.cpp b/src/routemanagerdialog.cpp
|
|
index 56dcbbeb99..d677a42dd5 100644
|
|
--- a/src/routemanagerdialog.cpp
|
|
+++ b/src/routemanagerdialog.cpp
|
|
@@ -33,6 +33,8 @@
|
|
#include <wx/clipbrd.h>
|
|
|
|
#include <iostream>
|
|
+#include <vector>
|
|
+#include <algorithm>
|
|
|
|
#include "styles.h"
|
|
#include "dychart.h"
|
|
@@ -1523,14 +1525,11 @@ void RouteManagerDialog::OnTrkRightClick( wxListEvent &event )
|
|
PopupMenu( &menu );
|
|
}
|
|
|
|
-WX_DEFINE_ARRAY( Track*, TrackArray );
|
|
-
|
|
-static int CompareTracks( Track** track1, Track** track2 )
|
|
+static bool CompareTracks( Track* track1, Track* track2 )
|
|
{
|
|
- TrackPoint* start1 = ( *track1 )->GetPoint(0);
|
|
- TrackPoint* start2 = ( *track2 )->GetPoint(0);
|
|
- if( start1->GetCreateTime() > start2->GetCreateTime() ) return 1;
|
|
- return -1; // Two tracks starting at the same time is not possible.
|
|
+ TrackPoint* start1 = track1->GetPoint(0);
|
|
+ TrackPoint* start2 = track2->GetPoint(0);
|
|
+ return start1->GetCreateTime() < start2->GetCreateTime();
|
|
}
|
|
|
|
void RouteManagerDialog::OnTrkMenuSelected( wxCommandEvent &event )
|
|
@@ -1616,8 +1615,8 @@ void RouteManagerDialog::OnTrkMenuSelected( wxCommandEvent &event )
|
|
TrackPoint* tPoint;
|
|
TrackPoint* newPoint;
|
|
TrackPoint* lastPoint;
|
|
- TrackArray mergeList;
|
|
- TrackArray deleteList;
|
|
+ std::vector<Track*> mergeList;
|
|
+ std::vector<Track*> deleteList;
|
|
bool runningSkipped = false;
|
|
|
|
::wxBeginBusyCursor();
|
|
@@ -1626,17 +1625,17 @@ void RouteManagerDialog::OnTrkMenuSelected( wxCommandEvent &event )
|
|
item = m_pTrkListCtrl->GetNextItem( item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED );
|
|
if( item == -1 ) break;
|
|
Track* track = pTrackList->Item( m_pTrkListCtrl->GetItemData( item ) )->GetData();
|
|
- mergeList.Add( track );
|
|
+ mergeList.push_back( track );
|
|
}
|
|
|
|
- mergeList.Sort( (CMPFUNC_wxArrayTrackArray) CompareTracks );
|
|
+ std::sort(mergeList.begin(), mergeList.end(), CompareTracks );
|
|
|
|
- targetTrack = mergeList.Item( 0 );
|
|
+ targetTrack = mergeList[ 0 ];
|
|
lastPoint = targetTrack->GetLastPoint();
|
|
|
|
- for( unsigned int t = 1; t < mergeList.Count(); t++ ) {
|
|
-
|
|
- mergeTrack = mergeList.Item( t );
|
|
+ for(auto const& mergeTrack: mergeList) {
|
|
+ if(mergeTrack == *mergeList.begin())
|
|
+ continue;
|
|
|
|
if( mergeTrack->IsRunning() ) {
|
|
runningSkipped = true;
|
|
@@ -1654,18 +1653,17 @@ void RouteManagerDialog::OnTrkMenuSelected( wxCommandEvent &event )
|
|
|
|
lastPoint = newPoint;
|
|
}
|
|
- deleteList.Add( mergeTrack );
|
|
+ deleteList.push_back( mergeTrack );
|
|
}
|
|
|
|
- for( unsigned int i = 0; i < deleteList.Count(); i++ ) {
|
|
- Track* deleteTrack = deleteList.Item( i );
|
|
+ for(auto const& deleteTrack: deleteList) {
|
|
g_pAIS->DeletePersistentTrack( deleteTrack );
|
|
pConfig->DeleteConfigTrack( deleteTrack );
|
|
g_pRouteMan->DeleteTrack( deleteTrack );
|
|
}
|
|
|
|
- mergeList.Clear();
|
|
- deleteList.Clear();
|
|
+ mergeList.clear();
|
|
+ deleteList.clear();
|
|
|
|
::wxEndBusyCursor();
|
|
|
|
diff --git a/src/s57chart.cpp b/src/s57chart.cpp
|
|
index 1144b3ddcc..2a363e8771 100644
|
|
--- a/src/s57chart.cpp
|
|
+++ b/src/s57chart.cpp
|
|
@@ -5101,29 +5101,25 @@ wxString s57chart::GetAttributeValueAsString( S57attVal *pAttrVal, wxString Attr
|
|
return value;
|
|
}
|
|
|
|
-int s57chart::CompareLights( const void** l1ptr, const void** l2ptr )
|
|
+bool s57chart::CompareLights( const S57Light* l1, const S57Light* l2 )
|
|
{
|
|
- S57Light l1 = *(S57Light*) *l1ptr;
|
|
- S57Light l2 = *(S57Light*) *l2ptr;
|
|
+ int positionDiff = l1->position.Cmp( l2->position );
|
|
+ if( positionDiff != 0 ) return true;
|
|
|
|
- int positionDiff = l1.position.Cmp( l2.position );
|
|
- if( positionDiff != 0 ) return positionDiff;
|
|
|
|
- double angle1, angle2;
|
|
- int attrIndex1 = l1.attributeNames.Index( _T("SECTR1") );
|
|
- int attrIndex2 = l2.attributeNames.Index( _T("SECTR1") );
|
|
+ int attrIndex1 = l1->attributeNames.Index( _T("SECTR1") );
|
|
+ int attrIndex2 = l2->attributeNames.Index( _T("SECTR1") );
|
|
|
|
// This should put Lights without sectors last in the list.
|
|
- if( attrIndex1 == wxNOT_FOUND && attrIndex2 == wxNOT_FOUND ) return 0;
|
|
- if( attrIndex1 != wxNOT_FOUND && attrIndex2 == wxNOT_FOUND ) return -1;
|
|
- if( attrIndex1 == wxNOT_FOUND && attrIndex2 != wxNOT_FOUND ) return 1;
|
|
+ if( attrIndex1 == wxNOT_FOUND && attrIndex2 == wxNOT_FOUND ) return false;
|
|
+ if( attrIndex1 != wxNOT_FOUND && attrIndex2 == wxNOT_FOUND ) return true;
|
|
+ if( attrIndex1 == wxNOT_FOUND && attrIndex2 != wxNOT_FOUND ) return false;
|
|
|
|
- l1.attributeValues.Item( attrIndex1 ).ToDouble( &angle1 );
|
|
- l2.attributeValues.Item( attrIndex2 ).ToDouble( &angle2 );
|
|
+ double angle1, angle2;
|
|
+ l1->attributeValues.Item( attrIndex1 ).ToDouble( &angle1 );
|
|
+ l2->attributeValues.Item( attrIndex2 ).ToDouble( &angle2 );
|
|
|
|
- if( angle1 == angle2 ) return 0;
|
|
- if( angle1 > angle2 ) return 1;
|
|
- return -1;
|
|
+ return angle1 < angle2;
|
|
}
|
|
|
|
static const char *type2str( GeoPrim_t type)
|
|
@@ -5161,7 +5157,7 @@ wxString s57chart::CreateObjDescriptions( ListOfObjRazRules* rule_list )
|
|
wxString objText;
|
|
wxString lightsHtml;
|
|
wxString positionString;
|
|
- wxArrayPtrVoid lights;
|
|
+ std::vector<S57Light*> lights;
|
|
S57Light* curLight = NULL;
|
|
|
|
for( ListOfObjRazRules::Node *node = rule_list->GetLast(); node; node = node->GetPrevious() ) {
|
|
@@ -5252,7 +5248,7 @@ wxString s57chart::CreateObjDescriptions( ListOfObjRazRules* rule_list )
|
|
curLight = new S57Light;
|
|
curLight->position = positionString;
|
|
curLight->hasSectors = false;
|
|
- lights.Add( curLight );
|
|
+ lights.push_back( curLight );
|
|
}
|
|
}
|
|
|
|
@@ -5352,30 +5348,31 @@ wxString s57chart::CreateObjDescriptions( ListOfObjRazRules* rule_list )
|
|
}
|
|
} // Object for loop
|
|
|
|
- if( lights.Count() > 0 ) {
|
|
+ if( !lights.empty() ) {
|
|
|
|
// For lights we now have all the info gathered but no HTML output yet, now
|
|
// run through the data and build a merged table for all lights.
|
|
|
|
- lights.Sort( ( CMPFUNC_wxArraywxArrayPtrVoid )( &s57chart::CompareLights ) );
|
|
+ std::sort(lights.begin(), lights.end(), s57chart::CompareLights);
|
|
|
|
wxString lastPos;
|
|
|
|
- for( unsigned int curLightNo = 0; curLightNo < lights.Count(); curLightNo++ ) {
|
|
- S57Light* thisLight = (S57Light*) lights.Item( curLightNo );
|
|
+ for(auto const& thisLight: lights) {
|
|
int attrIndex;
|
|
|
|
if( thisLight->position != lastPos ) {
|
|
|
|
lastPos = thisLight->position;
|
|
|
|
- if( curLightNo > 0 ) lightsHtml << _T("</table>\n<hr noshade>\n");
|
|
+ if( thisLight != *lights.begin() )
|
|
+ lightsHtml << _T("</table>\n<hr noshade>\n");
|
|
+ curLight++;
|
|
|
|
lightsHtml << _T("<b>Light</b> <font size=-2>(LIGHTS)</font><br>");
|
|
lightsHtml << _T("<font size=-2>") << thisLight->position << _T("</font><br>\n");
|
|
|
|
- if( curLight && curLight->hasSectors ) lightsHtml
|
|
- <<_("<font size=-2>(Sector angles are True Bearings from Seaward)</font><br>");
|
|
+ if( curLight && curLight->hasSectors )
|
|
+ lightsHtml <<_("<font size=-2>(Sector angles are True Bearings from Seaward)</font><br>");
|
|
|
|
lightsHtml << _T("<table>");
|
|
}
|
|
@@ -5386,12 +5383,12 @@ wxString s57chart::CreateObjDescriptions( ListOfObjRazRules* rule_list )
|
|
attrIndex = thisLight->attributeNames.Index( _T("COLOUR") );
|
|
if( attrIndex != wxNOT_FOUND ) {
|
|
wxString color = thisLight->attributeValues.Item( attrIndex );
|
|
- if( color == _T("red (3)") ) lightsHtml
|
|
- << _T("<table border=0><tr><td bgcolor=red> </td></tr></table> ");
|
|
- if( color == _T("green (4)") ) lightsHtml
|
|
- << _T("<table border=0><tr><td bgcolor=green> </td></tr></table> ");
|
|
- if( color == _T("white (1)") ) lightsHtml
|
|
- << _T("<table border=0><tr><td bgcolor=yellow> </td></tr></table> ");
|
|
+ if( color == _T("red (3)") )
|
|
+ lightsHtml << _T("<table border=0><tr><td bgcolor=red> </td></tr></table> ");
|
|
+ if( color == _T("green (4)") )
|
|
+ lightsHtml << _T("<table border=0><tr><td bgcolor=green> </td></tr></table> ");
|
|
+ if( color == _T("white (1)") )
|
|
+ lightsHtml << _T("<table border=0><tr><td bgcolor=yellow> </td></tr></table> ");
|
|
}
|
|
|
|
lightsHtml << _T("</font></td><td><font size=-1><nobr><b>");
|
|
@@ -5474,7 +5471,7 @@ wxString s57chart::CreateObjDescriptions( ListOfObjRazRules* rule_list )
|
|
lightsHtml << _T("</table><hr noshade>\n");
|
|
ret_val = lightsHtml << ret_val;
|
|
|
|
- lights.Clear();
|
|
+ lights.clear();
|
|
}
|
|
|
|
return ret_val;
|
|
diff --git a/src/wxsvg/include/wxSVG/NodeList.h b/src/wxsvg/include/wxSVG/NodeList.h
|
|
index 4d91c39cd9..9c4e7b1e6b 100644
|
|
--- a/src/wxsvg/include/wxSVG/NodeList.h
|
|
+++ b/src/wxsvg/include/wxSVG/NodeList.h
|
|
@@ -13,6 +13,6 @@
|
|
|
|
#include "SVGElement.h"
|
|
#include <wx/dynarray.h>
|
|
-WX_DECLARE_OBJARRAY(wxSVGElement*, wxNodeList);
|
|
+WX_DECLARE_OBJARRAY(wxSVGElementP, wxNodeList);
|
|
|
|
#endif //wxSVG_NODE_LIST_H
|
|
diff --git a/src/wxsvg/include/wxSVG/SVGElement.h b/src/wxsvg/include/wxSVG/SVGElement.h
|
|
index c472b4654a..f47fb89659 100644
|
|
--- a/src/wxsvg/include/wxSVG/SVGElement.h
|
|
+++ b/src/wxsvg/include/wxSVG/SVGElement.h
|
|
@@ -18,6 +18,8 @@ class wxSVGDocument;
|
|
#include "SVGAnimatedType.h"
|
|
#include "SVGDTD.h"
|
|
|
|
+typedef wxSVGElement* wxSVGElementP;
|
|
+
|
|
class wxSVGElement:
|
|
public wxSvgXmlElement
|
|
{
|