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

📄 graph.h

📁 图像处理的压缩算法
💻 H
📖 第 1 页 / 共 5 页
字号:

	

	/**#
		Add one data plot to layer by using the existing styleholder. The styleholder
		is usually used in templates to determine the type and other properties of
		a dataplot which uses the styleholder when being added to a layer.
	Parameters:
		cData = Data curve to add
		style = the style holder to use when creating the dataplot
	Example:
		// For this example to run, a graph window with the name "Graph1" must exist in the project.
		// Also, a workseet with the name "Data1" and with columns "A" and "B" must
		// exist with some numeric data in them.
		void	run_AddPlot()
		{
			// Construct the Curve object specifying the x and y datasets to be used for
			// the dataplot
			Curve		cc("Data1_a", "Data1_b");
			
			// the graph layer needs to be initialized:
			GraphLayer	lay("Graph1");
			
			// Get the first style holder in the layer.
			StyleHolder style;
			style = lay.StyleHolders(0); 
			
			// Check that the style holder is valid:
			if (!style.IsValid())
			{
				out_str("No style holders found!");
				return;
			}
			
			// Add the dataplot to the graph:
			int			nIndex = lay.AddPlot(cc, style);
			
			// Display the index of the data plot just added:
			out_int("Dataplot index = ", nIndex);
		}
	*/
	int AddPlot(Curve& cData, StyleHolder& style);

	/**
		Add entire worksheet to layer.
	Parameters:
		wks = worksheet object containing all data.
		nPlotID = the internal Origin plot type id.
	Return:
		0-offset data plot index of the dataplot added or -1 for error.
	Example:
		// For this example to run, a graph window with the name "Graph1" must exist in the project.
		// Also, a workseet with the name "Data1" must exist with some numeric data.

		void run_AddPlot2()
		{
			GraphLayer gl("Graph1");
			Worksheet wks("Data1");
			gl.AddPlot(wks);
		}
	*/
	int AddPlot(Worksheet& wks, int nPlotID = IDM_PLOT_UNKNOWN);
	
	/**
		Adds an error bar plot to an existing dataplot.
	Parameters:
		cData = Data curve to add the error bar to
		dsErrBar = the dataset to be used as errorbar
		colErrBar = the Data curve to be used as error bar
	Returns:
		the index of the added error bar dataplot in layer, or -1 if failed.
	Example:
		// For this example to run, a graph window with the name "Graph1" must exist in the project.
		// Also, a workseet with the name "Data1" and with columns "A" and "B" and another column
		// (the third column) must exist with some numeric data in them. The graph
		// window should contain one dataplot (such as scatter plot) 
		// which uses the workseet's "B" column as Y-column and "A" column as X-column.
		// After the function executes, the third column of the worksheet will be used
		// for error bars (the graph may need to be refreshed to see the error bars).
		void	run_GraphLayer_AddErrBar()
		{
			GraphLayer		lay("Graph1");
			
			// a dataplot in the layer that uses Data1_b as Y and Data1_a as X
			Curve			cc("Data1_a", "Data1_b");
			
			// use the third column in the worksheet "Data1" for error bar:
			Column	colErrBar("Data1", 2);		
			int				nPlotIndex = lay.AddErrBar(cc, colErrBar);
			out_int("nPlotIndex = ", nPlotIndex);
		}
	*/
	int AddErrBar(Curve& cData, Column &colErrBar);
	/**
	Example:
		This example adds an error bar plot to an existing dataplot. 
		For this example to run, a graph window with the name "Graph1" must exist in the project.
		Also, a workseet with the name "Data1" and with columns "A" and "B" and "C" must exist 
		with some numeric data in them. The graph window should contain one dataplot which uses 
		the workseet's "B" column as Y-column and "A" column as X-column. (the graph may need 
		to be refreshed to see the error bars).
			
		void test_GraphLayer_AddErrBar()
		{
			GraphLayer glMyLayer("Graph1");
			Curve crvMyCurve("Data1_a","Data1_b");
			Dataset dsErrBar("Data1_c");
			int iPlotIndex = glMyLayer.AddErrBar(crvMyCurve, dsErrBar);
			if (iPlotIndex==-1)
				printf("ErrBar Plotting Error!");
			else
				printf("Errbar added successfully!");
		}
	*/
	int AddErrBar(Curve& cData, Dataset &dsErrBar);
	
	/**
		Adds an X error bar plot to an existing dataplot.
	Parameters:
		cData = Data curve to add the X error bar to
		dsXErrBar = the dataset to be used as X error bar
		colXErrBar = the Data curve to be used as X error bar
	Returns:
		the index of the the added X error bar dataplot in layer, or -1 if failed.
	Example:
		// For this example to run, a graph window with the name "Graph1" must exist in the project.
		// Also, a workseet with the name "Data1" and with columns "A" and "B" and another column
		// (the third column) must exist with some numeric data in them. The graph
		// window should contain one dataplot (such as scatter plot) 
		// which uses the workseet's "B" column as Y-column and "A" column as X-column.
		// After the function executes, the third column of the worksheet will be used
		// for X error bars (the graph may need to be refreshed to see the error bars).
		void	run_GraphLayer_AddXErrBar()
		{
			GraphLayer		lay("Graph1");
			
			// a dataplot in the layer that uses Data1_b as Y and Data1_a as X
			Curve			cc("Data1_a", "Data1_b");
			
			// use the third column in the worksheet "Data1" for X error bar:
			Column	colErrBar("Data1", 2);		
			int				nPlotIndex = lay.AddXErrBar(cc, colErrBar);
			out_int("nPlotIndex = ", nPlotIndex);
		}
	*/
	int AddXErrBar(Curve& cData, Column &colXErrBar);
	/**
	Example:
		For this example to run, a graph window with the name "Graph1" must exist in 
		the project. Also, a workseet with the name "Data1" and with columns "A" and 
		"B" and "C" must exist with some numeric data in them. The graph window should 
		contain one dataplot which uses the workseet's "B" column as Y-column and "A" 
		column as X-column. After the function executes, the graph may need to be 
		refreshed to see the error bars.
		
		void test_Graphlayer_AddXErrBar()
		{
			GraphLayer glMyLayer("Graph1");
			Curve crvMyCurve("Data1_a","Data1_b");
			Dataset dsXErrBar("Data1_c");
			int iPlotIndex = glMyLayer.AddXErrBar(crvMyCurve, dsXErrBar);
			if (iPlotIndex==-1)
				printf("X ErrBar Plotting Error!");
			else
				printf("X Errbar added successfully!");
		}
	*/
	int AddXErrBar(Curve& cData, Dataset &dsXErrBar);
	
	/**
		Adds a label plot to an existing dataplot.
	Parameters:
		cData = Data curve to add the label plot to
		dsLabel = the dataset to be used as labels
		colLabel = the Data curve to be used as label column 
	Example:
		// For this example to run, a graph window with the name "Graph1" must exist in the project.
		// Also, a workseet with the name "Data1" and with columns "A" and "B" and another label column
		// (the third column) must exist. The graph
		// window should contain one dataplot (such as scatter plot) 
		// which uses the workseet's "B" column as Y-column and "A" column as X-column.
		// After the function executes, the third column of the worksheet will be used
		// for labels
		void	run_GraphLayer_AddLabelPlot()
		{
			//we need to first make sure the label column is really a Label column
			Worksheet wks("Data1");
			if(wks)
			{
				if(!wks.Columns(2).SetType(OKDATAOBJ_DESIGNATION_L))
					return;
			}
			else
				return;
			
			GraphLayer		lay("Graph1");
			
			// a dataplot in the layer that uses Data1_b as Y and Data1_a as X
			Curve			cc("Data1_a", "Data1_b");
			
			// first we plot col(B)
			int				nPlotIndex = lay.AddPlot(cc, IDM_PLOT_SCATTER);
			// use the third column in the worksheet "Data1" for labels:
			Column			colLabels("Data1", 2);		
			nPlotIndex = lay.AddLabelPlot(cc, colLabels);
			out_int("nPlotIndex = ", nPlotIndex);
			
			lay.Rescale();
		}
	*/
	int AddLabelPlot(Curve& cData, Column &colLabel);
	/**
	Example:
		For this example to run, a graph window with the name "Graph1" must exist 
		in the project. Also, a workseet with the name "Data1" and with columns "A" 
		and "B" and a label column "C" must exist. The graph window should contain 
		one dataplot which uses the workseet's "B" column as Y-column and "A" column 
		as X-column. 
		
		void test_Graphlayer_AddLabelPlot()
		{
			Worksheet wks("Data1");
			Dataset dsLables("Data1_c");
			if(wks)
			{
				if(!wks.Columns(2).SetType(OKDATAOBJ_DESIGNATION_L))
					return;
			}
			else
				return;
			
			GraphLayer glMyLayer("Graph1");
			Curve crvMyCurve("Data1_a", "Data1_b");
			
			int iPlotIndex = glMyLayer.AddLabelPlot(crvMyCurve, dsLables);
			if (iPlotIndex==-1)
				printf("Lables adding Error!");
			else
				printf("Lables added successfully!");
		}
	*/
	int AddLabelPlot(Curve& cData, Dataset &dsLabel);
	
#if  _OC_VER > 0x0703
	/**#
		Plot a Matrix into a graph layer
	Parameters:
		matObj = Matrix data object
		nPlotID = the internal Origin plot type id.
	Return:
		0-offset data plot index of the dataplot added or -1 for error
	Example:
		// important step to set the correct template to make 3D plots
		//IDM_PLOT_3D_MESH,		"mesh" // filled surface
		//IDM_PLOT_3D_MESH,		"cmap" // colormap surface
		//IDM_PLOT_3D_MESH,		"3Dbars"
		//IDM_PLOT_3D_MESH,		"wirefrm" // wireframes
		//IDM_PLOT_3D_MESH,		"wireface"  
		//IDM_PLOT_CONTOUR,		"contour"
		//IDM_PLOT_CONTOUR,		"contline"
		//IDM_PLOT_CONTOUR,		"contgray"
		//IDM_PLOT_MATRIX_IMAGE,"image"
		
		// 
		// this function plots the given matrix into a new graph
		// if nLevels is specified, will change the colormap to the specified number of levels
		// for plots not using colormap, must pass in 0
		bool plot_matrix(MatrixObject& mobj, LPCSTR lpcszTemplate, int nLevels = 0, int nPlotID = IDM_PLOT_CONTOUR)
		{
			GraphPage gp;
			string strTemp;
			gp.Create(lpcszTemplate, CREATE_HIDDEN); // use template, create as hidden to avoid unneeded drawing
			
			GraphLayer glay = gp.Layers();
			
			int nPlot = glay.AddPlot(mobj, nPlotID);
			glay.Rescale();
			if(nLevels) // to reset number of levels in color map
			{
				DataPlot dp = glay.DataPlots(0); 
				Tree tr; 
				tr = dp.Surface; // get the internal Surface branch of Format 
				tr.ColorMap.Details.Remove(); // must del actual levels so Count can be applied
				tr.ColorMap.Count.nVal = nLevels;
				dp.Surface = tr; // update surface branch from tree 
				strTemp = " Colormap is modified, levels = " + nLevels;
			}
			gp.Label = "Plot created using template: " + (string)lpcszTemplate + strTemp;
			gp.TitleShow = WIN_TITLE_SHOW_BOTH;
			gp.SetShow();// show it when all it ready
			return true;
		}
		
		void test_plot_from_matrix()
		{
			MatrixLayer mlayer = Project.ActiveLayer();
			MatrixObject mobj = mlayer.MatrixObjects();
			
			plot_matrix(mobj, "contour", 5); // contour filled color
			plot_matrix(mobj, "contour", 23);// contour lines only
			plot_matrix(mobj, "image", 0, IDM_PLOT_MATRIX_IMAGE);// grayscale contour map
			plot_matrix(mobj, "cmap", 18, IDM_PLOT_3D_MESH);// grayscale contour map
			plot_matrix(mobj, "wirefrm", 0, IDM_PLOT_3D_MESH);// grayscale contour map
		}

	*/
	int	AddPlot(MatrixObject& matObj, int nPlotID = IDM_PLOT_MATRIX_IMAGE);
#endif // _OC_VER

	/**
		It rescales the graphic layer axes to show all dataplot points that may be outside the current axis ranges.
	Return:
		TRUE if OK, otherwise FALSE.
	Parameters:
		None.
	Example:
		// For this example to run, a graph window with the name "Graph1" must exist in the project.
		// Then manually add some data to the graph and use the Axes dialog to rescale
		// the axes limits so that not all the data is visible. After the function executes,
		// all the data will be visible.
		void	run_GraphLayer_Rescale()
		{
			// the graph layer needs to be initialized:
			GraphLayer		lay("Graph1");
			
			// Rescale the layer axes if necessary:
			lay.Rescale();
		}
	*/
	BOOL	Rescale();

	
	/**
		Gets the layer's coordinate system type.
	Parameters:
		None.
	Returns:
		a value from the following enumeration indicating the type:
		enum {
			FRAME_COOR_CART = 0,			// XY Cartesian coordinate system
			FRAME_COOR_POLAR,				// polar		
			FRAME_COOR_TERNARY,				// ternary
			FRAME_COOR_SMITH_CHART			// Smith chart
		};
	Example:
		// For this example to run, a graph window with the name "Graph1" must exist in the project.
		void	run_GetCoordinateType()
		{
			// the graph layer needs to be initialized:
			GraphLayer		lay("Graph1");
			
			if (lay.GetCoordinateType() == FRAME_COOR_CART)
				out_str("The coordinate system is Cartesian");
			else
				out_str("The coordinate system is not Cartesian");
		}
	*/
	UINT GetCoordinateType();

	
	/**
		Groups dataplots in layer.
	Parameters:
		nIndexStart = the index of the first dataplot to be grouped
		nIndexEnd = the index of the last dataplot to be grouped. All the dataplots from nIndexStart 
					to nIndexEnd are going to be put into the same group (if nIndexEnd is negative,
					all the dataplots from nIndexStart to the end are going to be grouped) 
	Returns:
		TRUE for success, otherwise FALSE.
	Example:
		// For this example to run, a graph window with the name "Graph1" must exist in the project.
		// Make sure that the graph has at least two data plots and they are not grouped.
		// After the function executes, all the dataplots in layer will be grouped in one group.
		void	run_GroupPlots()
		{
			// the graph layer needs to be initialized:
			GraphLayer		lay("Graph1");
			
			// Group all the plots in the layer into one group.
			lay.GroupPlots(0);
		}
	*/
	BOOL	GroupPlots(int nIndexStart, int nIndexEnd = -1);
	
	
	/**
		Ungroups dataplots.
	Parameters:
		nIndex = the index of any dataplot inside the group. If -1, use the first group
	Returns:
		TRUE for success, otherwise FALSE.
	Example:
		// For this example to run, a graph window with the name "Graph1" must exist in the project.
		// Make sure that the graph has at least two data plots and that they are grouped.
		// After the function executes, the dataplots in layer will be ungrouped.
		void	run_UngroupPlots()
		{
			// the graph layer needs to be initialized:
			GraphLayer		lay("Graph1");
			
			// Group all the plots in the layer into one group.
			lay.UngroupPlots();
		}
	*/
	BOOL	UngroupPlots(int nIndex = -1);
	

⌨️ 快捷键说明

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