Skip to content

Commit

Permalink
not displaying selected records that are turned off #1719
Browse files Browse the repository at this point in the history
  • Loading branch information
lixun910 committed Oct 1, 2018
1 parent c535f5e commit ed0da65
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 30 deletions.
18 changes: 4 additions & 14 deletions Explore/MapLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ point_radius(2),
opacity(255),
pen_size(1),
show_boundary(false),
is_hide(true),
map_boundary(NULL)
{
is_hide = true;
}

BackgroundMapLayer::BackgroundMapLayer(wxString name, OGRLayerProxy* _layer_proxy, OGRSpatialReference* sr)
Expand All @@ -32,10 +32,10 @@ point_radius(2),
opacity(255),
pen_size(1),
show_boundary(false),
is_hide(false),
map_boundary(NULL),
show_connect_line(false)
{
is_hide = false;
num_obs = layer_proxy->GetNumRecords();
shape_type = layer_proxy->GetGdaGeometries(shapes, sr);
// this is for map boundary only
Expand Down Expand Up @@ -164,7 +164,7 @@ void BackgroundMapLayer::DrawHighlight(wxMemoryDC& dc, MapCanvas* map_canvas)
}
vector<wxInt64>& ids = aid_idx[aid];
for (int j=0; j<ids.size(); j++) {
if (associated_lines[associated_layer]) {
if (associated_lines[associated_layer] && !associated_layer->IsHide()) {
dc.DrawLine(shapes[i]->center, associated_layer->GetShape(ids[j])->center);
}
}
Expand All @@ -173,7 +173,7 @@ void BackgroundMapLayer::DrawHighlight(wxMemoryDC& dc, MapCanvas* map_canvas)

// draw self highlight
for (int i=0; i<highlight_flags.size(); i++) {
if (highlight_flags[i]) {
if (highlight_flags[i] && IsHide() == false) {
shapes[i]->paintSelf(dc);
}
}
Expand Down Expand Up @@ -321,16 +321,6 @@ Shapefile::ShapeType BackgroundMapLayer::GetShapeType()
return shape_type;
}

void BackgroundMapLayer::SetHide(bool flag)
{
is_hide = flag;
}

bool BackgroundMapLayer::IsHide()
{
return is_hide;
}

void BackgroundMapLayer::drawLegend(wxDC& dc, int x, int y, int w, int h)
{
wxPen pen(pen_color);
Expand Down
12 changes: 7 additions & 5 deletions Explore/MapLayer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ typedef pair<wxString, wxString> Association;

class AssociateLayerInt
{
protected:
bool is_hide;

public:
// primary key : AssociateLayer
map<AssociateLayerInt*, Association> associated_layers;
map<AssociateLayerInt*, bool> associated_lines;

AssociateLayerInt() {}
virtual ~AssociateLayerInt() {}

Expand All @@ -48,6 +51,8 @@ class AssociateLayerInt
associated_layers.clear();
}
virtual GdaShape* GetShape(int i) = 0;
virtual void SetHide(bool flag) { is_hide = flag; }
virtual bool IsHide() { return is_hide; }
};


Expand All @@ -66,7 +71,7 @@ class BackgroundMapLayer : public AssociateLayerInt
int opacity;
int pen_size;
bool show_boundary;
bool is_hide;


public:
OGRLayerProxy* layer_proxy;
Expand Down Expand Up @@ -105,9 +110,6 @@ class BackgroundMapLayer : public AssociateLayerInt
void SetName(wxString name);
virtual wxString GetName();

void SetHide(bool flag);
bool IsHide();

void SetPenColour(wxColour& color);
wxColour GetPenColour();

Expand Down
23 changes: 16 additions & 7 deletions Explore/MapLayerTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ void MapTree::DrawLegend(wxDC& dc, int x, int y, wxString text)
dc.DrawLine(10, y+2, x, y+2);

BackgroundMapLayer* ml = GetMapLayer(text);

x = x + 45; // switch width
dc.SetPen(*wxBLACK_PEN);
if (text == current_map_title) {
Expand All @@ -854,12 +854,15 @@ void MapTree::DrawLegend(wxDC& dc, int x, int y, wxString text)
dc.DrawText(text, x, y);

// draw switch button
if (ml == NULL) {
return;
AssociateLayerInt* ml_int;
if (ml) {
ml_int = ml;
} else {
ml_int = canvas;
}

wxString ds_thumb = "switch-on.png";
if (ml->IsHide()) ds_thumb = "switch-off.png";
if (ml_int->IsHide()) ds_thumb = "switch-off.png";
wxString file_path_str = GenUtils::GetSamplesDir() + ds_thumb;

wxImage img;
Expand Down Expand Up @@ -932,12 +935,18 @@ void MapTree::OnSwitchClick(wxMouseEvent& event)
wxString map_name = map_titles[new_order[switch_idx]];

BackgroundMapLayer* ml = GetMapLayer(map_name);

AssociateLayerInt* ml_int;
if (ml) {
ml->SetHide(!ml->IsHide());
ml_int = ml;
} else {
ml_int = canvas;
}

if (ml_int) {
ml_int->SetHide(!ml_int->IsHide());
canvas->DisplayMapLayers();
Refresh();
}
}
}
}

Expand Down
12 changes: 8 additions & 4 deletions Explore/MapNewView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ print_detailed_basemap(false),
maplayer_state(project_s->GetMapLayerState())
{
wxLogMessage("MapCanvas::MapCanvas()");
is_hide = false;
layer_name = project->layername;
bg_maps = project->CloneBackgroundMaps();
ds_name = project->GetDataSource()->GetOGRConnectStr();
Expand Down Expand Up @@ -877,7 +878,9 @@ void MapCanvas::DrawLayer0()
BOOST_FOREACH( GdaShape* map, background_maps ) {
map->paintSelf(dc);
}
DrawSelectableShapes_dc(dc);
if (IsHide() == false) {
DrawSelectableShapes_dc(dc);
}
BOOST_FOREACH( GdaShape* map, foreground_maps ) {
map->paintSelf(dc);
}
Expand Down Expand Up @@ -2101,14 +2104,15 @@ void MapCanvas::DrawHighlight(wxMemoryDC& dc, MapCanvas* map_canvas)
}
vector<wxInt64>& ids = aid_idx[aid];
for (int j=0; j<ids.size(); j++) {
if (associated_lines[associated_layer]) {
if (associated_lines[associated_layer] && !associated_layer->IsHide()) {
dc.DrawLine(selectable_shps[i]->center, associated_layer->GetShape(ids[j])->center);
}
}
}
}

this->DrawHighlighted(dc, false);
if (IsHide() == false) {
this->DrawHighlighted(dc, false);
}
}

GdaShape* MapCanvas::GetShape(int i)
Expand Down

0 comments on commit ed0da65

Please sign in to comment.