📄 plotsetup.c
字号:
else
nPlotType = 0;
}
return true;
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//
// Main function
// this function is called from inside Origin to bring up the Plot Setups dialog
//
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
BOOL PlotSetup(BOOL bNewPlot = FALSE, int nPlotID = IDM_PLOT_LINE, LPCSTR lpcszTemplate = NULL, HWND hWndParent = NULL)
{
Tree trPlots;
DWORD dwAddPlotCntrl = 0;
if(!bNewPlot) // open from graph window, layer contents
{
//Tree trPage;
GraphPage pg = Project.Pages();
bool bFromLayerContents = 0==nPlotID? true : false;
if ( !get_gpage_plot_contents_and_check_plot_type(pg, trPlots, nPlotID) )
return FALSE;
if(bFromLayerContents)
nPlotID = 0; // this is the only way to indicate that we are from layer contents
if(dwAddPlotCntrl = SelColsPlottingDlg(false, trPlots, nPlotID, 0, hWndParent))
{
apply_plot_list_tree_to_page(pg, trPlots.DataPlots, dwAddPlotCntrl);
return TRUE;
}
return FALSE;
}
//
// from here on, we are making new plots, so no current graph window to be considered, a new graph window is always created
//
string strTemplate = lpcszTemplate; // possible TemplateName:nExval, template name might be followed by int value that specify additional plotting info
int nExVal = 0; // additional plotting info
if(strTemplate.GetLength() > 3) // assume template name of at least 2 chars, like "AB:3"
{
int nExValPos = strTemplate.ReverseFind(':');
if(nExValPos > 1) // to avoid "c:\c\vc32\line.otp"
{
nExVal = atoi(strTemplate.Mid(nExValPos + 1));
strTemplate = strTemplate.Left(nExValPos);
}
}
string strTemplatePath = GetFilePath(strTemplate);
bool bTemplateLib = strTemplatePath.IsEmpty()? false:true;
GraphPage gp;
if(!gp.Create(strTemplate, CREATE_HIDDEN))
return false;
if(bTemplateLib)
nExVal = -1;// nExVal = -1 to indicate template library
if(get_gpage_plot_contents_and_check_plot_type(gp, trPlots, nPlotID))
{
dwAddPlotCntrl = SelColsPlottingDlg(true, trPlots, nPlotID, nExVal, hWndParent);
if(dwAddPlotCntrl && trPlots.DataPlots.IsValid()) // = 0 if user cancel
{
gp.SetShow();
apply_plot_list_tree_to_page(gp, trPlots.DataPlots, dwAddPlotCntrl);
if(dwAddPlotCntrl & ADDPLOTSFROMTREE_NEW)
gp.LT_execute("legend -s");
return true;
}
gp.Destroy();
}
return false;
}
#define OFFSET_WKS_LIST_SUPPORT_ITEMS 1
#define OFFSET_COL_LIST_SUPPORT_ITEMS 4
#define OFFSET_COL_LIST_LAYER_CONTENTS 1
static uint s_nWksListCntrlIDs[] = {IDC_SELCOLS_WKSTREE, IDC_SELCOLS_AVAILABLE_DATA_LABEL, IDC_SELCOLS_AVAILABLE_DATA, IDC_SELCOLS_APPLY_WKS_LABEL, 0};//IDC_SELCOLS_APPLY_WKS, 0};
static uint s_nColListCntrlIDs[] = {IDC_SELCOLS_SHOW_PLOTS, IDC_SELCOLS_SHOW_DATA, IDC_SELCOLS_COLS_LABEL, IDC_SELCOLS_COLS, IDC_SELCOLS_PLOT_TYPES_LABEL, IDC_SELCOLS_PLOT_TYPES,0};//, IDC_SELCOLS_X_ERR, IDC_SELCOLS_POS_NEG_ERR, IDC_SELCOLS_ADD_ROW_NUMBER, 0};
//-------- CPY 8/18/03 AUTO_ENTER_EDIT_WHEN_DATAPLOT_SELECTED
//static uint s_nCntrlButtons[] = {IDC_SELCOLS_ADD, IDC_SELCOLS_REPLACE, IDC_SELCOLS_EDIT, 0};
static uint s_nCntrlButtons[] = {IDC_SELCOLS_ADD, IDC_SELCOLS_REPLACE, 0};
//-------- end
//static uint s_nCntrlButtonsShowPlotList[] = {IDC_SELCOLS_SHOW_PLOTS, IDC_SELCOLS_ADD, IDC_SELCOLS_REPLACE, IDC_SELCOLS_EDIT, 0};
static uint s_nCntrlButtonsShowPlotList[] = {IDC_SELCOLS_SHOW_PLOTS, IDC_SELCOLS_ADD, IDC_SELCOLS_REPLACE, 0};
static uint s_nCtrlsVertResize[] = {IDC_SELCOLS_WKSTREE, IDC_SELCOLS_COLS, IDC_SELCOLS_PLOTS, 0};
#define TOTAL_NUM_OF_PANELS 3
#define IDC_SELCOLS_SHOW_COLS IDC_SELCOLS_SHOW_PLOTS
//--- CPY 9/26/03 EDIT_PLOT_SHOW_HIGHLIGHT_IN_WKS_LIST
// m_bReady replaced by m_nReadyState
enum {STATE_NOT_READY, STATE_READY, STATE_WAIT_READY};
//---
////////////////////////////////////////////////////////
// class SelColsForPlottingDlg
////////////////////////////////////////////////////////
class SelColsForPlottingDlg : public ResizeDialog
{
public:
SelColsForPlottingDlg(bool bNewPlot, TreeNode& trPlotList, int nPlotID = 0, int nExVal = 0) : ResizeDialog(IDD_SEL_COLS_PLOTTING, "ODlg")
{
m_bTemplateLib = false;
m_bFromColList = false;
if(nExVal < 0)
{
m_bTemplateLib = true;
m_nMakeNewPlotExVal = 0;
}
else
m_nMakeNewPlotExVal = nExVal; // for additional control info when making new plot
m_bMakeNewPlot = bNewPlot;
m_bAddToGraph = false;
if(nPlotID > 0)
{
m_nPlotIDCaller = nPlotID;
if(!bNewPlot)
m_bAddToGraph = true;
}
m_nReadyState = STATE_NOT_READY;
m_trCallerPlotList = trPlotList;
m_bApplyWasDone = false;
}
DWORD DoModalEx(HWND hParent)
{
DWORD dwRet = m_bMakeNewPlot? ADDPLOTSFROMTREE_NEW | ADDPLOTSFROMTREE_RESCALE: ADDPLOTSFROMTREE_EDIT;
InitMsgMap();// will be called from internal later
int nRet = DoModal(hParent);
if(IDOK == nRet)
{
if (m_bFromColList)
dwRet |= ADDPLOTSFROMTREE_IMPLICIT_STYLEHOLDERS;
return dwRet;
}
return 0;
}
protected:
uint GetCurrentPlotID(DWORD& dwAuxTypeInfo)
{
return m_cntrlPlotTypes.GetCurrentPlotType(dwAuxTypeInfo);
}
///----------------- Message Map ----------------
EVENTS_BEGIN
ON_INIT(OnInitDialog)
ON_OK(OnOK)
ON_DESTROY(OnDestroy)
ON_BN_CLICKED(IDC_SELCOLS_SHOW_DATA, OnCheckShowWks)
ON_BN_CLICKED(IDC_SELCOLS_SHOW_PLOTS, OnCheckShowPlots)
ON_BN_CLICKED(IDC_SELCOLS_X_ERR, OnChangeErrBarOptions)
ON_BN_CLICKED(IDC_SELCOLS_POS_NEG_ERR, OnChangeErrBarOptions)
ON_BN_CLICKED(IDC_SELCOLS_ADD_ROW_NUMBER, OnChangeAddRowNumbers)
ON_BN_CLICKED(IDC_SELCOLS_APPLY_WKS, OnApplyWksDesignations)
ON_BN_CLICKED(IDC_SELCOLS_ADD, OnAdd)
// ON_BN_CLICKED(IDC_SELCOLS_EDIT, OnEdit)
// ON_BN_CLICKED(IDC_SELCOLS_REPLACE, OnReplace)
ON_BN_CLICKED(IDC_APPLY, OnApply) //CPY 9/16/03
ON_CBN_SELCHANGE(IDC_SELCOLS_AVAILABLE_DATA, OnAvilableDataComboChange)
ON_CBN_SELCHANGE(IDC_SELCOLS_PLOTS, OnDataPlotSelChange)
//--- WM_USER
ON_USER_MSG(WM_USER_ON_CONTROL_CHANGE, OnControlChange)
ON_USER_MSG(WM_USER_RESIZE_CONTROLS, OnIncreaseDecreasePanelSize)
//--- vsFlex realted
ON_GRID_BUTTON_CLICK(IDC_SELCOLS_COLS, OnButtonClickColList)
ON_GRID_BEFORE_EDIT(IDC_SELCOLS_COLS, OnBeforeEditColList)
ON_GRID_AFTER_EDIT(IDC_SELCOLS_COLS, OnAfterEditColList)
ON_GRID_BEFORE_MOUSE_DOWN(IDC_SELCOLS_COLS, OnBeforeMouseDownColList)
ON_GRID_MOUSE_MOVE(IDC_SELCOLS_COLS, OnMouseMoveColList)
ON_GRID_SEL_CHANGE(IDC_SELCOLS_WKSTREE, OnWksSelChange)
ON_GRID_BEFORE_MOUSE_DOWN(IDC_SELCOLS_WKSTREE, OnBeforeMouseDownWksList)
ON_GRID_SEL_CHANGE(IDC_SELCOLS_PLOT_TYPES, OnPlotTypeChange)//---- CPY 7/30/03 PLOT_TYPE_LIST_SEL_SUPPORT
//---
/// TD 8-26-03 RESIZING
ON_SIZE(OnResize)
ON_GETMINMAXINFO(OnMinMaxInfo)
/// ----TD 8-26-03 RESIZING
ON_INIT_SIZE(OnInitSize)
EVENTS_END
///----------------------------------------------
///////////////////////////////////////////////////////
/// Event Handlers
///////////////////////////////////////////////////////
BOOL OnInitDialog()
{
//waitCursor junk;
PROFILE_HRGLASS
/// RVD 9/3/2003 QA70-5078 v7.0682 PLOT_RANGE_APPLY
//string strRegForDlgInfo = "PlotSetupDlg"; //"SelColsForPlottingDlg";
string strRegForDlgInfo = STR_PLOT_SETUP_DLG;
/// end PLOT_RANGE_APPLY
ResizeDialog::OnInitDialog();
initUpDownShowButtons();
m_cntrlPlotTypes.Init(IDC_SELCOLS_PLOT_TYPES, IDC_SELCOLS_PLOT_TYPES_STYLEHOLDER, *this);
m_cntrlCols.Init(IDC_SELCOLS_COLS, *this, m_nPlotIDCaller, strRegForDlgInfo, m_nMakeNewPlotExVal, IDC_SELCOLS_X_ERR, IDC_SELCOLS_POS_NEG_ERR, IDC_SELCOLS_ADD_ROW_NUMBER, IDC_SELCOLS_COLS_LABEL, IDC_SELCOLS_SHOW_ALL_COLS);
//m_cntrlPlotTypes.SetPlotType(m_cntrlCols.GetPlotType(), m_nPlotIDCaller, m_nMakeNewPlotExVal);
DWORD dwAuxTypeInfo = 0;
int nPlotType = m_cntrlCols.GetPlotType(&dwAuxTypeInfo);
m_cntrlPlotTypes.SetPlotType(nPlotType, m_nPlotIDCaller, dwAuxTypeInfo, m_nMakeNewPlotExVal);
m_cntrlWks.Init(IDC_SELCOLS_WKSTREE, *this, m_bMakeNewPlot, strRegForDlgInfo, IDC_SELCOLS_APPLY_WKS, IDC_SELCOLS_AVAILABLE_DATA);
m_cntrlPlots.Init(IDC_SELCOLS_PLOTS, *this);
if(!m_trCallerPlotList.DataPlots.IsValid())
init_tree_num_layers(m_trCallerPlotList, m_cntrlCols.GetNumLayers());
m_cntrlPlots.SetTree(m_trCallerPlotList);
m_staticAvailDataLabel = GetItem(IDC_SELCOLS_AVAILABLE_DATA_LABEL);
m_staticPlotListLabel = GetItem(IDC_SELCOLS_PLOTS_LABEL);
m_btnAddReplacePlot = GetItem(IDC_SELCOLS_ADD);
m_btnOK = GetItem(IDOK);
m_btnApply = GetItem(IDC_APPLY);
//------ CPY 9/6/03 v7.5686 RESIZEING_CLEAN_UP
/*
//// save the group size so we can resize the whole dialog
RECT r1;
m_cntrlWks.GetRect(r1);
m_nWksListGroupHeight = r1.bottom;
m_cntrlCols.GetRect(r1);
m_nPlotListGroupHeight = GetDlgExtent() - r1.bottom;
m_nColListGroupHeight = RECT_HEIGHT(r1);
*/
//m_comboPlotTypes = GetItem(IDC_SELCOLS_PLOT_TYPES);
//m_btnEditPlot = GetItem(IDC_SELCOLS_EDIT);
//m_btnReplacePlot = GetItem(IDC_SELCOLS_REPLACE);
//--- use diff reg section as the settings might have diff preferences between these cases
string strRegSection = "LayerContentsDlg";
if(m_bMakeNewPlot)
strRegSection = strRegForDlgInfo;
//---
ResizeDialog::LoadCheckBoxSettings(strRegSection, IDC_SELCOLS_SHOW_DATA, IDC_SELCOLS_SHOW_PLOTS, IDC_SELCOLS_X_ERR, IDC_SELCOLS_POS_NEG_ERR, IDC_SELCOLS_ADD_ROW_NUMBER, IDC_SELCOLS_APPLY_WKS, IDC_SELCOLS_SHOW_ALL_COLS);
if(m_bAddToGraph)
{
m_chkShowWks.Check = true;
m_chkShowPlots.Check = true;
}
else if(m_bTemplateLib)
m_chkShowPlots.Check = true;
showWksListGroup(isAvailDataListShown());
//----CPY 8/19/03, show order important, otherwise can seem like bad drawing of dialog, old code always show/hide PlotList, then follow by ColList
if(isColListShown())
{
showPlotListGroup(isPlotListShown());
showColListGroup(true);
}
else
{
showColListGroup(false);
showPlotListGroup(isPlotListShown());
// temp
m_cntrlPlotTypes.SetVisible(false);
}
//----
m_cntrlWks.OnReady(getAvailDataListLastChoice(), m_bMakeNewPlot, dwAuxTypeInfo);// if making new plot, then sel current wks
m_cntrlPlotTypes.OnReady(dwAuxTypeInfo, m_cntrlWks.GetCurrentPageType());
/// RVD 9/3/2003 QA70-5078 v7.0682 PLOT_RANGE_APPLY
DWORD dwView = 0;
if( dlg_load_registry(STR_PLOT_SETUP_DLG, STR_PLOT_VIEW, dwView) )
m_cntrlPlots.OnReady(m_bMakeNewPlot, m_bTemplateLib, dwView);
else
/// end PLOT_RANGE_APPLY
m_cntrlPlots.OnReady(m_bMakeNewPlot, m_bTemplateLib);
m_cntrlCols.OnReady();
if(!isAvailDataListShown())
m_cntrlCols.UpdateList();
if(m_bMakeNewPlot)
{
m_wndDlg.Text = SCP_DLG_TITLE_LEFT_NEW_PLOT;// + getCurrentPlotType();
}
else
m_wndDlg.Text = SCP_DLG_TITLE_LEFT_LAYER_CONTENTS;
//if ( m_btnEditPlot )
// m_btnEditPlot.Enable = FALSE;
//if ( m_btnReplacePlot )
// m_btnReplacePlot.Enable = FALSE;
//--- CPY 9/6/03 v7.5686 RESIZEING_CLEAN_UP
AddPanel(&m_cntrlWks);
AddPanel(&m_cntrlCols);
AddPanel(&m_cntrlPlots);
LoadSizeOfPanels();
//--- end CPY 9/6/03 v7.5686 RESIZEING_CLEAN_UP
m_nReadyState = STATE_READY;
enableOKbutton(false);// CPY, startup with OK disabled, must have proper settings to enable
return TRUE;
}
BOOL OnInitSize(int &left, int &top, int &right, int &bottom)
{
RECT rect;
rect.left =left;
rect.top =top;
rect.right =right;
rect.bottom =bottom;
repositionPanels(true, false, &rect);
return FALSE;
}
BOOL OnIncreaseDecreasePanelSize(uint wParam, uint lParam)
{
if(ResizeDialog::OnIncreaseDecreasePanelSize(wParam, lParam))
{
repositionPanels();
}
return TRUE;
}
BOOL OnResize(int nType, int cx, int cy)
{
if(ResizeDialog::OnResize(nType, cx, cy))
repositionPanels();
return TRUE;
}
BOOL OnAvilableDataComboChange( Control ctrl )
{
m_cntrlWks.OnAvilableDataComboChange();
return TRUE;
}
BOOL OnDataPlotSelChange(Control ctrl )
{
//-------- CPY 8/18/03 AUTO_ENTER_EDIT_WHEN_DATAPLOT_SELECTED
//if ( m_btnEditPlot )
//{
// BOOL bEnableEdit = m_cntrlPlots.IsEditAllowed();
// m_btnEditPlot.Enable = bEnableEdit;
//}
//m_cntrlPlots.OnSelChange(m_cntrlPlotTypes);
if(!isReadyEventHandling(true))
return TRUE;
//---- CPY 9/9/03 WKS_1000_COLS_TOO_SLOW
if(m_cntrlPlots.IsSelSameRow())
return TRUE;
//----
m_cntrlPlots.EndEdit(m_cntrlCols);
checkStartEdit();
return TRUE;
}
BOOL OnControlChange(uint wParam, uint lParam)
{
// we may get here from some other internal PostMessage, so check if lParam=NULL to avoid those,
// sinice lparam is typically hWnd if posted internally
/// RVD 8/25/2003 QA70-5042 v7.0674 DATAPLOT_LIMITS_DISPLAY
//if(0== lParam && ON_CONTROL_CHANGE_COL_DESIGNATIONS == wParam)
if( lParam )
{
short shMsg = LOWORD(wParam);
if (shMsg <= 0)
{
if(ONCTRLCHNG_DELETE_ROWS == shMsg)
{
short shRow = HIWORD(wParam);
OnRemove(shRow);// need to change 1 to layer Row
}
return TRUE;
}
m_cntrlPlots.UpdateDataPlotLimits(wParam);
}
else if( ON_CONTROL_CHANGE_COL_DESIGNATIONS == wParam )
/// end DATAPLOT_LIMITS_DISPLAY
{
//m_btnAddReplacePlot.Enable = m_cntrlCols.IsReadyAddReplacePlot();
enablePlottingButton();
}
return TRUE;
}
BOOL OnOK()
{
if(isPlotListShown())
{
m_bFromColList = false;
m_cntrlPlots.GetTree(m_trCallerPlotList);
// call to make plot
}
else // no need to get from control, directly make plot
{
Tree trLayer;
m_bFromColList = true;
m_cntrlCols.GetDataPlots(trLayer);
m_trCallerPlotList.DataPlots.Layer0.XML = trLayer.Layer.XML;
}
return TRUE;
}
BOOL OnApply(Control cntrl)
{
m_bFromColList = false;
Tree trTemp;
m_cntrlPlots.GetTree(trTemp);
if(trTemp.DataPlots.IsValid())
{
GraphPage pg = Project.Pages();
DWORD dwApplyFlags = ADDPLOTSFROMTREE_EDIT;
apply_plot_list_tree_to_page(pg, trTemp.DataPlots, dwApplyFlags);
// we need to update the layer contents after apply, so the correct tree is in the PlotList
Tree trPlots;
gpage_get_plots(pg, trPlots);
m_cntrlPlots.EndEdit(m_cntrlCols);
updateGUIOnEditReplace(FALSE);
m_cntrlPlots.SetTree(trPlots);
m_bApplyWasDone = true;
}
return TRUE;
}
BOOL OnDestroy()
{
/// RVD 9/3/2003 QA70-5078 v7.0682 PLOT_RANGE_APPLY
dlg_save_to_registry(STR_PLOT_SETUP_DLG, STR_PLOT_VIEW, m_cntrlPlots.GetView());
/// end PLOT_RANGE_APPLY
saveAvailDataListLastChoice(m_cntrlWks.GetAvailableDataChoice());
SaveCheckBoxSettings();
SaveSizeOfPanels();
return TRUE;
}
BOOL OnAdd(Control cntrl)
{
if(m_cntrlCols.IsInEditMode())
{
//updateGUIOnEditReplace(FALSE); CPY 9/3/03 this is removed since Replace will no longer change selection after Marko changed in TreeEditor
return doAddOrReplace(TRUE);
}
doAddOrReplace();
m_cntrlCols.ClearAllDesignations();
return TRUE;
}
void OnRemove(int nRowToSel)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -