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

📄 pagemaplayerprop.cpp

📁 一个英国人写的GIS查看/编辑工具。支持标准的shapefile地图文件格式和coverage地图文件格式。同时可以编辑相应的dbf文件。
💻 CPP
📖 第 1 页 / 共 3 页
字号:
            CFeature feature;
            feature.m_lFeatureTypeId = m_pMapLayer->GetFType();
            BOOL bFound = BDFeature(BDHandle(), &feature, BDSELECT2);
            while (bFound)
            {
               for (int j = 0; j < aColourFeature.GetSize(); j++)
               {
                  if (aColourFeature[j].m_lFeatureId == feature.m_lId)
                  {
                     aColourFeature[j].m_sFeature = feature.m_sName;
                  }
               }
               bFound = BDGetNext(BDHandle());
            }
            BDEnd(BDHandle());
         };

         // Now determine colors for the features
         
         for (int j = 0; j < aColourFeature.GetSize(); j++)
         {            
            CMapStyle mapstyle = GetStyle(j);
            (CMapStyle&)aColourFeature[j] = mapstyle;            
         }
         
         EndWaitCursor();
      }

      // Now add the features to the list

      m_lbLayers.ResetContent();
      for (int j = 0; j < aColourFeature.GetSize(); j++)
      {         
         m_lbLayers.AddString(aColourFeature[j].m_sFeature + "\n" + aColourFeature[j].m_sAttr,                              
                              aColourFeature[j].m_lFeatureId, 
                              (CMapStyle&)aColourFeature[j]);
      };      
      m_lbLayers.SetCurSel(0);
      OnSelchangeLayers();
   }
}

/////////////////////////////////////////////////////////////////////////////

void CPageMapLayerProp::RangeColour(BOOL bInit)
{
   // Determine whether range color is selected

   int index = m_cbAutoStyle.GetCurSel();
   ASSERT(index != CB_ERR);
   DWORD dw = m_cbAutoStyle.GetItemData(index);
   BOOL bCheck = dw == rangecolor;

   // Enable controls

   InitControls();

   // Initialise

   if (bCheck)
   {
      CRangeColourArray& aRangeColour = m_pMapProperty->m_aRangeColour;
      
      if (aRangeColour.GetSize() == 0 || !bInit)
      {
         BeginWaitCursor();         

         CDlgColourRange dlg(m_pMapLayer, m_pMapProperty, TRUE);
         dlg.DoModal();         
      }

      // Now add the layers to the list

      m_lbLayers.ResetContent();
      for (int j = 0; j < aRangeColour.GetSize(); j++)
      {                  
         CString s = aRangeColour.GetDesc(j);
         m_lbLayers.AddString(s + "\n" , 0, (CMapStyle&)aRangeColour[j]);
      }; 
      m_eMin.SetWindowText("");
      m_eMax.SetWindowText("");
      m_lbLayers.SetCurSel(0);
      OnSelchangeLayers();

      EndWaitCursor();
   }
}

/////////////////////////////////////////////////////////////////////////////
//
// Retrieve selected colors
//

void CPageMapLayerProp::UpdateRangeColour()
{
   CMapStyle mapstyle;
   // Retrieve colors

   CRangeColourArray& aRangeColour = m_pMapProperty->m_aRangeColour;
   ASSERT(aRangeColour.GetSize() == m_lbLayers.GetCount());
   for (int i = 0; i < m_lbLayers.GetCount(); i++)
   {
      mapstyle = m_lbLayers.GetStyle(i);

      (CMapStyle&)aRangeColour[i] = mapstyle;
      
      
   };
}

/////////////////////////////////////////////////////////////////////////////
//
// Add a new value to a range of values
//

