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

📄 plottypelistcontrol.h

📁 图像处理的压缩算法
💻 H
📖 第 1 页 / 共 2 页
字号:
/*------------------------------------------------------------------------------*
 * File Name:PlotTypeListControl.h												*
 * Creation: CPY 7/30/2003														*
 * Purpose: OriginC Class for managing the plot type list control for the  		*
 * the Plot Setup dialog														*
 * Copyright (c) Originlab Corp. 2003, 2004, 2005, 2006, 						*
 * All Rights Reserved															*
 * 																				*
 * Modification Log:															*
 *	CPY created 7/30/03 PLOT_TYPE_LIST_SEL_SUPPORT								*
 *	CPY 9/9/03 v7.5689 TERNARY_PLOT_USE_2D_TYPES								*
 *	CPY 9/20/03 MATRIX_SEL_SEE_3D_PLOTS_IN_2D_LAYERS							*
 * 	CPY 9/23/03 QA70-5134 v7.5704 3D_XYY_SHOULD_BE_NO_FUNCTION_PLOTS			*
 *	CPY 10/7/03 QA70-5309 v7.5714 CUSTOM_PLOT_TYPE_BROKEN_BY_END_EDIT			*
 *------------------------------------------------------------------------------*/

enum {IDM_PLOT_CUSTOM = 1, IDM_PLOT_STYLE_HOLDER};

//------ CPY 9/23/03 QA70-5134 v7.5704 3D_XYY_SHOULD_BE_NO_FUNCTION_PLOTS
//#define _DEBUG_PLOT_TYPE
//------

