📄 coldesignations.h
字号:
if(bTestValid) // if testing, only need 1st page, now restore
m_vsPageNames = vsPagesSave;
if(nRow >= 0)
{
m_vsColLabels[nRow] = m_vsColNames[nRow];
m_vsColNames[nRow] = strSaveRowNumberDisplay;
}
return bRet;
}
private:
bool isValidColDesignations()
{
Tree trTemp = NULL;
return GetDataPlots(trTemp, true);
}
int guessPageType(LPCSTR lpcszName)
{
Page pg(lpcszName);
if(pg)
return pg.GetType();
return EXIST_DATA;
}
bool updateRowNumberXFromAndStep(bool bCheckShowRow = false)
{
int nRow = getRowNumberRow();
if(nRow > 0 && getFromStepColIndex() > 0)
{
int ii = getRowNumberRowArrayIndex(); //nRow - m_flx.FixedRows;
m_vsColLabels[ii] = getXFromStepStr();
//----- CPY 8/17/03 ROW_NUMBER_ROW_IMPROVEMENT
//m_flx.TextMatrix(nRow, m_nLabelCol) = m_vsColLabels[ii];
if(m_n1stDataValCol > 0)
m_flx.TextMatrix(nRow, getFromStepColIndex()) = m_vsColLabels[ii];
//-----
if(bCheckShowRow && !m_chkAddRowNumX.Check)
{
m_chkAddRowNumX.Check = true;
HideRow(nRow, false);
}
return true;
}
return false;
}
bool updateRowNumbersRow()
{
int nRow = findRowNumberRow();
if(nRow < 0 && !isRowNumberRowAllowed())
return false; // consistent, nothing to do
if(nRow && !isRowNumberRowAllowed()) // was added before, we need to just hide it
m_chkAddRowNumX.Check = false;
else if(nRow < 0) // no such row, so does not matter
return false;
if(m_chkAddRowNumX.Check)
{
updateDesigationRadio(nRow);
//m_flx.RowHidden(nRow) = false;
HideRow(nRow, false);
}
else
{
setDesignationRadioChoice(nRow, COLDESIG_NONE);
//m_flx.RowHidden(nRow) = true;
HideRow(nRow, true);
}
return true;
}
void updateListAfterChange(bool bApplyWks, bool bResetDesigationRadio, bool bResetGrid = false)
{
HOUR_GLASS
if(bResetGrid)
setupGridCols();
updateColNameLabelsAndOtherInfo(bResetDesigationRadio);
updateShowColsRows();
if(bApplyWks)
ApplyWksColDesignations();
//ResizeCols(4);
updateDesignations(true);
notifyDlgOnDesignationChanges();
if(isAllowSortCols())
m_flx.ExplorerBar = flexExSortShow;
else
m_flx.ExplorerBar = flexExNone;
}
void updateColNameLabelsAndOtherInfo(bool bResetDesigationRadio = true)
{
int nFixedRows = m_flx.FixedRows;
m_flx.Rows = nFixedRows + m_vsColNames.GetSize();
for(int ii = 0, nRow = nFixedRows; ii < m_vsColNames.GetSize(); ii++, nRow++)
{
if(bResetDesigationRadio)
m_flx.RowData(nRow) = COLDESIG_NONE;
m_flx.TextMatrix(nRow, m_nNameCol) = m_vsColNames[ii];
if(m_nLabelCol > 0)
{
if(getRowNumberRow() == nRow)
m_flx.TextMatrix(nRow, m_nLabelCol) = STR_ROWNUM_ROW_LABEL; //----- CPY 8/17/03 ROW_NUMBER_ROW_IMPROVEMENT
else
m_flx.TextMatrix(nRow, m_nLabelCol) = m_vsColLabels[ii];
}
if(m_nIndexCol > 0)
m_flx.TextMatrix(nRow, m_nIndexCol) = getColPositionInWks(ii, m_vsColNames[ii]);
if(m_n1stDataValCol > 0)
m_flx.TextMatrix(nRow, m_n1stDataValCol) = get1stDataVal(m_vsColNames[ii]);
}
}
void updateShowColsRows()
{
bool bIsShowAll = m_chkShowAllCols.Check;
int nFixedRows = m_flx.FixedRows;
for(int ii = 0, nRow = nFixedRows; ii < m_vsColNames.GetSize(); ii++, nRow++)
{
if(bIsShowAll || !isWksColHiddenOrDisregard(m_vsColNames[ii]))
HideRow(nRow, false);
else
{
HideRow(nRow, true);
m_flx.RowData(nRow) = COLDESIG_NONE;
}
}
updateRowNumbersRow();// must do this after updateShowAllCols which also HideShowRows
}
void countYs()
{
m_nYs = 0;
m_nModifiers = 0;
int nPos = m_strColPattern.Find('Y');
while(nPos >= 0)
{
m_nYs++;
nPos = m_strColPattern.Find('Y', nPos + 1);
}
// not all plot IDs has correct string, so some needed correction
if(PCD_EXACT_ONE_GROUP & m_dwAuxTypeInfo) // the rest are modifiers
{
m_nYs = 1;
m_nModifiers = 2;// XYXY, may need to be more general later
}
}
bool hasEnoughYs(int nYs)
{
if(nYs < 1)
return false;
if(IS_PCD_EXACT_Y_COLS(m_dwAuxTypeInfo) && nYs != m_nYs)
return false;
if(IS_PCD_EXACT_Y_COLS_OR_ONE_LESS(m_dwAuxTypeInfo) && (nYs < m_nYs -1 || nYs > m_nYs))
return false;
return true;
}
bool hasTooManyYs(int nYs)
{
if(!IS_PCD_EXACT_Y_COLS_OR_MORE(m_dwAuxTypeInfo) && nYs > m_nYs)
return true;
return false;
}
void updatePlotType(int nNewPlotID, int nPageType, DWORD dwLayerBits = 0)
{
//---- CPY 9/9/03 v7.5689 TERNARY_PLOT_USE_2D_TYPES
//printf("id %d, dw %d, nLayer = %d\n", nNewPlotID, dwLayerBits, HIWORD(dwLayerBits));
/*
if(nNewPlotID)
m_nPlotType = Project.GetPlotTypeInfo(nNewPlotID, m_dwAuxTypeInfo, m_dwAuxPlotInfo, m_strColPattern);
if(nPageType)
{
if(EXIST_DATA == nPageType || EXIST_FUNC_PLOT == nPageType)
m_dwAuxTypeInfo &= ~PCD_CAN_ADD_E_H_L;
if(EXIST_FUNC_PLOT == nPageType)
m_dwAuxTypeInfo |= PCD_NO_X;
}
if (PCD_LAYER_TRI == dwLayerBits)
m_dwAuxTypeInfo = PCD_LAYER_TRI | PCD_EXACT_YCOLS | PCD_Z_PREFER_Y | PCD_GROUP_MULTI_YS | PCD_PREFER_X | PCD_CAN_ADD_E_H_L | PCD_HIDE_ERR_BARS;
else if (PCD_LAYER_SMITH == dwLayerBits)
m_dwAuxTypeInfo |= PCD_HIDE_ERR_BARS;
*/
//nNewPlotID can be 0, and get_plot_type_info will fix other bits, change m_nPlotType only if nNewPlotID is not zero
int nn = get_plot_type_info(nNewPlotID, nPageType, dwLayerBits, m_dwAuxTypeInfo, m_dwAuxPlotInfo, m_strColPattern);
if(nn)
{
m_nPlotType = nn;
countYs();
}
//----
}
void setupGridCols()
{
updateErrBarOptions();
// out_int("Plot type = ", m_nPlotType);
if(!Project.GetPlotDesignations(m_nPlotType, m_dwAuxTypeInfo, m_strColPattern, m_vnColDesignations))
m_vnColDesignations.SetSize(0);
prepareGridColumns();
}
void updateErrBarOptions()
{
m_dwAuxTypeInfo &= ~(PCD_SHOW_X_ERR | PCD_SHOW_POS_NEG_ERR);
if(IsAllowErrbars())//(m_dwAuxTypeInfo & PCD_CAN_ADD_E_H_L)
{
if(m_chkXErrBars.Check)
m_dwAuxTypeInfo |= PCD_SHOW_X_ERR;
if(m_chkPosNegErrBars.Check)
m_dwAuxTypeInfo |= PCD_SHOW_POS_NEG_ERR;
}
}
void updateDesignations(bool bResizeCols = false)
{
int nR1 = m_flx.FixedRows;
int nR2 = m_flx.Rows;
for(int nRow = nR1; nRow < nR2; nRow++)
updateDesigationRadio(nRow);
if(bResizeCols)
updateColWidths();
}
void updateDesigationRadio(int nRow) // update check box according to RowData
{
int nDesig = m_flx.RowData(nRow);
int nRadioChoice = getDesignationRadioChoice(nDesig);
for(int nCol = m_nRadioColBegin, nRadio = 0; nCol <= m_nRadioColEnd; nCol++, nRadio++)
{
if(nRadioChoice == nRadio)
m_flx.TextMatrix(nRow, nCol) = 1;
else
m_flx.TextMatrix(nRow, nCol) = 0;
}
if(nDesig != COLDESIG_NONE && isSingleDesignation(nDesig))
checkSingleDesignationForAllRows(nRow, nDesig);
}
//only 1 X is allowed, we may relax this later
checkSingleDesignationForAllRows(int nRowNewChange, int nDesignationToCheck)
{
int nDesig = m_flx.RowData(nRowNewChange);
if(nDesignationToCheck == nDesig)
{
int nR1 = m_flx.FixedRows;
int nR2 = m_flx.Rows;
int nD;
for(int nRow = nR1; nRow < nR2; nRow++)
{
if(nRowNewChange == nRow)
continue;
nD = m_flx.RowData(nRow);
if(nDesignationToCheck == nD)
{
m_flx.RowData(nRow) = COLDESIG_NONE;
updateDesigationRadio(nRow);
}
}
}
}
bool isAllowSortCols()
{
DWORD dwModifierBits = PCD_MODIFIER_SIZE|PCD_MODIFIER_COLOR|PCD_MODIFIER_VEC_AM|PCD_MODIFIER_VEC_XYEND;
if(m_dwAuxTypeInfo & dwModifierBits)
return false;
//---- CPY 9/10/03 v7.5690 HI_LO_CLOSE_FLOAT_COLS
if(m_nYs > 1 && (m_dwAuxTypeInfo & PCD_EXACT_YCOLS))
return false;
//----
return true;
}
bool isSingleDesignation(int nDesig) // between rows in table
{
if(COLDESIG_X == nDesig)
return true;
if(nDesig >= COLDESIG_SIZE) // all modifier does not make sense to have more then one
return true;
if(m_dwAuxTypeInfo & PCD_EXACT_ONE_GROUP)
return true;
return false;
}
int getFromStepColIndex()
{
return m_n1stDataValCol;
}
string getXFromStepStr()
{
string str;
cvt_x_from_step_to_str(m_RowNumberXFrom, m_RowNumberXStep, str.GetBuffer(MAXLINE), MAXLINE);
str.ReleaseBuffer();
return str;
}
bool setXFromStepStr(LPCSTR lpcsz, bool bCheckShowRow = true) // must be in the form of 123/456
{
string str = lpcsz;
int nPos = str.Find('/');
if(nPos > 0 && nPos < str.GetLength())
{
string strFrom = str.Left(nPos);
string strStep = str.Mid(nPos+1);
m_RowNumberXFrom = atof(strFrom);
m_RowNumberXStep = atof(strStep);
updateRowNumberXFromAndStep(bCheckShowRow);
return true;
}
return false;
}
int getRowNumberRowArrayIndex()
{
return 0; // this should never changed
}
bool isRowNumberRowAllowed()
{
return (m_dwAuxTypeInfo & PCD_NO_X) || ( m_dwAuxTypeInfo & PCD_ONLY_ONE_Z)? false:true;
}
int findRowNumberRow()
{
return FindRow(STR_ROW_NUMBER, m_nNameCol);
}
int getRowNumberRow(bool bCheckSort = true)
{
// there is some inconsistency sometimes, so PCD_NO_X is not always present
if(!isRowNumberRowAllowed())
return -1;
//----- CPY 8/20/03, Row# row can be sorted out
if(bCheckSort && isAllowSortCols())
return findRowNumberRow();
else
return m_flx.FixedRows;
//-----
}
bool isXCol(int nCol)
{
if(!isColDesignationInList(COLDESIG_X))
return false;
// if X, must be 1
if(1==nCol)
return true;
return false;
}
int getDesignationRadioChoice(int nDesignation)
{
int nRadioChoice = 0;
for(int ii = 0; ii < m_vnColDesignations.GetSize(); ii++)
{
if(nDesignation == m_vnColDesignations[ii])
{
nRadioChoice = ii + 1;// disregard not in designation list
break;
}
}
return nRadioChoice;
}
int getDesignationOfCol(int nCol) // return -1 if not one of Col Designations Cols
{
// disregard not in designation list
if(nCol > m_vnColDesignations.GetSize())
return -1;
if(0 == nCol)
return COLDESIG_NONE;
return m_vnColDesignations[nCol-1];
}
bool setDesignation(int nRow, int nDesig, bool bCheckInList = true)
{
if(bCheckInList && !isColDesignationInList(nDesig))
return false;
m_flx.RowData(nRow) = nDesig;
return true;
}
bool setDesignationRadioChoice(int nRow, int nChoice)
{
int nDesig = COLDESIG_NONE;
if(nChoice > 0 && nChoice <= m_vnColDesignations.GetSize())
nDesig = m_vnColDesignations[nChoice-1];
//--- CPY 9/15/03, SET_ALL_TO_TOP_NO_PLOT
if(getRowNumberRow() == nRow && nDesig > COLDESIG_X)
return false;
//---
int nOldDesignation = getColDesignation(nRow);
//m_flx.RowData(nRow) = nDesig;
setDesignation(nRow, nDesig, false);
if(nChoice)
{
if(!isValidColDesignations())
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -