1 /* 2 Copyright (C) 2010-2014 Kristian Duske 3 4 This file is part of TrenchBroom. 5 6 TrenchBroom is free software: you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation, either version 3 of the License, or 9 (at your option) any later version. 10 11 TrenchBroom is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 #include "MultiMapView.h" 21 22 #include "View/MapView.h" 23 24 #include <cassert> 25 26 namespace TrenchBroom { 27 namespace View { MultiMapView(wxWindow * parent)28 MultiMapView::MultiMapView(wxWindow* parent) : 29 MapViewContainer(parent), 30 m_maximizedView(NULL) {} 31 ~MultiMapView()32 MultiMapView::~MultiMapView() {} 33 addMapView(MapView * mapView)34 void MultiMapView::addMapView(MapView* mapView) { 35 assert(mapView != NULL); 36 m_mapViews.push_back(mapView); 37 } 38 doFlashSelection()39 void MultiMapView::doFlashSelection() { 40 MapViewList::const_iterator it, end; 41 for (it = m_mapViews.begin(), end = m_mapViews.end(); it != end; ++it) { 42 MapView* mapView = *it; 43 mapView->flashSelection(); 44 } 45 } 46 doGetIsCurrent() const47 bool MultiMapView::doGetIsCurrent() const { 48 MapViewList::const_iterator it, end; 49 for (it = m_mapViews.begin(), end = m_mapViews.end(); it != end; ++it) { 50 MapView* mapView = *it; 51 if (mapView->isCurrent()) 52 return true; 53 } 54 return false; 55 } 56 doSetToolBoxDropTarget()57 void MultiMapView::doSetToolBoxDropTarget() { 58 MapViewList::const_iterator it, end; 59 for (it = m_mapViews.begin(), end = m_mapViews.end(); it != end; ++it) { 60 MapView* mapView = *it; 61 mapView->setToolBoxDropTarget(); 62 } 63 } 64 doClearDropTarget()65 void MultiMapView::doClearDropTarget() { 66 MapViewList::const_iterator it, end; 67 for (it = m_mapViews.begin(), end = m_mapViews.end(); it != end; ++it) { 68 MapView* mapView = *it; 69 mapView->clearDropTarget(); 70 } 71 } 72 doCanSelectTall()73 bool MultiMapView::doCanSelectTall() { 74 if (currentMapView() == NULL) 75 return false; 76 return currentMapView()->canSelectTall(); 77 } 78 doSelectTall()79 void MultiMapView::doSelectTall() { 80 if (currentMapView() != NULL) 81 currentMapView()->selectTall(); 82 } 83 doFocusCameraOnSelection(const bool animate)84 void MultiMapView::doFocusCameraOnSelection(const bool animate) { 85 MapViewList::const_iterator it, end; 86 for (it = m_mapViews.begin(), end = m_mapViews.end(); it != end; ++it) { 87 MapView* mapView = *it; 88 mapView->focusCameraOnSelection(animate); 89 } 90 } 91 doMoveCameraToPosition(const Vec3 & position,const bool animate)92 void MultiMapView::doMoveCameraToPosition(const Vec3& position, const bool animate) { 93 MapViewList::const_iterator it, end; 94 for (it = m_mapViews.begin(), end = m_mapViews.end(); it != end; ++it) { 95 MapView* mapView = *it; 96 mapView->moveCameraToPosition(position, animate); 97 } 98 } 99 doMoveCameraToCurrentTracePoint()100 void MultiMapView::doMoveCameraToCurrentTracePoint() { 101 MapViewList::const_iterator it, end; 102 for (it = m_mapViews.begin(), end = m_mapViews.end(); it != end; ++it) { 103 MapView* mapView = *it; 104 mapView->moveCameraToCurrentTracePoint(); 105 } 106 } 107 doCanMaximizeCurrentView() const108 bool MultiMapView::doCanMaximizeCurrentView() const { 109 return m_maximizedView != NULL || currentMapView() != NULL; 110 } 111 doCurrentViewMaximized() const112 bool MultiMapView::doCurrentViewMaximized() const { 113 return m_maximizedView != NULL; 114 } 115 doToggleMaximizeCurrentView()116 void MultiMapView::doToggleMaximizeCurrentView() { 117 if (m_maximizedView != NULL) { 118 doRestoreViews(); 119 m_maximizedView = NULL; 120 } else { 121 m_maximizedView = currentMapView(); 122 doMaximizeView(m_maximizedView); 123 } 124 } 125 doGetCurrentMapView() const126 MapView* MultiMapView::doGetCurrentMapView() const { 127 MapViewList::const_iterator it, end; 128 for (it = m_mapViews.begin(), end = m_mapViews.end(); it != end; ++it) { 129 MapView* mapView = *it; 130 if (mapView->isCurrent()) 131 return mapView; 132 } 133 return NULL; 134 } 135 } 136 } 137