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

📄 ogr_featurestyle.h

📁 mitab,读取MapInfo的地图文件
💻 H
📖 第 1 页 / 共 2 页
字号:
/******************************************************************************
 * $Id: ogr_featurestyle.h 10646 2007-01-18 02:38:10Z warmerdam $
 *
 * Project:  OpenGIS Simple Features Reference Implementation
 * Purpose:  Define of Feature Representation
 * Author:   Stephane Villeneuve, stephane.v@videtron.ca
 *
 ******************************************************************************
 * Copyright (c) 1999, Frank Warmerdam
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included
 * in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 ****************************************************************************/

#ifndef OGR_FEATURESTYLE_INCLUDE
#define OGR_FEATURESTYLE_INCLUDE

#include "cpl_conv.h"

class OGRFeature;

typedef enum ogr_style_tool_class_id
{
    OGRSTCNone,
    OGRSTCPen,
    OGRSTCBrush,
    OGRSTCSymbol,
    OGRSTCLabel,
    OGRSTCVector
} OGRSTClassId;

typedef enum ogr_style_tool_units_id
{
    OGRSTUGround,
    OGRSTUPixel,
    OGRSTUPoints,
    OGRSTUMM,
    OGRSTUCM,
    OGRSTUInches
} OGRSTUnitId;

typedef enum ogr_style_tool_param_pen_id
{  
    OGRSTPenColor = 0,                   
    OGRSTPenWidth,                   
    OGRSTPenPattern,
    OGRSTPenId,
    OGRSTPenPerOffset,
    OGRSTPenCap,
    OGRSTPenJoin,
    OGRSTPenPriority,
    OGRSTPenLast
              
} OGRSTPenParam;

typedef enum ogr_style_tool_param_brush_id
{  
    OGRSTBrushFColor = 0,                   
    OGRSTBrushBColor,                   
    OGRSTBrushId,
    OGRSTBrushAngle,                   
    OGRSTBrushSize,
    OGRSTBrushDx,
    OGRSTBrushDy,
    OGRSTBrushPriority,
    OGRSTBrushLast
              
} OGRSTBrushParam;



typedef enum ogr_style_tool_param_symbol_id
{  
    OGRSTSymbolId = 0,
    OGRSTSymbolAngle,
    OGRSTSymbolColor,
    OGRSTSymbolSize,
    OGRSTSymbolDx,
    OGRSTSymbolDy,
    OGRSTSymbolStep,
    OGRSTSymbolPerp,
    OGRSTSymbolOffset,
    OGRSTSymbolPriority,
    OGRSTSymbolFontName,
    OGRSTSymbolLast
              
} OGRSTSymbolParam;

typedef enum ogr_style_tool_param_label_id
{  
    OGRSTLabelFontName = 0,
    OGRSTLabelSize,
    OGRSTLabelTextString,
    OGRSTLabelAngle,
    OGRSTLabelFColor,
    OGRSTLabelBColor,
    OGRSTLabelPlacement,
    OGRSTLabelAnchor,
    OGRSTLabelDx,
    OGRSTLabelDy,
    OGRSTLabelPerp,
    OGRSTLabelBold,
    OGRSTLabelItalic,
    OGRSTLabelUnderline,
    OGRSTLabelPriority,
    OGRSTLabelStrikeout,
    OGRSTLabelStretch,
    OGRSTLabelAdjHor,
    OGRSTLabelAdjVert,
    OGRSTLabelHColor,
    OGRSTLabelLast
              
} OGRSTLabelParam;

typedef enum ogr_style_tool_param_vector_id
{  
    OGRSTVectorId = 0,
    OGRSTVectorNoCompress,
    OGRSTVectorSprain,
    OGRSTVectorNoSlope,
    OGRSTVectorMirroring,
    OGRSTVectorCentering,
    OGRSTVectorPriority,
    OGRSTVectorLast
              
} OGRSTVectorParam;

typedef enum ogr_style_type
{
    OGRSTypeString,
    OGRSTypeDouble,
    OGRSTypeInteger,
    OGRSTypeBoolean
}  OGRSType;

typedef struct ogr_style_param
{
    int              eParam;
    char            *pszToken;
    GBool            bGeoref;
    OGRSType         eType;
}OGRStyleParamId;


typedef struct ogr_style_value
{
    char            *pszValue;
    double           dfValue;
    int              nValue; // Used for both integer and boolean types
    GBool            bValid;
    OGRSTUnitId      eUnit;
}OGRStyleValue;


