コード例 #1
0
ファイル: fpdf_flatten.cpp プロジェクト: hfiguiere/pdfium
CFX_FloatRect CalculateRect(CPDF_RectArray* pRectArray) {
  CFX_FloatRect rcRet;

  rcRet.left = GetMinMaxValue(*pRectArray, MIN, LEFT);
  rcRet.top = GetMinMaxValue(*pRectArray, MAX, TOP);
  rcRet.right = GetMinMaxValue(*pRectArray, MAX, RIGHT);
  rcRet.bottom = GetMinMaxValue(*pRectArray, MIN, BOTTOM);

  return rcRet;
}
コード例 #2
0
//按照等距自动进行分段
void CRangeRenderPage::OnBnClickedBtnAutoSetrange()
{
    UpdateData(TRUE);

	if(m_Breaknum<=0 || m_renderField.IsEmpty())
	{
		return;
	}

    double dmin=0.0,dmax =0.0;

	//获得字段的最大最小值
	GetMinMaxValue(dynamic_cast<Geodatabase::IFeatureClass*>(m_pLayer->GetDataObject().get()),
		            m_renderField,&dmax,&dmin);

    
	m_Classes.clear();
    m_list.DeleteAll();

	COLORREF beginColor =m_ctlColorRamp.get_curStartColor();
	COLORREF endColor =m_ctlColorRamp.get_curEndColor();
    

	RangeItem item;

	Display::ISymbolPtr pDefaultSymbol =CreateDefaultSymbol(dynamic_cast<Geodatabase::IFeatureClass*>(m_pLayer->GetDataObject().get()));

	Display::ISymbolPtr pSymbol;
	//如果最大最小值相等,则只分一个段
    if(dmin ==dmax)
	{
        item.max =dmax;
		item.min =dmin;
		pSymbol =pDefaultSymbol->Clone();
		pSymbol->SetColor(beginColor);
		item.pSymbol =pSymbol;

		item.strLabel.Format("%.6f%s%.6f",item.min,"-",item.max);
		
		m_Classes.push_back(item);
	    
	}
	else
	{
		//获取过渡色彩的各个分量
		int begin_r_color = (int)GetRValue(beginColor);
		int begin_g_color = (int)GetGValue(beginColor);
		int begin_b_color = (int)GetBValue(beginColor);

		int end_r_color =(int) GetRValue(endColor);
		int end_g_color =(int) GetGValue(endColor);
		int end_b_color =(int) GetBValue(endColor);

		double dr,dg,db;
        
		BYTE markr,markg,markb;

		if(m_Breaknum == 1)	
		{
			dr = end_r_color - begin_r_color;
			dg = end_g_color - begin_g_color;
			db = end_b_color - begin_b_color;
		}	  
		else
		{
			dr = (end_r_color - begin_r_color) / (double)(m_Breaknum - 1);
			dg = (end_g_color - begin_g_color) / (double)(m_Breaknum - 1);
			db = (end_b_color - begin_b_color) / (double)(m_Breaknum - 1);
		}
        
		double step =(dmax-dmin)/m_Breaknum;
        
	
		//分段的方法
		/*
		upper = min + i * step
		保留六位有效位
		下一个区间为上一个的上限+0.000001
		*/
		//依次加入区间
		for(int i=0;i<m_Breaknum;i++)
		{
			markr =begin_r_color+i*dr;
			markg =begin_g_color+i*dg;
			markb =begin_b_color +i*db;

			item.min =dmin+step*i+0.000001;
			item.max =dmin+step*(i+1);
			pSymbol =pDefaultSymbol->Clone();
			pSymbol->SetColor(RGB(markr,markg,markb));
			item.pSymbol =pSymbol;
			item.strLabel.Format("%.6f%s%.6f",item.min,"-",item.max);
			m_Classes.push_back(item);
		}

		//设置第一个和最后一个区间
		m_Classes[0].min =dmin;
		m_Classes[m_Breaknum-1].max =dmax;


	}


	//将各个分段添加到列表中
	for(size_t i=0;i<m_Classes.size();i++)
	{
		
		m_list.AddSymbolItem(m_Classes[i].pSymbol,m_Classes[i].strLabel,m_Classes[i].strLabel);
	}

}