/usr/include/osgEarthQt/LayerManagerWidget is in libosgearth-dev 2.4.0+dfsg-6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 | /* -*-c++-*- */
/* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
* Copyright 2008-2013 Pelican Mapping
* http://osgearth.org
*
* osgEarth is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
#ifndef OSGEARTHQT_LAYERMANAGERWIDGET_H
#define OSGEARTHQT_LAYERMANAGERWIDGET_H 1
#include <osgEarthQt/Actions>
#include <osgEarthQt/Common>
#include <osgEarthQt/DataManager>
#include <osgEarth/Map>
#include <QCheckBox>
#include <QDropEvent>
#include <QFrame>
#include <QHBoxLayout>
#include <QPoint>
#include <QScrollArea>
#include <QSlider>
#include <QVBoxLayout>
#include <QWidget>
namespace osgEarth { namespace QtGui
{
using namespace osgEarth;
class LayerManagerWidget;
//---------------------------------------------------------------------------
class LayerControlWidgetBase : public QFrame
{
Q_OBJECT
public:
LayerControlWidgetBase(LayerManagerWidget* parentManager, bool hasContent=true) : _parent(parentManager) { initUi(hasContent); }
virtual Action* getDoubleClickAction(const ViewVector& views) { return 0L; }
LayerManagerWidget* getParentManager() { return _parent; }
virtual osgEarth::UID getUID()=0;
signals:
void doubleClicked();
protected:
virtual ~LayerControlWidgetBase();
virtual void initUi(bool hasContent);
void mouseDoubleClickEvent(QMouseEvent* event);
void mousePressEvent(QMouseEvent* event);
void mouseMoveEvent(QMouseEvent* event);
void dragEnterEvent(QDragEnterEvent* event);
void dragLeaveEvent(QDragLeaveEvent* event);
//void dragMoveEvent(QDragMoveEvent* event);
void dropEvent(QDropEvent* event);
LayerManagerWidget* _parent;
QVBoxLayout* _primaryLayout;
QFrame* _headerBox;
QHBoxLayout* _headerBoxLayout;
QFrame* _contentBox;
QHBoxLayout* _contentBoxLayout;
QFrame* _dropBox;
QPoint _dragStartPosition;
};
//---------------------------------------------------------------------------
class ElevationLayerControlWidget : public LayerControlWidgetBase
{
Q_OBJECT
public:
ElevationLayerControlWidget(ElevationLayer* layer, LayerManagerWidget* parentManager);
Action* getDoubleClickAction(const ViewVector& views);
osgEarth::UID getUID();
ElevationLayer* layer() { return _layer.get(); }
void setLayerVisible(bool value);
private slots:
void onEnabledCheckStateChanged(int state);
protected:
virtual ~ElevationLayerControlWidget();
void initUi();
osg::ref_ptr<ElevationLayer> _layer;
osg::ref_ptr<Action> _doubleClick;
osg::ref_ptr<ElevationLayerCallback> _layerCallback;
QCheckBox* _visibleCheckBox;
};
//---------------------------------------------------------------------------
class ImageLayerControlWidget : public LayerControlWidgetBase
{
Q_OBJECT
public:
ImageLayerControlWidget(osgEarth::ImageLayer* layer, LayerManagerWidget* parentManager);
Action* getDoubleClickAction(const ViewVector& views);
osgEarth::UID getUID();
osgEarth::ImageLayer* layer() { return _layer.get(); }
void setLayerVisible(bool value);
void setLayerOpacity(float opacity);
private slots:
void onCheckStateChanged(int state);
void onSliderValueChanged(int value);
protected:
virtual ~ImageLayerControlWidget();
void initUi();
osg::ref_ptr<osgEarth::ImageLayer> _layer;
osg::ref_ptr<Action> _doubleClick;
osg::ref_ptr<ImageLayerCallback> _layerCallback;
QCheckBox* _visibleCheckBox;
QSlider* _opacitySlider;
};
//---------------------------------------------------------------------------
class ModelLayerControlWidget : public LayerControlWidgetBase
{
Q_OBJECT
public:
ModelLayerControlWidget(ModelLayer* layer, LayerManagerWidget* parentManager, osgEarth::Map* map=0L);
Action* getDoubleClickAction(const ViewVector& views);
osgEarth::UID getUID();
ModelLayer* layer() { return _layer.get(); }
void setLayerVisible(bool value);
void setLayerOverlay(bool overlay);
private slots:
void onEnabledCheckStateChanged(int state);
void onOverlayCheckStateChanged(int state);
protected:
virtual ~ModelLayerControlWidget();
void initUi();
osg::ref_ptr<ModelLayer> _layer;
osg::ref_ptr<Map> _map;
osg::ref_ptr<ModelLayerCallback> _layerCallback;
osg::ref_ptr<Action> _doubleClick;
QCheckBox* _visibleCheckBox;
QCheckBox* _overlayCheckBox;
};
//---------------------------------------------------------------------------
class LayerWidgetMimeData : public QMimeData
{
Q_OBJECT
public:
static const QString MIME_TYPE;
LayerWidgetMimeData(LayerControlWidgetBase* widget) : _widget(widget) {}
bool hasFormat(const QString &mimeType) const
{
if (mimeType == MIME_TYPE)
return true;
return false;
}
QStringList formats() const
{
QStringList formats;
formats << MIME_TYPE;
return formats;
}
QVariant retrieveData(const QString &mimeType, QVariant::Type type) const
{
return QVariant();
}
LayerControlWidgetBase* getWidget() const { return _widget; }
private:
LayerControlWidgetBase* _widget;
};
//---------------------------------------------------------------------------
class OSGEARTHQT_EXPORT LayerManagerWidget : public QScrollArea
{
Q_OBJECT
public:
enum LayerType {
ELEVATION_LAYERS,
IMAGE_LAYERS,
MODEL_LAYERS
};
LayerManagerWidget(DataManager* dm, LayerType type=IMAGE_LAYERS);
LayerManagerWidget(osgEarth::Map* map, LayerType type=IMAGE_LAYERS);
void setActiveView(osgViewer::View* view);
void setActiveViews(const ViewVector& views);
void resetStyleSheet();
private slots:
void onItemDoubleClicked();
private:
friend struct LayerManagerMapCallback;
QWidget* findItemByUID(osgEarth::UID uid, int* out_row=0L);
void addElevationLayerItem(osgEarth::ElevationLayer* layer, int index=-1);
void addImageLayerItem(osgEarth::ImageLayer* layer, int index=-1);
void addModelLayerItem(osgEarth::ModelLayer* layer, int index=-1);
void removeLayerItem(osgEarth::Layer* layer);
void moveLayerItem(osgEarth::Layer* layer, int oldIndex, int newIndex);
protected:
friend class LayerControlWidgetBase;
static const std::string DEFAULT_STYLESHEET;
void initialize();
void refresh();
void dragEnterEvent(QDragEnterEvent* event);
void dragLeaveEvent(QDragLeaveEvent* event);
void dropEvent(QDropEvent* event);
void doLayerWidgetDrop(LayerControlWidgetBase* widget, LayerControlWidgetBase* dropOn=0L);
osg::ref_ptr<DataManager> _manager;
osg::ref_ptr<osgEarth::Map> _map;
ViewVector _views;
LayerType _type;
QVBoxLayout* _stack;
QFrame* _dropBox;
bool _dragging;
int _dragId;
osg::observer_ptr<osg::Referenced> _dragLayer;
};
} }
#endif // OSGEARTHQT_LAYERMANAGERWIDGET_H
|