//Everytime a pszStyleString gived in parameter is NULL, 
//    the StyleString defined in the Mgr will be use.

class CPL_DLL OGRStyleTable
{
  private:
    char **m_papszStyleTable;

  public:
    OGRStyleTable();
    ~OGRStyleTable();
    GBool AddStyle(const char *pszName,const char *pszStyleString);
    GBool RemoveStyle(const char *pszName);
    GBool ModifyStyle(const char *pszName, const char *pszStyleString);
    
    GBool SaveStyleTable(const char *pszFilename);
    GBool LoadStyleTable(const char *pszFilename);
    const char *Find(const char *pszStyleString);
    GBool IsExist(const char *pszName);
    const char *GetStyleName(const char *pszName);
    void  Print(FILE *fpOut);
    void  Clear();
    OGRStyleTable   *Clone();
};


class OGRStyleTool;

class CPL_DLL OGRStyleMgr
{
  private:
    OGRStyleTable   *m_poDataSetStyleTable;
    char            *m_pszStyleString;

  public:
    OGRStyleMgr(OGRStyleTable *poDataSetStyleTable = NULL);
    ~OGRStyleMgr();

    GBool SetFeatureStyleString(OGRFeature *,const char *pszStyleString=NULL,
                                GBool bNoMatching = FALSE);
    /*it will set in the gived feature the pszStyleString with 
            the style or will set the style name found in 
            dataset StyleTable (if bNoMatching == FALSE)*/
              
    const char *InitFromFeature(OGRFeature *);
    GBool InitStyleString(const char *pszStyleString = NULL);
    
    const char *GetStyleName(const char *pszStyleString= NULL);
    const char *GetStyleByName(const char *pszStyleName);
    
    GBool AddStyle(const char *pszStyleName, const char *pszStyleString=NULL);
    
    const char *GetStyleString(OGRFeature * = NULL);
 
    GBool AddPart(OGRStyleTool *);
    GBool AddPart(const char *);

    int GetPartCount(const char *pszStyleString = NULL);
    OGRStyleTool *GetPart(int hPartId, const char *pszStyleString = NULL);
    
    /*It could have a reference counting processus for the OGRStyleTable, if
      needed */
      
    OGRStyleTable *GetDataSetStyleTable(){return m_poDataSetStyleTable;}
    
    OGRStyleTool *CreateStyleToolFromStyleString(const char *pszStyleString);

};

class CPL_DLL OGRStyleTool
{
  private:
    GBool m_bModified;
    GBool m_bParsed;
    double m_dfScale;
    OGRSTUnitId m_eUnit;
    OGRSTClassId m_eClassId;
    char *m_pszStyleString;

    virtual GBool Parse() = 0;

  protected:
    GBool Parse(OGRStyleParamId* pasStyle,
                OGRStyleValue* pasValue,
                int nCount);

  public:
    
    OGRStyleTool(){}
    OGRStyleTool(OGRSTClassId eClassId);
    virtual ~OGRStyleTool();

    GBool GetRGBFromString(const char *pszColor, int &nRed, int &nGreen, 
                           int &nBlue, int &nTransparence);
    int   GetSpecificId(const char *pszId, const char *pszWanted);

    GBool IsStyleModified() {return m_bModified;}
    void  StyleModified() {m_bModified = TRUE;}

    GBool IsStyleParsed() {return m_bParsed;}
    void  StyleParsed() {m_bParsed = TRUE;}
    
    OGRSTClassId GetType();

    void SetInternalInputUnitFromParam(char *pszString);
    
    void SetUnit(OGRSTUnitId,double dfScale = 1.0); //the dfScale will be
         //used if we are working with Ground Unit ( ground = paper * scale);

    OGRSTUnitId GetUnit(){return m_eUnit;}
    
    /* It's existe two way to set the parameters in the Style, with generic
methodes (using a defined enumeration) or with the reel method specific
for Each style tools.*/
    
    virtual const char *GetStyleString() = 0;
    void SetStyleString(const char *pszStyleString);
    const char *GetStyleString(OGRStyleParamId *pasStyleParam ,
                            OGRStyleValue *pasStyleValue, int nSize);

    const char *GetParamStr(OGRStyleParamId &sStyleParam ,
                            OGRStyleValue &sStyleValue,
                            GBool &bValueIsNull);

⌨️ 快捷键说明

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