class PlotTypeListControl : public GridListControl
{
public:
	void Init(int nID, int nIDStatic, Dialog& dlg)
	{
		GridListControl::Init(nID, dlg);
		m_cntrlStyleHolder = dlg.GetItem(nIDStatic);
		
		int nFixedRows = 0;
		m_flx.FixedRows = nFixedRows;
		m_flx.Editable = flexEDNone;
		m_flx.Cols = 1;
		m_flx.Rows = nFixedRows;
		//m_flx.FormatString = "Plot Type";
		m_nSelPlotType = 0;
		m_dwAuxTypeInfo = 0;
		m_nCustomPlotID = 0;
		m_nCustomPlotExVal = 0;
		m_cntrlStyleHolder.Visible = false;
		m_dwLayerBits = 0;
		m_nCurrentDataPageType = 0;//undefined, EXIST_;
		m_nEditPlotPageType = 0;// undefined
		m_nEditPlotType = 0;
		m_dwEditAuxTypeInfo = 0;
		m_bAvailDataReady = false;
		//----- CPY 10/7/03 QA70-5309 v7.5714 CUSTOM_PLOT_TYPE_BROKEN_BY_END_EDIT
		m_nCustomPlotID_save = -1;// CPY 10/7/03, to indicate not yet initialized
		m_nCustomPlotExVal_save = 0;
		//-----
	}
	bool OnReady(DWORD dwAuxTypeInfo, int nPageType) // when all init done, may beed to do further initialization
	{
		m_nCurrentDataPageType = nPageType;
		SetTargetLayerType(dwAuxTypeInfo & MASK_PCD_LAYER_BITS);
		return true;
	}
	//nPlotType = internal plot type
	//nPlotID = Origin plot ID, might be a general plot ID like bubble, typically a menu res ID
	bool SetPlotType(uint nPlotType, int nPlotID = 0, DWORD dwAuxTypeInfo = 0, int nPlotExVal = 0)
	{
		bool bNeedUpdate = m_nSelPlotType == 0? true:false;
		m_nSelPlotType = nPlotType;
		m_dwAuxTypeInfo = dwAuxTypeInfo;
		m_nCustomPlotID = nPlotID;
		m_nCustomPlotExVal = nPlotExVal;
		return true; 
	}
	// when DataPlotList is changing selected item
	// return true if plot list is shown, so caller might set additional attributes
	bool OnChangeTarget(int nDPLtype, ColListControl& listCols)
	{
		//----CPY 8/21/03 TARAK_HELP_FIND_REASON_GRID_SHOWING_IN_LAYER_CONTENTS_OPEN
		if(!listCols.IsVisible())
			return false;
		//----
		if(nDPLtype >= DPL_STYLE_HOLDER_OUTSIDE_GROUP)
		{
			SetVisible(false);
			m_cntrlStyleHolder.Visible = true;
			return false;
		}
		else
		{
			m_cntrlStyleHolder.Visible = false;
			SetVisible(true);
			return true;
		}
	}
	void SetTargetLayerType(DWORD dwLayerBits)
	{
		//printf("nLayer = %d\n", HIWORD(dwLayerBits));
		m_dwLayerBits = dwLayerBits;
		OnNewPageType();
	}
	void Update()
	{
		int nFixedRows = m_flx.FixedRows;
		m_flx.Rows = m_vnPlotTypes.GetSize() + nFixedRows;
		
		for(int ii = nFixedRows, jj = 0; ii < m_flx.Rows; ii++, jj++)
		{
			m_flx.TextMatrix(ii, 0) = getPlotTypeStr(m_vnPlotTypes[jj]);
			m_flx.RowData(ii) = m_vnPlotTypes[jj];
		}
	}
	// called from main dialog, after ColListControl is updated with current edited data plot details
	void OnStartEditPlot(const string& strWksName, int nPlotType, DWORD dwAuxTypeInfo, DWORD dwLTPlotInfo)
	{
		m_nEditPlotPageType = EXIST_DATA;
		Page  pg(strWksName);
		if(pg)
			m_nEditPlotPageType = pg.GetType();
		
		
		m_nEditPlotType = nPlotType;
		m_dwEditAuxTypeInfo = dwAuxTypeInfo;
		
#ifdef _DEBUG_PLOT_TYPE		
		printf("On start edit, PlotType = %d, AuxTypeInfo = %X, layer bits = %X\n", nPlotType, dwAuxTypeInfo, (dwAuxTypeInfo & MASK_PCD_LAYER_BITS));
#endif

		m_nCustomPlotID_save = m_nCustomPlotID;
		m_nCustomPlotExVal_save = m_nCustomPlotExVal;
		updatePlotTypeList(m_nEditPlotPageType, nPlotType, 0, dwAuxTypeInfo, dwLTPlotInfo); 	
	}
	void OnEndEditPlot()
	{
		m_nEditPlotType = 0;
		m_nEditPlotPageType = 0;
		m_dwEditAuxTypeInfo = 0;
		//---- CPY 10/7/03 QA70-5309 v7.5714 CUSTOM_PLOT_TYPE_BROKEN_BY_END_EDIT
		if(m_nCustomPlotID_save >= 0) // CPY 10/7/03, check was actually saved , OnEndEditPlot could be called without OnStartEditPlot	
		{
			m_nCustomPlotID = m_nCustomPlotID_save;
			m_nCustomPlotExVal = m_nCustomPlotExVal_save;
		}
		//----
	}
	bool OnNewPageType(int nPageType = -1, bool bAddStyleHolderEntry = false)
	{
		if(nPageType >= 0)
		{
			m_nCurrentDataPageType = nPageType;
		}
		else
		{
			if(m_nCurrentDataPageType < 0)
				return false;
			nPageType = m_nCurrentDataPageType;
		} 
		if( is_page_type_incompatible( m_nEditPlotPageType, nPageType ) )
			return false; 
		
		if(m_nEditPlotPageType)
			updatePlotTypeList(nPageType, m_nEditPlotType, 0, m_dwEditAuxTypeInfo);		
		else	
			updatePlotTypeList(nPageType);
		
		m_bAvailDataReady = true;
		return true;
	}
	int GetCurrentPlotType(DWORD& dwAuxTypeInfo, int* pPlotExVal = NULL)
	{
		uint nPlotID = getSelPlotID(pPlotExVal);
		if(nPlotID)
			return getPlotType(nPlotID, &dwAuxTypeInfo);
		
		return 0;// none available
	}
	uint GetPlotTypeByIndex(int nIndex = 0) 
	{
		if(m_vnPlotTypes.GetSize() > nIndex)
			return m_vnPlotTypes[nIndex];
		
		return 0;//IDM_PLOT_LINE;
	}
	void OnPlotTypeChange(ColListControl& listCols, bool bReady = true)
	{
		if(!m_bAvailDataReady)
			return;
		
		int	nPlotExVal = 0;
		uint nPlotID = getSelPlotID(&nPlotExVal);
		if(bReady && nPlotID)
			listCols.OnChangePlotType(nPlotID, m_nCurrentDataPageType, nPlotExVal, m_dwLayerBits);
		else
			listCols.OnChangePlotType(0);
	}
	// get the list of selected plot types, currently only one can be selected
	bool	GetPlotTypes(vector<uint> &vnPlotTypes)
	{
		vnPlotTypes.SetSize(0);
		DWORD dwAuxTypeInfo;
		int nPlotType = GetCurrentPlotType(dwAuxTypeInfo);
		if(nPlotType)
		{
			vnPlotTypes.Add(nPlotType);
			return true;
		}
		
		return false;
	}
private:
	bool isPlotTypeSpecial(uint nPlotID, vector<uint>& vnPlotTypes)
	{
		if(0 == nPlotID)
			return false;
		DWORD 	dwCustom;
		uint	nTypeCustom = getPlotType(nPlotID, &dwCustom);
		for(int ii = 0; ii < vnPlotTypes.GetSize(); ii++)
		{
			DWORD dwCompare;
			int nTypeCompare = getPlotType(vnPlotTypes[ii], &dwCompare);
			//DWORD	dwCompare = dw & ~PCD_LTPLOTINFO_HAS_NEXVAL;
			//DWORD	dwCustomCompare = dwCustom & ~PCD_LTPLOTINFO_HAS_NEXVAL;
			//if(nTypeCustom == nType && dwCompare == dwCustomCompare)
			if(isPlotTypesTheSame(nTypeCustom, dwCustom, nTypeCompare, dwCompare))
				return false;
		}
		return true;
	}
	bool isPlotTypesTheSame(int nPlotType1, DWORD dwAuxTypeInfo1, int nPlotType2, DWORD dwAuxTypeInfo2, bool bIgnoreColorSize = false)
	{
		DWORD	dw1 = dwAuxTypeInfo1 & ~PCD_LTPLOTINFO_HAS_NEXVAL;
		DWORD	dw2 = dwAuxTypeInfo2 & ~PCD_LTPLOTINFO_HAS_NEXVAL;
		if(nPlotType1 != nPlotType2)
			return false;
		if(bIgnoreColorSize) 
		{
			dw2 = dw2 & ~(PCD_MODIFIER_SIZE | PCD_MODIFIER_COLOR | PCD_EXACT_YCOLS);
			dw1 = dw1 & ~(PCD_MODIFIER_SIZE | PCD_MODIFIER_COLOR | PCD_EXACT_YCOLS);
		}
		if(dw1 == dw2)
			return true;
		
#ifdef _DEBUG_PLOT_TYPE
		if(bIgnoreColorSize)
			printf("when bIgnoreColorSize, Plot Type dwAuxTypeInfo diff, %X vs %X\n", dw1, dw2);
		else
			printf("Plot Type dwAuxTypeInfo diff, %X vs %X\n", dw1, dw2);
#endif //#ifdef _DEBUG_PLOT_TYPE

		return false;
	}
	void updatePlotTypeList(int nPageType, int nPlotID = 0, int nPlotExVal = 0, DWORD dwAuxTypeInfo = 0, DWORD dwLTPlotInfo = 0)
	{
		//printf("page %d, layer %d, plot %d\n", nPageType, HIWORD(m_dwLayerBits), nPlotID);
		
		vector<uint> nWksPlots = {
			IDM_PLOT_LINE,IDM_PLOT_SCATTER,IDM_PLOT_LINESYMB,
			IDM_PLOT_COLUMN,IDM_PLOT_AREA,IDM_PLOT_FILL_COLOR_BAND,IDM_PLOT_HILOCLOSE,
			IDM_PLOT_COLUMN_FLOAT,IDM_PLOT_VECTOR,IDM_PLOT_FLOWVECTOR, IDM_PLOT_INDEX_SIZE, IDM_PLOT_INDEX_COLOR, IDM_PLOT_INDEX_SIZE_COLOR, 
			IDM_PLOT_PIE_TYPE, IDM_PLOT_BAR,IDM_PLOT_COLUMN_STACK, IDM_PLOT_BAR_STACK};
		vector<uint> nMatPlots = {
			IDM_PLOT_SURFACE_COLORMAP, IDM_PLOT_SURFACE_COLORFILL, IDM_PLOT_SURFACE_WIREFRAME, IDM_PLOT_SURFACE_BARS,
			IDM_PLOT_CONTOUR,IDM_PLOT_MATRIX_IMAGE};
		vector<uint> nDatasetPlots = {IDM_PLOT_LINE,IDM_PLOT_SCATTER,IDM_PLOT_LINESYMB}; 
		//vector<uint> n3DScatterPlots = {ID_3D_GRAPH_SCATTER, ID_3D_GRAPH_TRAJECTORY};
		vector<uint> n3DScatterPlots = {IDM_PLOT_3D_LINE, IDM_PLOT_3D_INDEX_SIZE, IDM_PLOT_3D_INDEX_COLOR, IDM_PLOT_3D_INDEX_SIZE_COLOR};
		vector<uint> nPolarSmithTernaryPlots = {IDM_PLOT_LINE,IDM_PLOT_SCATTER,IDM_PLOT_LINESYMB,IDM_PLOT_INDEX_SIZE, IDM_PLOT_INDEX_COLOR, IDM_PLOT_INDEX_SIZE_COLOR,IDM_PLOT_FLOWVECTOR, IDM_PLOT_COLUMN};
		//vector<uint> nFuncPlots = {IDM_FUNCS_PLOT};
		vector<uint> n3DXYYPlots = {IDM_PLOT_3D_BAR, IDM_PLOT_3D_RIBBON, IDM_PLOT_3D_WALL};
		
		if(EXIST_WKS == nPageType || EXIST_EXTERN_WKS == nPageType)
		{
			bool b3D = false;
			if(isTargetXYZLayer(b3D))
			{
				if(b3D)
					m_vnPlotTypes = n3DScatterPlots;
				else
					m_vnPlotTypes = nPolarSmithTernaryPlots;
			}
			else if (m_dwLayerBits == PCD_LAYER_POLAR)

⌨️ 快捷键说明

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