diff --git a/CcdDataImageProcessing/CcdDataImageProcessing.rc b/CcdDataImageProcessing/CcdDataImageProcessing.rc
index 7597604..9eaa63b 100644
Binary files a/CcdDataImageProcessing/CcdDataImageProcessing.rc and b/CcdDataImageProcessing/CcdDataImageProcessing.rc differ
diff --git a/CcdDataImageProcessing/CcdDataImageProcessing.vcxproj b/CcdDataImageProcessing/CcdDataImageProcessing.vcxproj
index 900a382..04e8c15 100644
--- a/CcdDataImageProcessing/CcdDataImageProcessing.vcxproj
+++ b/CcdDataImageProcessing/CcdDataImageProcessing.vcxproj
@@ -29,8 +29,8 @@
Application
true
v140
- Unicode
- Dynamic
+ MultiByte
+ Static
Application
@@ -187,6 +187,7 @@
+
@@ -195,6 +196,7 @@
+
Create
diff --git a/CcdDataImageProcessing/CcdDataImageProcessing.vcxproj.filters b/CcdDataImageProcessing/CcdDataImageProcessing.vcxproj.filters
index a550caf..2c7eb44 100644
--- a/CcdDataImageProcessing/CcdDataImageProcessing.vcxproj.filters
+++ b/CcdDataImageProcessing/CcdDataImageProcessing.vcxproj.filters
@@ -36,6 +36,9 @@
头文件
+
+ 头文件
+
@@ -50,6 +53,9 @@
源文件
+
+ 源文件
+
diff --git a/CcdDataImageProcessing/CcdDataImageProcessingDlg.cpp b/CcdDataImageProcessing/CcdDataImageProcessingDlg.cpp
index 1551dac..ba4e544 100644
--- a/CcdDataImageProcessing/CcdDataImageProcessingDlg.cpp
+++ b/CcdDataImageProcessing/CcdDataImageProcessingDlg.cpp
@@ -10,19 +10,7 @@
#define FILE_CCD_IMAGE_INFO_PATH _T("ccd_image_info.csv")
#define FILE_CCD_DATAT_PATH _T("ccd_data_path.csv")
-// ɫ
-#define RED RGB(255, 0, 0)
-#define ORANGE RGB(255, 165, 0)
-#define YELLOW RGB(255, 255, 0)
-#define GREEN RGB(0, 255, 0)
-#define CYAN RGB(0, 255, 255)
-#define BLUE RGB(0, 0, 255)
-#define PURPLE RGB(128, 0, 128)
-#define GREY RGB(169, 169, 169)
-#define PINK RGB(255, 192, 203)
-#define BLACK RGB(0, 0, 0)
-#define WHITE RGB(255, 255, 255)
-#define BROWN RGB(165, 42, 42)
+
// ؼIDӳ
const int minEnergyCtrlIds[] = { IDC_MIN_ENERGY_EDIT1, IDC_MIN_ENERGY_EDIT2, IDC_MIN_ENERGY_EDIT3,
@@ -53,8 +41,8 @@ const TCHAR* colorNames[] = {
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
-ColorSchemeManager m_colorSchemeManager;
-std::map m_proportionEnergy;
+//ColorSchemeManager m_colorSchemeManager;
+
// Ӧóڡ˵ CAboutDlg Ի
@@ -171,11 +159,12 @@ void CCcdDataImageProcessingDlg::DoDataExchange(CDataExchange* pDX)
DDX_Control(pDX, IDC_CCD_DATA_PATH_EDIT, m_CddDataPath);
+ DDX_Control(pDX, IDC_PIC_CTRL, m_PicCtrl);
}
BEGIN_MESSAGE_MAP(CCcdDataImageProcessingDlg, CDialogEx)
ON_WM_SYSCOMMAND()
- ON_WM_PAINT()
+// ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_IMAGE_INFO_SAVE_BUTTON, &CCcdDataImageProcessingDlg::OnBnClickedImageInfoSaveButton)
ON_BN_CLICKED(IDC_DLG_MIN_BUTTON, &CCcdDataImageProcessingDlg::OnBnClickedDlgMinButton)
@@ -184,6 +173,7 @@ BEGIN_MESSAGE_MAP(CCcdDataImageProcessingDlg, CDialogEx)
ON_BN_CLICKED(IDC_SLECT_PATH_BUTTON, &CCcdDataImageProcessingDlg::OnBnClickedSlectPathButton)
ON_WM_PAINT()
ON_BN_CLICKED(IDC_SAVE_IMAGE_BUTTON, &CCcdDataImageProcessingDlg::OnBnClickedSaveImageButton)
+ ON_WM_TIMER()
END_MESSAGE_MAP()
@@ -223,7 +213,7 @@ BOOL CCcdDataImageProcessingDlg::OnInitDialog()
OnInitEnergyInfo();
OnInitCcdDataPath();
OnInitAll();
-
+ SetTimer(0, 500, NULL);
return TRUE; // ǽõؼ TRUE
}
@@ -313,7 +303,7 @@ void CCcdDataImageProcessingDlg::OnBnClickedImageInfoSaveButton()
}
// ʾɹ
- AfxMessageBox(_T("CCDͼɫϢѱ棡"));
+ //AfxMessageBox(_T("CCDͼɫϢѱ棡"),MB_TOPMOST);
}
@@ -570,17 +560,9 @@ void CCcdDataImageProcessingDlg::OnBnClickedSlectPathButton()
void CCcdDataImageProcessingDlg::OnBnClickedImageGenerateButton()
{
- // TODO: ִ
- // һεĻ
- m_data.clear(); // ֮ǰ
-
+ CWaitCursor wait;
CString cddDataPathInfo;
GetDlgItemText(IDC_CCD_DATA_PATH_EDIT, cddDataPathInfo);
- CStringA cstrA(cddDataPathInfo); // CString תΪ CStringA
- std::string stdStr = cstrA.GetString(); // CStringA תΪ std::string
- CFileMgr fileMgr;
- fileMgr.ReadFileToStrVec(stdStr, m_data); // ļ energy_data.csv
-
m_colorSchemeManager.addScheme("Scheme1"); // Ӷɫ
//---ȡз--------------------------------------------
@@ -620,42 +602,42 @@ void CCcdDataImageProcessingDlg::OnBnClickedImageGenerateButton()
float maxEnergyValue = _tstof(maxEnergy); // תΪ float
// ɫ
- COLORREF color = WHITE; // ĬɫΪɫ
+ COLORREF color = RGB_WHITE; // ĬɫΪɫ
if (colorCombo == colorNames[0]) { // Red
- color = RED;
+ color = RGB_RED;
}
else if (colorCombo == colorNames[1]) { // Orange
- color = ORANGE;
+ color = RGB_ORANGE;
}
else if (colorCombo == colorNames[2]) { // Yellow
- color = YELLOW;
+ color = RGB_YELLOW;
}
else if (colorCombo == colorNames[3]) { // Green
- color = GREEN;
+ color = RGB_GREEN;
}
else if (colorCombo == colorNames[4]) { // Cyan
- color = CYAN;
+ color = RGB_CYAN;
}
else if (colorCombo == colorNames[5]) { // Blue
- color = BLUE;
+ color = RGB_BLUE;
}
else if (colorCombo == colorNames[6]) { // Purple
- color = PURPLE;
+ color = RGB_PURPLE;
}
else if (colorCombo == colorNames[7]) { // Grey
- color = GREY;
+ color = RGB_GREY;
}
else if (colorCombo == colorNames[8]) { // Pink
- color = PINK;
+ color = RGB_PINK;
}
else if (colorCombo == colorNames[9]) { // Black
- color = BLACK;
+ color = RGB_BLACK;
}
else if (colorCombo == colorNames[10]) { // White
- color = WHITE;
+ color = RGB_WHITE;
}
else if (colorCombo == colorNames[11]) { // Brown
- color = BROWN;
+ color = RGB_BROWN;
}
// ѡӷΧ
@@ -667,143 +649,154 @@ void CCcdDataImageProcessingDlg::OnBnClickedImageGenerateButton()
//---ͼ--------------------------------------------------------
m_colorSchemeManager.setCurrentScheme("Scheme1"); // õǰɫΪ Scheme1
+ gCsvToImg->m_colorSchemeManager = m_colorSchemeManager;
+ gCsvToImg->ReadCsv2Img(cddDataPathInfo);
- // ػԻǿˢ
- Invalidate(); // ǴΪЧ
- UpdateWindow(); // ˢ´
- printf("11");
+ auto Db2CString=[](float val)
+ {
+ CString str;
+ str.Format("%.3f", val);
+ return str;
+ };
+
+ auto ¤tScheme = gCsvToImg->m_colorSchemeManager.currentScheme;
+
+ //CEdit ؼеռֵ (ûȫʱ쳣)
+ try
+ {
+ m_ProportionEnergy1.SetWindowText(Db2CString(currentScheme->ranges.at(0).dPercent));
+ m_ProportionEnergy2.SetWindowText(Db2CString(currentScheme->ranges.at(1).dPercent));
+ m_ProportionEnergy3.SetWindowText(Db2CString(currentScheme->ranges.at(2).dPercent));
+ m_ProportionEnergy4.SetWindowText(Db2CString(currentScheme->ranges.at(3).dPercent));
+ m_ProportionEnergy5.SetWindowText(Db2CString(currentScheme->ranges.at(4).dPercent));
+ m_ProportionEnergy6.SetWindowText(Db2CString(currentScheme->ranges.at(5).dPercent));
+ m_ProportionEnergy7.SetWindowText(Db2CString(currentScheme->ranges.at(6).dPercent));
+ m_ProportionEnergy8.SetWindowText(Db2CString(currentScheme->ranges.at(7).dPercent));
+ m_ProportionEnergy9.SetWindowText(Db2CString(currentScheme->ranges.at(8).dPercent));
+ m_ProportionEnergy10.SetWindowText(Db2CString(currentScheme->ranges.at(9).dPercent));
+ }
+ catch (...){}
+
+ UpdateWindow();
}
// ֵɫ
COLORREF CCcdDataImageProcessingDlg::GetColorFromEnergy(float energy)
{
if (m_colorSchemeManager.currentScheme == nullptr) {
- return WHITE;
+ return RGB_WHITE;
}
return m_colorSchemeManager.currentScheme->getColor(energy);
}
-void CCcdDataImageProcessingDlg::OnPaint()
-{
- CPaintDC dc(this); // 豸
- CRect clientRect;
- GetClientRect(&clientRect); // ȡͻ
-
- // ñɫ
- dc.FillSolidRect(clientRect, RGB(255, 255, 255));
-
- //
- CFont font;
- font.CreatePointFont(120, _T("Arial"));
- dc.SelectObject(&font);
-
- //
- int numRows = m_data.size();
- int numCols = (numRows > 0) ? m_data[0].size() : 0;
-
- // Ϊգǰ
- if (numRows == 0 || numCols == 0) {
- dc.TextOut(10, 10, _T("No data available"));
- return;
- }
-
- // ȡڵĿȺ߶
- int maxImageWidth = clientRect.Width(); // ʹôڵĿ
- int maxImageHeight = clientRect.Height(); // ʹôڵĸ߶
-
- // ÿݿĴСΣ
- float pointSize;
- if (numCols > 0) {
- // ʹڿȶ̬ÿݿĴС
- float maxPointSizeWidth = static_cast(maxImageWidth) / numCols; // ÿݿڿϵС
- pointSize = static_cast(maxPointSizeWidth); // ѡƵĴС
- }
- else {
- pointSize = 10; // ĬϴС
- }
-
- // ߶ȿÿռ䣬̬ÿݿĸ߶
- int pointSizeHeight;
- if (numRows > 0) {
- // ʹڸ߶ȶ̬ÿݿĴС
- float maxPointSizeHeight = static_cast(maxImageHeight) / numRows; // ÿݿڸ߶ϵС
- pointSizeHeight = static_cast(maxPointSizeHeight); // ѡ߶ƵĴС
- }
- else {
- pointSizeHeight = 10; // ĬϴС
- }
-
- // ȡСֵȷݵܹӦ
- if (pointSize > pointSizeHeight)pointSize = pointSizeHeight;
-
- // pointSize ̫СһСֵ
- if (pointSize < 0.5) {
- pointSize = 0.5; // ȷÿݵΪ 1
- }
-
- // ƫʹͼұߣϱϱ
- int offsetX = 0;
- int offsetY = 0;
-
- // ÿݵ
- for (int row = 0; row < numRows; ++row) {
- for (int col = 0; col < numCols; ++col) {
- // ȷÿԪضЧ
- if (row < m_data.size() && col < m_data[row].size()) {
- try {
- float energy = std::stof(m_data[row][col]); // ַתΪ
-
- // ͳ
- if (energy < m_minEnergy) m_minEnergy = energy; // Сֵ
- if (energy > m_maxEnergy) m_maxEnergy = energy; // ֵ
-
- m_NumEnergy++;
-
- // ȡֵӦɫ
- COLORREF color = GetColorFromEnergy(energy);
- dc.SetDCBrushColor(color); // ûˢɫ
-
- // 㵱ǰݵλãƫ
- float scaledX = col * pointSize + offsetX;
- float scaledY = row * pointSize + offsetY;
-
- // ݿ
- CRect rect(scaledX, scaledY, scaledX + pointSize, scaledY + pointSize);
- dc.FillSolidRect(rect, color);
- }
- catch (const std::invalid_argument& e) {
- // ЧַĬֵ
- continue; // תΪ floatǰԪ
- }
- }
- }
- }
-
- // ʾСֵ
- CString str;
- str.Format(_T("Min Energy: %.2f, Max Energy: %.2f"), m_minEnergy, m_maxEnergy);
- dc.TextOut(0, 1300, str);
- UpProportionEnergy();
-}
-
-COLORREF ColorScheme::getColor(float energy)
-{
-
- for (const auto& range : ranges) {
- if (energy >= range.minEnergy && energy <= range.maxEnergy) {
-
- //HWND hwd = (HWND)range.proportionEnergy;
- //CString str;
- //GetDlgItemText(range.proportionEnergy, str); // ȡؼָ
- m_proportionEnergy[range.proportionEnergy]++;
- return range.color;
- }
- }
- return WHITE; // ĬϷذɫ
-
-}
-
+//void CCcdDataImageProcessingDlg::OnPaint()
+//{
+//
+//
+// gCsvToImg->ShowLastImg(&m_PicCtrl);
+// return;
+//
+// CPaintDC dc(this); // 豸
+// CRect clientRect;
+// GetClientRect(&clientRect); // ȡͻ
+//
+// // ñɫ
+// dc.FillSolidRect(clientRect, RGB(255, 255, 255));
+//
+// //
+// CFont font;
+// font.CreatePointFont(120, _T("Arial"));
+// dc.SelectObject(&font);
+//
+// //
+// int numRows = m_data.size();
+// int numCols = (numRows > 0) ? m_data[0].size() : 0;
+//
+// // Ϊգǰ
+// if (numRows == 0 || numCols == 0) {
+// dc.TextOut(10, 10, _T("No data available"));
+// return;
+// }
+//
+// // ȡڵĿȺ߶
+// int maxImageWidth = clientRect.Width(); // ʹôڵĿ
+// int maxImageHeight = clientRect.Height(); // ʹôڵĸ߶
+//
+// // ÿݿĴСΣ
+// float pointSize;
+// if (numCols > 0) {
+// // ʹڿȶ̬ÿݿĴС
+// float maxPointSizeWidth = static_cast(maxImageWidth) / numCols; // ÿݿڿϵС
+// pointSize = static_cast(maxPointSizeWidth); // ѡƵĴС
+// }
+// else {
+// pointSize = 10; // ĬϴС
+// }
+//
+// // ߶ȿÿռ䣬̬ÿݿĸ߶
+// int pointSizeHeight;
+// if (numRows > 0) {
+// // ʹڸ߶ȶ̬ÿݿĴС
+// float maxPointSizeHeight = static_cast(maxImageHeight) / numRows; // ÿݿڸ߶ϵС
+// pointSizeHeight = static_cast(maxPointSizeHeight); // ѡ߶ƵĴС
+// }
+// else {
+// pointSizeHeight = 10; // ĬϴС
+// }
+//
+// // ȡСֵȷݵܹӦ
+// if (pointSize > pointSizeHeight)pointSize = pointSizeHeight;
+//
+// // pointSize ̫СһСֵ
+// if (pointSize < 0.5) {
+// pointSize = 0.5; // ȷÿݵΪ 1
+// }
+//
+// // ƫʹͼұߣϱϱ
+// int offsetX = 0;
+// int offsetY = 0;
+//
+// // ÿݵ
+// for (int row = 0; row < numRows; ++row) {
+// for (int col = 0; col < numCols; ++col) {
+// // ȷÿԪضЧ
+// if (row < m_data.size() && col < m_data[row].size()) {
+// try {
+// float energy = std::stof(m_data[row][col]); // ַתΪ
+//
+// // ͳ
+// if (energy < m_minEnergy) m_minEnergy = energy; // Сֵ
+// if (energy > m_maxEnergy) m_maxEnergy = energy; // ֵ
+//
+// m_NumEnergy++;
+//
+// // ȡֵӦɫ
+// COLORREF color = GetColorFromEnergy(energy);
+// dc.SetDCBrushColor(color); // ûˢɫ
+//
+// // 㵱ǰݵλãƫ
+// float scaledX = col * pointSize + offsetX;
+// float scaledY = row * pointSize + offsetY;
+//
+// // ݿ
+// CRect rect(scaledX, scaledY, scaledX + pointSize, scaledY + pointSize);
+// dc.FillSolidRect(rect, color);
+// }
+// catch (const std::invalid_argument& e) {
+// // ЧַĬֵ
+// continue; // תΪ floatǰԪ
+// }
+// }
+// }
+// }
+//
+// // ʾСֵ
+// CString str;
+// str.Format(_T("Min Energy: %.2f, Max Energy: %.2f"), m_minEnergy, m_maxEnergy);
+// dc.TextOut(0, 1300, str);
+// UpProportionEnergy();
+//}
void CCcdDataImageProcessingDlg::OnBnClickedSaveImageButton()
{
@@ -815,7 +808,8 @@ void CCcdDataImageProcessingDlg::OnBnClickedSaveImageButton()
CString savePath = saveFileDlg.GetPathName();
// 2. ͼ溯
- SaveImage(savePath);
+ gCsvToImg->SaveLastImg(savePath);
+ //SaveImage(savePath);
}
}
@@ -851,3 +845,14 @@ void CCcdDataImageProcessingDlg::SaveImage(const CString& savePath)
}
}
+
+
+void CCcdDataImageProcessingDlg::OnTimer(UINT_PTR nIDEvent)
+{
+ // TODO: ڴϢ/Ĭֵ
+ gCsvToImg->ShowLastImg(&m_PicCtrl);
+
+
+
+ CDialogEx::OnTimer(nIDEvent);
+}
diff --git a/CcdDataImageProcessing/CcdDataImageProcessingDlg.h b/CcdDataImageProcessing/CcdDataImageProcessingDlg.h
index 0930bdc..1690734 100644
--- a/CcdDataImageProcessing/CcdDataImageProcessingDlg.h
+++ b/CcdDataImageProcessing/CcdDataImageProcessingDlg.h
@@ -1,14 +1,14 @@
// CcdDataImageProcessingDlg.h : ͷļ
//
-
+#include "CsvToImg.h"
#pragma once
#include "afxwin.h"
#include
#include "FileMgr.h"
#include