Apply format stored in theme file to object
Apply format stored in tree to object
BOOL ApplyFormat( LPCSTR lpcszXMLPath, BOOL bRepaint = TRUE, BOOL bRelative = FALSE, BOOL bUndo = FALSE, vector<int> * piaErrors = NULL, vector<string> * psaErrors = NULL )
BOOL ApplyFormat( const TreeNode & trNode, BOOL bRepaint = TRUE, BOOL bRelative = FALSE, BOOL bUndo = FALSE, vector<int> * piaErrors = NULL, vector<string> * psaErrors = NULL )
EX1
// Graph should exist with ticks facing outward // After running example, ticks will face inward void OriginObject_ApplyFormat_Ex1() { GraphPage gp = Project.GraphPages(0); gp.ApplyFormat("themes\\graph\\Ticks All In.OTH"); }
EX2
// In a new project, import some data and make two graphs of the same type // Modify the first graph created in any way you like // Run the example. The second graph will get the modifications of the first. void OriginObject_ApplyFormat_Ex2() { GraphPage pg1 = Project.GraphPages(0); GraphPage pg2 = Project.GraphPages(1); Tree tr; tr = pg1.GetFormat(); pg2.ApplyFormat(tr); }
EX3
// following code will set properties of a given Rect object void OriginObject_ApplyFormat_Ex3(string strName = "Rect") { GraphLayer gl = Project.ActiveLayer(); GraphObject gg = gl.GraphObjects(strName); if(gg) { Tree tr; tr.Root.Fill.Color.nVal = -4; // this value corresponds to transparent, or NONE in dialog tr.Root.Fill.Pattern.Style.nVal = 6; tr.Root.Fill.Pattern.UseBorderColor.nVal = 0;// independent color for fill pattern lines tr.Root.Fill.Pattern.PatternColor.nVal = 6; // yellow tr.Root.Fill.Pattern.Width.dVal = 0.1; // fill pattern line width tr.Root.Fill = tr.Root.Border; int nErr = gg.UpdateThemeIDs(tr.Root); if(0 == nErr) gg.ApplyFormat(tr, true, true); } }
If you use the same tree to get and apply format, please note that: changing some setting will possibly make some other setting outdated.
OriginObject::CopyFormat,OriginObject::GetFormat,OriginObject::UpdateThemeIDs
origin.h