void CPageMapLayerProp::OnAdd() 
{
   double dMin, dMax;
   COLORREF cr = -1;

   // Store existing selected colors

   UpdateRangeColour();

   // Retrieve the values from the controls

   if (m_eMin.GetValue(dMin) && m_eMax.GetValue(dMax,dMin))   
   {
      CRangeColourArray& aRangeColour = m_pMapProperty->m_aRangeColour;

     // Remove items included in new range

      for (int i = 0; i < aRangeColour.GetSize(); i++)
      {
         if (aRangeColour[i].m_dMin >= dMin && 
             aRangeColour[i].m_dMax <= dMax)
         {
            cr = aRangeColour[i].m_crFill;
            aRangeColour.RemoveAt(i);
            i--;
         }
      }

      // Determine where to place the value in the list

      for (i = 0; i < aRangeColour.GetSize(); i++)
      {         
         // Insert the new value in the correct place

         if (aRangeColour[i].m_dMin >= dMin)
         {
            if (cr == -1)
            {
               if (i > 0) cr = aRangeColour[i-1].m_crFill;            
               else cr = aRangeColour[i].m_crFill;
            };
            break;
         }

         // Adjust lesser value to fit
         
         if (aRangeColour[i].m_dMax > dMin)
         {
            cr = aRangeColour[i].m_crFill;
            aRangeColour[i].m_dMax = dMin;
         }
      }

      // Insert value

      if (i < aRangeColour.GetSize()) aRangeColour[i].m_dMin = dMax;      
            
      CRangeColour rangecolor;            
      rangecolor.m_dMin = dMin;
      rangecolor.m_dMax = dMax;
      rangecolor.m_crFill = cr;
      aRangeColour.InsertAt(i, rangecolor);

     // Update the list

      RangeColour(TRUE);      
   }	
}

/////////////////////////////////////////////////////////////////////////////
//
// Remove the current selection from the list
//

void CPageMapLayerProp::OnDelete() 
{  
   CRangeColourArray& aRangeColour = m_pMapProperty->m_aRangeColour;
   ASSERT(aRangeColour.GetSize() == m_lbLayers.GetCount());
      
   int i = m_lbLayers.GetCurSel();   
   if (i != LB_ERR)
   {
      // Retrieve colours

      UpdateRangeColour();

      // Adjust values either side to fill gap   

      if (i > 0) aRangeColour[i-1].m_dMax = aRangeColour[i].m_dMax;
      if (i+1 < aRangeColour.GetSize()) aRangeColour[i+1].m_dMin = aRangeColour[i].m_dMin;
      
      // Remove value
   
      aRangeColour.RemoveAt(i);

      // Redraw

      RangeColour(TRUE);
   };
	   
}


/////////////////////////////////////////////////////////////////////////////
//
// Enable/Disbales appropriate controls according to Auto Style property
//


void CPageMapLayerProp::InitControls()
{
   int index = m_cbAutoStyle.GetCurSel();
   ASSERT(index != CB_ERR);
   DWORD dw = m_cbAutoStyle.GetItemData(index);   

   m_lbLayers.EnableWindow(dw == sepcolor || dw == rangecolor || dw == legendvalues); 
   m_lbLayers.ShowWindow(dw == sepcolor || dw == rangecolor || dw == legendvalues); 
   m_eFeatureName.EnableWindow(dw == sepcolor || dw == legendvalues);
   m_eFeatureName.ShowWindow(dw == sepcolor || dw == legendvalues);   
   m_cbColourScheme.ShowWindow(dw == sepcolor || dw == legendvalues);
   GetDlgItem(IDC_SCHEMEMENU)->ShowWindow(dw == sepcolor || dw == legendvalues || dw == rangecolor);
   GetDlgItem(IDS_COLOURSCHEME)->ShowWindow(dw == sepcolor  || dw == legendvalues);
   GetDlgItem(IDC_UPDOWN)->ShowWindow(dw == sepcolor || dw == legendvalues);   
   GetDlgItem(IDS_MIN)->ShowWindow(dw == autocolor || dw == autosize || dw == rangecolor || dw == ranking);
   GetDlgItem(IDS_MAX)->ShowWindow(dw == autocolor || dw == autosize || dw == rangecolor || dw == ranking);
   m_eMin.EnableWindow(dw == autocolor || dw == autosize || dw == rangecolor || dw == ranking);
   m_eMax.EnableWindow(dw == autocolor || dw == autosize || dw == rangecolor || dw == ranking);
   m_eMin.ShowWindow(dw == autocolor || dw == autosize || dw == rangecolor || dw == ranking);
   m_eMax.ShowWindow(dw == autocolor || dw == autosize || dw == rangecolor || dw == ranking);
   GetDlgItem(IDC_ADD)->ShowWindow(dw == rangecolor);
   GetDlgItem(IDC_DELETE)->ShowWindow(dw == rangecolor);   
}

/////////////////////////////////////////////////////////////////////////////

void CPageMapLayerProp::OnDeltaposUpdown(NMHDR* pNMHDR, LRESULT* pResult) 
{  
	NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
   
	int i = m_lbLayers.GetCurSel();

   m_lbLayers.UpDown(pNMUpDown->iDelta);
	
	*pResult = 0;

}

/////////////////////////////////////////////////////////////////////////////

