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

📄 coldesignations.h

📁 图像处理的压缩算法
💻 H
📖 第 1 页 / 共 3 页
字号:
/*------------------------------------------------------------------------------*
 * File Name:ColDesignations.h													*
 * Creation: CPY 6/28/2003														*
 * Purpose: OriginC Class for managing column plot designations for the 		*
 * the Plot Setup dialog														*
 * Copyright (c) Originlab Corp. 2003, 2004, 2005, 2006, 						*
 * All Rights Reserved															*
 * 																				*
 * Modification Log:															*
 *	CPY 8/17/03 9/9/03 ROW_NUMBER_ROW_IMPROVEMENT								*
 *	CPY 9/15/03 ROW_NUMBER_ROW_AUTO_SHOW_IF_NO_X_COL_IN_WKS						*
 *	CPY 9/15/03, SET_ALL_TO_TOP_NO_PLOT											*
 *	RVD 9/3/2003 QA70-5078 v7.0682 PLOT_RANGE_APPLY								*
 *------------------------------------------------------------------------------*/

#ifndef _COL_DESIGNATIONS_H
#define _COL_DESIGNATIONS_H

#include <GetNBox.h> // We need GetNBox support for Row# X start/increment values

enum {INFO_COL_NAME = 1, INFO_COL_LABEL, INFO_COL_1ST_DATA, INFO_COL_INDEX};

#define STR_HEADING_COL			_LC("Column", _CAT)
#define STR_HEADING_DATASET		_LC("Dataset", _CAT)
#define STR_ROW_NUMBER			"Row#"
#define STR_ROWNUM_ROW_LABEL	_LC("From/Step=",_CAT)

class ColListControl : public GridListControl
{
public:
	ColListControl()
	{
		m_dwAuxPlotInfo = 0;
		m_dwAuxTypeInfo = 0;
		m_nNameCol = -1;
		m_nLabelCol = -1;
		m_n1stDataValCol = -1;
		m_nRadioColBegin = 0;
		m_nRadioColEnd = -1;
		m_RowNumberXFrom = 1;
		m_RowNumberXStep = 1;
		m_pOwner = NULL;
		m_bIsWksPages = false;
		m_bIsMatrixPage = false;
		m_bIsFunctionPlots = false;
		m_bEditMode = false;
	}
	void Init(int nID, Dialog& dlg, uint nPlotID, const string& strRegForDlgInfo, int nMakePlotExVal, int nXErrID, int nPosNegErrID, int nAddRowNumForX, int nPageNames, int nShowAllCols)
	{
		m_pOwner = &dlg; // save this so we can cast to correct class later
		
		GridListControl::Init(nID, dlg);
		SetAlternateRowColors();
		m_flx.Cols = 1;// just to show at least something
		m_flx.ExtendLastCol =true;// false;
		m_flx.Editable = flexEDKbdMouse;
		m_flx.FocusRect = flexFocusLight;//flexFocusInset
		if(0) // multiple selection, this is powerful, but could be confusing in terms of GUI
		{
			m_flx.SelectionMode = flexSelectionByRow;//flexSelectionFree;flexSelectionListBox;//
			m_flx.AllowSelection = true;
		}
		else
		{
			m_flx.SelectionMode = flexSelectionFree;
			m_flx.AllowSelection = false;
		}
		
		///////////////
		m_nPlotType	= Project.GetPlotTypeInfo(nPlotID, m_dwAuxTypeInfo, m_dwAuxPlotInfo, m_strColPattern);
		countYs();
		m_nMakePlotExVal = nMakePlotExVal;
		///////////////
		
		m_chkXErrBars = dlg.GetItem(nXErrID);
		m_chkPosNegErrBars = dlg.GetItem(nPosNegErrID);
		m_chkAddRowNumX = dlg.GetItem(nAddRowNumForX);
		m_staticCntrlPageNames = dlg.GetItem(nPageNames);
		m_chkShowAllCols = dlg.GetItem(nShowAllCols);
	}
	bool OnReady()
	{
		notifyDlgOnDesignationChanges(); // init the Add button
		return true;
	}
	
	int GetPlotType(DWORD *pdwAuxTypeInfo = NULL)
	{
		if (pdwAuxTypeInfo)
			*pdwAuxTypeInfo = m_dwAuxTypeInfo;
		return m_nPlotType;
	}
	
	bool IsAllowErrbars()
	{
		return IS_ALLOW_ERR_BARS(m_dwAuxTypeInfo);
	}
	bool IsAllowX() { return (m_dwAuxTypeInfo & PCD_NO_X)? false:true;}
	bool IsWorksheetPages() { return m_bIsWksPages;}
	
	Control GetItem(int nID)
	{
		Control cntrl;
		if(m_pOwner)
			cntrl = m_pOwner->GetItem(nID);
		return cntrl;
	}
	//virtual
	void ClearAll()
	{
		GridListControl::ClearAll();
		m_vsPageNames.SetSize(0);
	}
	// return number of Col Designations that is greater then the given value
	int GetNumDesignationsAssigned(int nDesigBase = COLDESIG_NONE)
	{
		int nCount = 0;
		int nR1 = m_flx.FixedRows;
		int nR2 = m_flx.Rows;
		for(int nRow = nR1; nRow < nR2; nRow++)
		{
			if(getColDesignation(nRow) > nDesigBase)
				nCount++;
		}
		return nCount;
	}
	void ClearColDesignations(int nRow = -1, int nCol = -1, bool bAllDown = false, bool bKeepX = false, bool bRepaint = true);
	void ClearAllDesignations(bool bKeepX = true) {ClearColDesignations(-1, -1, bKeepX, true);}
	
	void SetColDesginations(int nRow, int nCol, bool bAllDown, bool bRepaint = true);// otherwise all up
	void ApplyWksColDesignations(bool bRepaint = false)
	{
		HOUR_GLASS
		
		int nR1 = m_flx.FixedRows;
		int nR2 = m_flx.Rows;
		string strColName;
		string str1stYDataset;
		
		for(int nRow = nR1; nRow < nR2; nRow++)
		{
			//int nDesig = m_flx.RowData(nRow);
			strColName = m_flx.TextMatrix(nRow, m_nNameCol);
			if(m_bIsWksPages)
			{
				Worksheet wks(m_vsPageNames[0]);
				Column cc = wks.Columns(strColName);
				if(cc)
				{
					int nDesignation = colTypeToColDesignation(cc.GetType());
					if(COLDESIG_Y == nDesignation && str1stYDataset.IsEmpty())
						str1stYDataset = strColName;

					setDesignation(nRow, nDesignation);
				}
			}
			else if(m_bIsMatrixPage)
				setDesignation(nRow, COLDESIG_Z);
			else // loose datasets
			{
				DWORD dw = Project.GetDatasetInfo(strColName);
				if(PGDN_PLOTTABLE & dw)
				{
					if(str1stYDataset.IsEmpty())
						str1stYDataset = strColName;
					setDesignation(nRow, COLDESIG_Y);
				}
				else if(PGDN_IS_DATASET & dw)
					setDesignation(nRow, COLDESIG_X);
				else
					setDesignation(nRow, COLDESIG_NONE);
			}
		}
		//----- CPY 9/9/03 ROW_NUMBER_ROW_IMPROVEMENT
		m_RowNumberXFrom = 1;
		m_RowNumberXStep = 1;
		if(isRowNumberRowAllowed() && !str1stYDataset.IsEmpty())
		{
			double dbXFrom = 1, dbXStep = 1;
			string strDataset = m_bIsWksPages? m_vsPageNames[0] + "_" + str1stYDataset : str1stYDataset;
			if(GetDatasetXFromStep(strDataset, &dbXFrom, &dbXStep))
			{
				m_RowNumberXFrom = dbXFrom;
				m_RowNumberXStep = dbXStep;
				updateRowNumberXFromAndStep();
			}
		}
		//----- end ROW_NUMBER_ROW_IMPROVEMENT

		if(bRepaint)
			updateDesignations();

		notifyDlgOnDesignationChanges();
	}
	// called from PlotList when a data plot is edited
	bool OnStartEditPlot(int nPlotType, DWORD dwAuxTypeInfo, LPCSTR lpcszColPattern)
	{
		m_nPlotType = nPlotType;
		m_dwAuxTypeInfo = dwAuxTypeInfo;
		m_dwAuxPlotInfo = 0;
		m_strColPattern = lpcszColPattern;
		countYs();
		m_nMakePlotExVal = 0;
		m_bEditMode = true;
		return true;
	}
	void OnEndEditPlot()
	{
		m_bEditMode = false;
	}
	bool IsInEditMode() { return m_bEditMode;}
	bool IsReadyAddReplacePlot()
	{
		int nMainColDesignations = 0;
		//if(isRowNumberRowAllowed() && countDesignations(COLDESIG_X) != 1)
		if(isRowNumberRowAllowed() && !(PCD_X_OPTIONAL & m_dwAuxTypeInfo) && countDesignations(COLDESIG_X) != 1)
			return false;
		bool bCountY = false;
		if(PCD_ONLY_ONE_Z & m_dwAuxTypeInfo)
			nMainColDesignations = countDesignations(COLDESIG_Z);
		else
		{
			bCountY = true;
			nMainColDesignations = countDesignations(COLDESIG_Y);
		}
		if(!bCountY && nMainColDesignations != 1) 
			return false;
		
		if(bCountY && !hasEnoughYs(nMainColDesignations))
			return false;
	
		if(bCountY && IsInEditMode() && hasTooManyYs(nMainColDesignations))
			return false;
		
		if(m_nModifiers > 0 && countModifiers() != m_nModifiers)
			return false;
		
		return true;
	}
	// called mainly from PlotTypeListControl
	void OnChangePlotType(int nNewPlotID, int nPageType = 0, int nPlotExVal = 0, DWORD dwLayerBits = 0)
	{		
		RemoveSelection();
		if( 0 == nNewPlotID )
		{
			ClearAll();
			return;
		}
		updatePlotType(nNewPlotID, nPageType, dwLayerBits);
		m_nMakePlotExVal = nPlotExVal;			
		updateListAfterChange(false, false, true);
	}
	bool ApplyColDesignations(const vector<string>&	vsColNames, const vector<uint>&	vnColDesignations, bool bRepaint = true)
	{
		HOUR_GLASS
		
		int nRow;
		for(int ii = 0; ii < vsColNames.GetSize(); ii ++)
		{
			nRow = FindRow(vsColNames[ii], m_nNameCol);
			if(nRow >= 0 && ii < vnColDesignations.GetSize())
				setDesignation(nRow, vnColDesignations[ii]);
			else if(nRow < 0 && (nRow = getRowNumberRow()) > 0) // not found, check to see if Row# CPY 8/21/03 QA70-5034
			{
				if(COLDESIG_X == vnColDesignations[ii] && vsColNames[ii].Find('/') > 0) // From/Step
				{
					setDesignation(nRow, COLDESIG_X);
					setXFromStepStr(vsColNames[ii]);
				}
			}
		}
		if(bRepaint)
			updateDesignations();
			
		notifyDlgOnDesignationChanges();
		return true;
	}
	int	GetNumLayers()
	{
		int		nNum = m_dwAuxPlotInfo & LTPI_LAYERS_NUMBER_MASK;
		if (nNum < 1)
			nNum = 1;
		
		return nNum;
	}	
	void UpdateList()// from default if no wks name given
	{
		vector<string> vsWksNames;
		WorksheetPage wksPage = Project.Pages();
		if(wksPage)
		{
			vsWksNames.Add(wksPage.GetName());
			UpdateList(vsWksNames);
		}
		else
			ClearAll();
	}
	void UpdateList(vector<string>& vsWksPageNames, bool bApplyWks = false, int nPageType = 0)
	{
		ClearAll();
		//--- CPY 9/15/03 ROW_NUMBER_ROW_AUTO_SHOW_IF_NO_X_COL_IN_WKS
		if(EXIST_WKS == nPageType && !m_chkAddRowNumX.Check)
		{
			Worksheet wks(vsWksPageNames[0]);
			if(wks)
			{
				string strColDesigs = wks.GetColDesignations();
				if(strColDesigs.Find('X') < 0) // no X col in wks
				{
					//out_str("Force Row#");
					m_chkAddRowNumX.Check = true;
				}
			}
		}
		//--- end
		if(nPageType < EXIST_DATA)
			nPageType = guessPageType(vsWksPageNames[0]);
			
		updateWksPageNames(vsWksPageNames, nPageType);
		updateShowWksNames();
		setupGridCols();
		vector<string> vsColNames, vsColLabels;
		
		m_vsColNames.SetSize(0);
		m_vsColLabels.SetSize(0);
		if(vsWksPageNames.GetSize() && Project.GetCommonColumns(vsWksPageNames, vsColNames, vsColLabels, isKeepColOrder()))
		{
			if(isRowNumberRowAllowed())//getRowNumberRow(false) > 0)
			{
				m_vsColNames.Add(STR_ROW_NUMBER);
				m_vsColLabels.Add(getXFromStepStr());
			}
			m_vsColNames.Append(vsColNames);
			m_vsColLabels.Append(vsColLabels);
		}
		updateListAfterChange(bApplyWks, true);
	}
	void OnChangeAddRowNumbers()
	{
		RemoveSelection();
		updateRowNumbersRow();
		updateColWidths();
	}
	void updateColWidths()
	{
		ResizeCols(4);
	}
	void OnChangeErrBarOptions()
	{
		RemoveSelection();
		setupGridCols();
		updateColNameLabelsAndOtherInfo(false);
		//ResizeCols(4);
		updateDesignations(true);
	}
	/// RVD 9/3/2003 QA70-5078 v7.0682 PLOT_RANGE_APPLY
	//bool GetDataPlots(TreeNode& trPlotList, bool bTestValid = false)
	bool GetDataPlots(TreeNode& trPlotList, bool bTestValid = false, DWORD dwPlotView = DPEDTVIEW_HIDE_LIMITS)
	/// end PLOT_RANGE_APPLY
	{
		vector<uint> vnColDesignations;
		//----- CPY 8/20/03 ADD_PLOT_WRONG_X_AFTER_SORT
		vector<uint> vnPositions;
		getColDesignations(vnColDesignations, vnPositions);
		vector<uint> vnReorderIndexes;
		vnPositions.Sort(SORT_ASCENDING, TRUE, vnReorderIndexes);
		vnColDesignations.Reorder(vnReorderIndexes);
		//-----
		string strSaveRowNumberDisplay;
		int nRow = -1;
		if((nRow = getRowNumberRow()) > 0)
		{
			nRow = 0;//-= m_flx.FixedRows;
			strSaveRowNumberDisplay = m_vsColNames[nRow];// Row# is always at index 0
			m_vsColNames[nRow] = m_vsColLabels[nRow];
			m_vsColLabels[nRow] = "";
		}
		
		if (PCD_LTPLOTINFO_HAS_NEXVAL & m_dwAuxTypeInfo)
		{
			DWORD		dwExValue = m_dwAuxPlotInfo & LTPI_NEXVAL_MASK;
			m_nMakePlotExVal = dwExValue >> NEXVAL_MASK_BITSHIFT_IN_LTPI;
		}
		
		vector<string> vsPagesSave;
		if(bTestValid) // if testing, only need 1st page
		{
			vsPagesSave = m_vsPageNames;
			m_vsPageNames.SetSize(1);
		}
		
		/// RVD 9/3/2003 QA70-5078 v7.0682 PLOT_RANGE_APPLY
		//bool bRet = Project.MakeDataplotsTree(trPlotList, m_nPlotType, m_dwAuxTypeInfo, m_dwAuxPlotInfo, m_strColPattern, m_nMakePlotExVal,
		//	vnColDesignations, m_vsPageNames, m_vsLayerNames, m_vsColNames);
		BOOL bNoLimits = (dwPlotView & DPEDTVIEW_HIDE_LIMITS) ? TRUE : FALSE;
		bool bRet = Project.MakeDataplotsTree(trPlotList, m_nPlotType, m_dwAuxTypeInfo, m_dwAuxPlotInfo, m_strColPattern, m_nMakePlotExVal,
			vnColDesignations, m_vsPageNames, m_vsLayerNames, m_vsColNames, bNoLimits);
		/// end PLOT_RANGE_APPLY

⌨️ 快捷键说明

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