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

📄 colorunit.cpp

📁 对测井数据显示、编辑、处理
💻 CPP
字号:
// ColorUnit.cpp: implementation of the CColorUnit class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "welldataprocess.h"
#include "ColorUnit.h"

#include "GlobalData.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CColorUnit::CColorUnit()
{
	m_fLeftValue = 0.0;
	m_fRightValue = 255.0;
}

CColorUnit::~CColorUnit()
{

}

void CColorUnit::SetRectValue(CRect rect)
{
	
}


void CColorUnit::SetTopPosition(int nTopPos)
{
	
}

void CColorUnit::SetBottomPosition(int nBottomPos)
{
	
}

void CColorUnit::SetRoad(CRoadUnit* pRoadUnit)
{
	m_rect.top = pRoadUnit->GetOrgPoint().y + pRoadUnit->GetRoadHeadHeight() / 2 + 12;
	m_rect.bottom = pRoadUnit->GetRoadHeadHeight() / 2 + m_rect.top - 16;
	m_rect.left = pRoadUnit->GetOrgPoint().x + 4;
	m_rect.right = m_rect.left + pRoadUnit->GetRoadWidth() - 8;
}

CRect CColorUnit::GetLayerRect()
{
	return m_rect;
}


int CColorUnit::GetTopPosition()
{
	return m_rect.top;
}

int CColorUnit::GetBottomPosition()
{
	return m_rect.bottom;
}

void CColorUnit::Draw(CDC *pDC)
{
	int nCount;
	nCount = int(m_fRightValue - m_fLeftValue);
	
	int x0 = m_rect.left;
	int x1 = x0;
	float fScale = (m_rect.Width() / 30.0f);
	
	for(int i = 0; i <= 30; i ++)
	{
	
		x1 = x0 + fScale + 0.5;
		CRect rect = CRect(x0, m_rect.top, x1, m_rect.bottom);
		EraseRect(pDC, rect, m_color[i * 2]);
		x0 = x1;
	}

	CString strLeft, strRight;
	strLeft.Format("%7.2f", m_fLeftValue);
	strRight.Format("%7.2f", m_fRightValue);
	PutText(1, m_rect.left + 12, m_rect.top - 8, 12, 0, strLeft, pDC);
	PutText(1, m_rect.right - 12, m_rect.top - 8, 12, 0, strRight, pDC);

}

float CColorUnit::GetRightValue()
{
	return m_fRightValue;
}

float CColorUnit::GetLeftValue()
{
	return m_fLeftValue;
}

void CColorUnit::SetValueLeft(float fValue)
{
	m_fLeftValue = fValue;
}

void CColorUnit::SetValueRight(float fValue)
{
	m_fRightValue = fValue;
}

CColorUnit::CColorUnit(float fLeftValue, float fRightValue, CRect rect)
{
	m_fLeftValue = fLeftValue;
	m_fRightValue = fRightValue;
	m_rect = rect;
}

void CColorUnit::SetColorValue(COLORREF color[])
{
	for(int i = 0; i < 64; i ++)
	{
		m_color[i] = color[i];
	}
}

COLORREF CColorUnit::GetIndexColor(int nIndex)
{
	return m_color[nIndex];
}

void CColorUnit::InitColorFromFile()
{
	COLORREF	color[64];
	FILE *fp;
	CString strFileName;

	strFileName = GetAppPath() + "\\Data\\rgb.txt";

	fp = fopen(strFileName, "r");
	if(fp == NULL)
	{
		AfxMessageBox("Can't open the Color File!");
		return;
	}

	for(int j = 0; j < 64; j ++)
	{
	   int r, g, b;
	   fscanf(fp, "%d %d %d", &r, &g, &b);
	   color[j] = RGB(r, g, b);
	}
	
	this->SetColorValue(color); 

	fclose(fp);
}

⌨️ 快捷键说明

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