void CPageMapLayerProp::OnSelchangeLayers() 
{
   int index = m_cbAutoStyle.GetCurSel();
   ASSERT(index != CB_ERR);
   DWORD dw = m_cbAutoStyle.GetItemData(index);
   
   if (dw == sepcolor)
   {
      int index = m_lbLayers.GetCurSel();
      if (index != LB_ERR)
      {      
         CString s = m_lbLayers.GetText(index);
         m_eFeatureName.SetWindowText(s.Left(s.Find('\n')));
      }	
   }
   else if (dw == legendvalues)
   {
      int index = m_lbLayers.GetCurSel();
      if (index != LB_ERR)
      {      
         CString s = m_lbLayers.GetText(index);         
         m_eFeatureName.SetWindowText(s.Mid(s.Find('\n')+1));
      }	
   }
}

/////////////////////////////////////////////////////////////////////////////

void CPageMapLayerProp::OnChangeFeaturename() 
{
   int index = m_cbAutoStyle.GetCurSel();
   ASSERT(index != CB_ERR);
   DWORD dw = m_cbAutoStyle.GetItemData(index);

   // Separate Colour

   if (dw == sepcolor)
   {
	   CString s;
      m_eFeatureName.GetWindowText(s);
   
      int index = m_lbLayers.GetCurSel();
      if (index != LB_ERR)
      {
         CString s2 = m_lbLayers.GetText(index);
         s2 = s2.Mid(s2.Find('\n')+1);

         m_lbLayers.SetText(index, s + '\n' + s2);      
      }	
   }

   // Legend Values

   else if (dw == legendvalues)
   {
      CString s;
      m_eFeatureName.GetWindowText(s);
   
      int index = m_lbLayers.GetCurSel();
      if (index != LB_ERR)
      {
         CString s2 = m_lbLayers.GetText(index);
         s2 = s2.Left(s2.Find('\n'));

         m_lbLayers.SetText(index, s2 + '\n' + s);      
      }	
   }
   
}

///////////////////////////////////////////////////////////////////////////////

BOOL CPageMapLayerProp::OnSetActive() 
{
   // Set this as the default page

   CSheetMapProp *pSheet = (CSheetMapProp*)GetParent();
   ASSERT(pSheet->IsKindOf(RUNTIME_CLASS(CSheetMapProp)));
   pSheet->m_nDefaultPage = CSheetMapProp::layer;
	
	return CPropertyPage::OnSetActive();
}

/////////////////////////////////////////////////////////////////////////////
//
// Save changes
//

BOOL CPageMapLayerProp::OnKillActive() 
{
   double d1 = NULL_DOUBLE, d2 = NULL_DOUBLE;
   CString str;
   CMapStyle mapstyle;

   int index = m_cbAutoStyle.GetCurSel();
   ASSERT(index != CB_ERR);
   DWORD dw = m_cbAutoStyle.GetItemData(index);
  
   if ((dw != autocolor && dw != autosize && dw != ranking) || 
       (m_eMin.GetValue(d1) && m_eMax.GetValue(d2, d1)))
   {        
      if (dw == ranking) 
      {
         swap(d1, d2);
         dw = autocolor;
      };
      
      // Auto Colour/Size properties

      m_pMapProperty->m_bAutoColour = dw == autocolor;
      m_pMapProperty->m_bAutoSize = dw == autosize;
      
      if (dw == autocolor || dw == autosize)
      {
         m_pMapProperty->m_dAutoMin = d1;
         m_pMapProperty->m_dAutoMax = d2;
      }

      // Separate color, Update list
      
      m_pMapProperty->m_nSepColour = 0;      
      if (dw == sepcolor || dw == legendvalues)
      {
         m_pMapProperty->m_nSepColour = m_nSepColour;       
         
         CColourFeatureArray& aColourFeature = m_pMapProperty->m_aColourFeature;
         aColourFeature.RemoveAll();

         for (int i = 0; i < m_lbLayers.GetCount(); i++)
         {
            mapstyle = m_lbLayers.GetStyle(i);

            CColourFeature feature;
            feature.m_lFeatureId = m_lbLayers.GetItemData(i);
            (CMapStyle&)feature = mapstyle;            
            CString s = m_lbLayers.GetText(i);
            feature.m_sFeature = s.Left(s.Find('\n'));
            feature.m_sAttr = s.Mid(s.Find('\n')+1);
            aColourFeature.Add(feature);            
         }
      }

      // Range Colour, Update list

      m_pMapProperty->m_bRangeColour = dw == rangecolor;      
      if (dw == rangecolor)
      {
         UpdateRangeColour();
      }
      
	   return CPropertyPage::OnKillActive();
   };
   return FALSE;
}

⌨️ 快捷键说明

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