📄 tabtooldeftable.cpp
字号:
if (poDef->nPixelWidth == poNewPenDef->nPixelWidth && poDef->nLinePattern == poNewPenDef->nLinePattern && poDef->nPointWidth == poNewPenDef->nPointWidth && poDef->rgbColor == poNewPenDef->rgbColor) { nNewPenIndex = i+1; // Fount it! poDef->nRefCount++; } } /*----------------------------------------------------------------- * OK, we did not find a match, then create a new entry *----------------------------------------------------------------*/ if (nNewPenIndex == 0) { if (m_numPen >= m_numAllocatedPen) { // Realloc array by blocks of 20 items m_numAllocatedPen += 20; m_papsPen = (TABPenDef**)UGK_Realloc(m_papsPen, m_numAllocatedPen*sizeof(TABPenDef*)); } m_papsPen[m_numPen] = (TABPenDef*)UGK_Calloc(1, sizeof(TABPenDef)); *m_papsPen[m_numPen] = *poNewPenDef; m_papsPen[m_numPen]->nRefCount = 1; nNewPenIndex = ++m_numPen; } return nNewPenIndex;}/********************************************************************** * TABToolDefTable::GetNumBrushes() * * Return the number of valid Brush indexes for this .MAP file **********************************************************************/int TABToolDefTable::GetNumBrushes(){ return m_numBrushes;}/********************************************************************** * TABToolDefTable::GetBrushDefRef() * * Return a reference to the specified Brush tool definition, or NULL if * specified index is invalid. * * Note that nIndex is a 1-based index. A value of 0 indicates "none" * in MapInfo. **********************************************************************/TABBrushDef *TABToolDefTable::GetBrushDefRef(int nIndex){ if (nIndex >0 && nIndex <= m_numBrushes) return m_papsBrush[nIndex-1]; return NULL;}/********************************************************************** * TABToolDefTable::AddBrushDefRef() * * Either create a new BrushDefRef or add a reference to an existing one. * * Return the Brush index that has been attributed to this Brush tool * definition, or -1 if something went wrong * * Note that nIndex is a 1-based index. A value of 0 indicates "none" * in MapInfo. **********************************************************************/int TABToolDefTable::AddBrushDefRef(TABBrushDef *poNewBrushDef){ int i, nNewBrushIndex = 0; TABBrushDef *poDef; if (poNewBrushDef == NULL) return -1; /*----------------------------------------------------------------- * Check for "none" case: pattern = 0 (pattern 0 does not exist!) *----------------------------------------------------------------*/ if (poNewBrushDef->nFillPattern < 1) return 0; /*----------------------------------------------------------------- * Start by searching the list of existing Brushs *----------------------------------------------------------------*/ for (i=0; nNewBrushIndex == 0 && i<m_numBrushes; i++) { poDef = m_papsBrush[i]; if (poDef->nFillPattern == poNewBrushDef->nFillPattern && poDef->bTransparentFill == poNewBrushDef->bTransparentFill && poDef->rgbFGColor == poNewBrushDef->rgbFGColor && poDef->rgbBGColor == poNewBrushDef->rgbBGColor) { nNewBrushIndex = i+1; // Fount it! poDef->nRefCount++; } } /*----------------------------------------------------------------- * OK, we did not find a match, then create a new entry *----------------------------------------------------------------*/ if (nNewBrushIndex == 0) { if (m_numBrushes >= m_numAllocatedBrushes) { // Realloc array by blocks of 20 items m_numAllocatedBrushes += 20; m_papsBrush = (TABBrushDef**)UGK_Realloc(m_papsBrush, m_numAllocatedBrushes*sizeof(TABBrushDef*)); } m_papsBrush[m_numBrushes]=(TABBrushDef*)UGK_Calloc(1, sizeof(TABBrushDef)); *m_papsBrush[m_numBrushes] = *poNewBrushDef; m_papsBrush[m_numBrushes]->nRefCount = 1; nNewBrushIndex = ++m_numBrushes; } return nNewBrushIndex;}/********************************************************************** * TABToolDefTable::GetNumFonts() * * Return the number of valid Font indexes for this .MAP file **********************************************************************/int TABToolDefTable::GetNumFonts(){ return m_numFonts;}/********************************************************************** * TABToolDefTable::GetFontDefRef() * * Return a reference to the specified Font tool definition, or NULL if * specified index is invalid. * * Note that nIndex is a 1-based index. A value of 0 indicates "none" * in MapInfo. **********************************************************************/TABFontDef *TABToolDefTable::GetFontDefRef(int nIndex){ if (nIndex >0 && nIndex <= m_numFonts) return m_papsFont[nIndex-1]; return NULL;}/********************************************************************** * TABToolDefTable::AddFontDefRef() * * Either create a new FontDefRef or add a reference to an existing one. * * Return the Font index that has been attributed to this Font tool * definition, or -1 if something went wrong * * Note that nIndex is a 1-based index. A value of 0 indicates "none" * in MapInfo. **********************************************************************/int TABToolDefTable::AddFontDefRef(TABFontDef *poNewFontDef){ int i, nNewFontIndex = 0; TABFontDef *poDef; if (poNewFontDef == NULL) return -1; /*----------------------------------------------------------------- * Start by searching the list of existing Fonts *----------------------------------------------------------------*/ for (i=0; nNewFontIndex == 0 && i<m_numFonts; i++) { poDef = m_papsFont[i]; if (EQUAL(poDef->szFontName, poNewFontDef->szFontName)) { nNewFontIndex = i+1; // Fount it! poDef->nRefCount++; } } /*----------------------------------------------------------------- * OK, we did not find a match, then create a new entry *----------------------------------------------------------------*/ if (nNewFontIndex == 0) { if (m_numFonts >= m_numAllocatedFonts) { // Realloc array by blocks of 20 items m_numAllocatedFonts += 20; m_papsFont = (TABFontDef**)UGK_Realloc(m_papsFont, m_numAllocatedFonts*sizeof(TABFontDef*)); } m_papsFont[m_numFonts]=(TABFontDef*)UGK_Calloc(1, sizeof(TABFontDef)); *m_papsFont[m_numFonts] = *poNewFontDef; m_papsFont[m_numFonts]->nRefCount = 1; nNewFontIndex = ++m_numFonts; } return nNewFontIndex;}/********************************************************************** * TABToolDefTable::GetNumSymbols() * * Return the number of valid Symbol indexes for this .MAP file **********************************************************************/int TABToolDefTable::GetNumSymbols(){ return m_numSymbols;}/********************************************************************** * TABToolDefTable::GetSymbolDefRef() * * Return a reference to the specified Symbol tool definition, or NULL if * specified index is invalid. * * Note that nIndex is a 1-based index. A value of 0 indicates "none" * in MapInfo. **********************************************************************/TABSymbolDef *TABToolDefTable::GetSymbolDefRef(int nIndex){ if (nIndex >0 && nIndex <= m_numSymbols) return m_papsSymbol[nIndex-1]; return NULL;}/********************************************************************** * TABToolDefTable::AddSymbolDefRef() * * Either create a new SymbolDefRef or add a reference to an existing one. * * Return the Symbol index that has been attributed to this Symbol tool * definition, or -1 if something went wrong * * Note that nIndex is a 1-based index. A value of 0 indicates "none" * in MapInfo. **********************************************************************/int TABToolDefTable::AddSymbolDefRef(TABSymbolDef *poNewSymbolDef){ int i, nNewSymbolIndex = 0; TABSymbolDef *poDef; if (poNewSymbolDef == NULL) return -1; /*----------------------------------------------------------------- * Start by searching the list of existing Symbols *----------------------------------------------------------------*/ for (i=0; nNewSymbolIndex == 0 && i<m_numSymbols; i++) { poDef = m_papsSymbol[i]; if (poDef->nSymbolNo == poNewSymbolDef->nSymbolNo && poDef->nPointSize == poNewSymbolDef->nPointSize && poDef->_nUnknownValue_ == poNewSymbolDef->_nUnknownValue_ && poDef->rgbColor == poNewSymbolDef->rgbColor ) { nNewSymbolIndex = i+1; // Fount it! poDef->nRefCount++; } } /*----------------------------------------------------------------- * OK, we did not find a match, then create a new entry *----------------------------------------------------------------*/ if (nNewSymbolIndex == 0) { if (m_numSymbols >= m_numAllocatedSymbols) { // Realloc array by blocks of 20 items m_numAllocatedSymbols += 20; m_papsSymbol = (TABSymbolDef**)UGK_Realloc(m_papsSymbol, m_numAllocatedSymbols*sizeof(TABSymbolDef*)); } m_papsSymbol[m_numSymbols]=(TABSymbolDef*)UGK_Calloc(1, sizeof(TABSymbolDef)); *m_papsSymbol[m_numSymbols] = *poNewSymbolDef; m_papsSymbol[m_numSymbols]->nRefCount = 1; nNewSymbolIndex = ++m_numSymbols; } return nNewSymbolIndex;}/********************************************************************** * TABToolDefTable::GetMinVersionNumber() * * Returns the minimum file version number that can accept all the * tool objects currently defined. * * Default is 300, and currently 450 can be returned if file contains * pen widths defined in points. **********************************************************************/int TABToolDefTable::GetMinVersionNumber(){ int i, nVersion = 300; /*----------------------------------------------------------------- * Scan Pen Defs *----------------------------------------------------------------*/ for(i=0; i< m_numPen; i++) { if (m_papsPen[i]->nPointWidth > 0 ) { nVersion = MAX(nVersion, 450); // Raise version to 450 } } return nVersion;}void TABToolDefTable::PrintfInfo(){ TABPenDef *pen; TABBrushDef *brush; TABFontDef *font; TABSymbolDef *symbol; printf("Pen Definition:\n"); for(int i=0;i<m_numPen;i++) { pen = GetPenDefRef(i+1); printf("The %dth Pen Definition:\n"); printf("RefCount=%d PixelWidth=%d LinePattern=%d PointWidth=%d rgbColor=%d\n", pen->nRefCount,pen->nPixelWidth,pen->nLinePattern, pen->nPointWidth,pen->rgbColor); } printf("Brush Definition:\n"); for(int i=0;i<m_numBrushes;i++) { brush = GetBrushDefRef(i+1); printf("The %dth Brush Definition:\n"); printf("RefCount=%d FillPattern=%d TransparentFill=%d rgbFGColor=%d rgbBGColor=%d\n", brush->nRefCount,brush->nFillPattern,brush->bTransparentFill, brush->rgbFGColor,brush->rgbBGColor); } printf("Font Definition:\n"); for(int i=0;i<m_numFonts;i++) { font = GetFontDefRef(i+1); printf("The %dth Font Definition:\n"); printf("RefCount=%d FontName=%s\n",font->nRefCount,font->szFontName); } printf("Symbol Defintion:\n"); for(int i=0;i<m_numSymbols;i++) { symbol = GetSymbolDefRef(i+1); printf("The %dth Symbol Definition:\n"); printf("RefCount=%d SymbolNo=%d PointSize=%d rgbColor=%d\n", symbol->nRefCount,symbol->nSymbolNo,symbol->nPointSize, symbol->rgbColor); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -