⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qgslegend.h

📁 一个非常好的GIS开源新版本
💻 H
📖 第 1 页 / 共 2 页
字号:
/***************************************************************************                          qgslegend.h  -  description                             -------------------    begin                : Sun Jul 28 2002    copyright            : (C) 2002 by Gary E.Sherman    email                : sherman at mrcc dot com               Romans 3:23=>Romans 6:23=>Romans 10:9,10=>Romans 12 ***************************************************************************//*************************************************************************** *                                                                         * *   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.                                   * *                                                                         * ***************************************************************************//* $Id: qgslegend.h 7683 2007-11-29 10:16:43Z timlinux $ */#ifndef QGSLEGEND_H#define QGSLEGEND_H#include <deque>#include <map>#include <set>#include <QTreeWidget>class QgsLegendLayer;class QgsLegendLayerFile;class QgsLegendItem;class QgsMapLayer;class QgsMapCanvas;class QDomDocument;class QDomNode;class QMouseEvent;class QTreeWidgetItem;/**   \class QgsLegend   \brief A Legend treeview for QGIS   Map legend is a specialised QListView designed to show grooups of map layers,   map layers, and the map layer members, properties and symbols for each layer.   The legend supports simple operations such as displaying an ordered list of    layers in the current canvas, and complex operations such as drag/dropping    layer symbologies and properties between layers.    There are a variety of different items that can appear in a QgsLegend. All    items added to a QgsLegend should be inherited from QgsLegendItem as this   will ensure that they can perform legend specific tasks such as seeing if   dropping of other items onto them is allowed, returning their type etc.   The following types are defined:   <ul>   <li>QgsLegendGroup - a group folder for many layers (can include other groups)</li>   <li>QgsLegendLayer - a layer that contains one or more files associated with it.                         allowing more than one file lets you create virtual layers where                        1 or more files can share the same symbology and properties                        and be treated as they are one layer for things such as hiding /                         showing, scale dependent visibility etc.</li>   <li>QgsLegendSymbologyGroup - a collabsable node that contains symbology items. Can                                only exist inside of a QgsLegendLayer</li>   <li>QgsLegendSymbologyItem - a class break (vector) or pallette entry (raster) etc.                                 Double clicking on a symbology item will let you change                                the properties for only that specific item. Can only exist                                inside a symbology group.</li>   <li>QgsLegendPropertyGroup - a collapsable node that shows 1 or more properties. Can                                only exist inside of a QgsLegendLayer</li>   <li>QgsLegendPropertyItem - A list of properties related to the layer. Double clicking                              a property item will invoke a dialog that will let you change                              the property settings. Can only exist inside a property group</li>   <li>QgsLegendLayerFileGroup - each QgsLegendLayer can have one or more files associated                              with it. This is the container group for these files. Can                              only exist inside of a QgsLegendLayer.</li>   <li>QgsLegendLayerFile -  A file node that relates to a file on disk. Assigning multiple                             file nodes in a file group allows you treat them as if they are                             one entity.</li>   </ul>   @note Additional group types may be defined in the future to accommodate WMS, PostGIS etc layers.   @author Gary E.Sherman, Tim Sutton, Marco Hugentobler and Jens Oberender*/class QgsLegend : public QTreeWidget{    Q_OBJECT; private:    // Moved here to match access of declaration later in file.    // Previous location raised a warning in msvc as the forward    // declaration was public while the definition was private    class QgsLegendPixmaps;    public:    /*! Constructor.   * @param qgis_app link to qgisapp      * @param theParent An optional parent widget   * @param theName An optional name for the widget   */  QgsLegend(QWidget * parent = 0, const char *name = 0);  //! Destructor   ~QgsLegend();   /** Returns QgsLegendLayerFile associated with current layer */   QgsLegendLayerFile* currentLayerFile();     /*!Returns the current layer if the current item is a QgsLegendLayerFile.   If the current item is a QgsLegendLayer, its first maplayer is returned.  Else, 0 is returned.*/  QgsMapLayer* currentLayer();  /**Writes the content of the legend to a project file*/  bool writeXML(QDomNode & layer_node, QDomDocument & document);  /**Restores the legend from a project file*/  bool readXML(QDomNode& legendnode);  /**Returns true, if the y-coordinate is >= the center of the item*/  bool yCoordAboveCenter(QgsLegendItem* it, int ycoord);  /**Returns the first item in the hierarchy*/  QTreeWidgetItem* firstItem();  /**Returns the next item (next sibling or next item on level above)*/  QTreeWidgetItem* nextItem(QTreeWidgetItem* item);  /**Returns the next sibling of an item or 0 if there is none*/  QTreeWidgetItem* nextSibling(QTreeWidgetItem* item);  /**Returns the previous sibling of an item or 0 if there is none*/  QTreeWidgetItem* previousSibling(QTreeWidgetItem* item);  /**Finds the next dom node. This function is used by QgsLegend, but probably its not a good place here*/  static QDomNode nextDomNode(const QDomNode& theNode);  /**Inserts an item into another one. Stores the item specific settings of the moved item (and its subitems)   and applies it afterwards again*/  void insertItem(QTreeWidgetItem* move, QTreeWidgetItem* into);  /**Moves an item after another one. Stores the item specific settings of the moved item (and its subitems)   and applies it afterwards again*/  void moveItem(QTreeWidgetItem* move, QTreeWidgetItem* after);  /**Removes an item from the legend. This is e.g. necessary before shifting it to another place*/  void removeItem(QTreeWidgetItem* item);  /**Returns the ids of the layers contained in this legend. The order is bottom->top*/  std::deque<QString> layerIDs();    /**Updates layer set of map canvas*/  void updateMapCanvasLayerSet();    /**Updates overview*/  void updateOverview();  /**Show/remove all layer in/from overview*/  void setOverviewAllLayers(bool inOverview);  /**Adds an entry to mPixmapWidthValues*/  void addPixmapWidthValue(int width);  /**Adds an entry to mPixmapHeightValues*/  void addPixmapHeightValue(int height);  /**Removes an entry from mPixmapWidthValues*/  void removePixmapWidthValue(int width);  /**Removes an entry from mPixmapHeightValues*/  void removePixmapHeightValue(int height);  /** Sets the name of the QgsLegendLayer that is the parent of       the given QgsLegendLayerFile */  void setName(QgsLegendLayerFile* w, QString layerName);  /**Sets the toggle editing action. Usually called from QgisApp*/  void setToggleEditingAction(QAction* editingAction){mToggleEditingAction = editingAction;}  /**Returns structure with legend pixmaps*/  QgsLegendPixmaps& pixmaps() { return mPixmaps; }    void updateCheckStates(QTreeWidgetItem* item, Qt::CheckState state) {mStateOfCheckBoxes[item] = state;}  public slots:    /*!Adds a new layer group with the maplayer to the canvas*/    void addLayer( QgsMapLayer * layer );    void setMapCanvas(QgsMapCanvas * canvas){mMapCanvas = canvas;}    /**Updates symbology items for a layer*/    void refreshLayerSymbology(QString key, bool expandItem = true);   /*!   * Slot called to clear the tree of all items   * @note Usually connected to a QgsMapCanvas that will ask its legend to clear itself.   * @return void   */  void removeAll();  /*!   * Called when the user wishes to toggle on or off all of the layers in   * the legend, and in the map.   * @return void   */  void selectAll(bool select);  /*!   * Slot called when user wishes to add a new empty layer group to the legend.   * The user will be prompted for the name of the newly added group.   * @return void   */  void addGroup();  void removeLayer(QString);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -