// // $Id$ //----------------------------------------------------------------------- // // (c) Copyright 2006 by GATS, Inc., // 11864 Canon Blvd, Suite 101, Newport News VA 23606 // // All Rights Reserved. No part of this software or publication may be // reproduced, stored in a retrieval system, or transmitted, in any form // or by any means, electronic, mechanical, photocopying, recording, or // otherwise without the prior written permission of GATS, Inc. // //----------------------------------------------------------------------- // // Module: GracePlot.cpp // // Author: John Burton // // Date: Thu May 4 13:16:01 2006 // //----------------------------------------------------------------------- // // Modification History: // // $Log$ // //----------------------------------------------------------------------- // //----------------------------------------------------------------------- // Include Files: //----------------------------------------------------------------------- // #include "GracePlot.h" #include // //----------------------------------------------------------------------- // Defines and Macros: //----------------------------------------------------------------------- // // //----------------------------------------------------------------------- // Global Variables: //----------------------------------------------------------------------- // using namespace gracesc; // //----------------------------------------------------------------------- // Utility Routines: //----------------------------------------------------------------------- // XmgraceGraph::XmgraceGraph(unsigned int number) { graph_number = number; linemax = 0; newline = true; GracePrintf("g%d hidden false",graph_number); } XmgraceGraph& XmgraceGraph::operator << (const char* command) { GracePrintf("with g%d",graph_number); GracePrintf("%s",command); return(*this); } XmgraceGraph& XmgraceGraph::operator << (const double& variable){ if(newline){ data.push_back(std::vector()); data[data.size()-1].push_back(variable); newline=false; } else{ data[data.size()-1].push_back(variable); } return(*this); } void XmgraceGraph::operator << (void (*func)(XmgraceGraph&)){ func(*this); } void XmgraceGraph::clear(void){ for(unsigned int i=0;ilinemax){ linemax=lastline; } for(unsigned int i=0;i void XmgraceGraph::Scale_yAxis(int LogType,int vmin,int vmax) { if (LogType ==1){ GracePrintf ( "yaxes scale Logarithmic"); // GracePrintf ( "yaxis tick major 10"); // GracePrintf ( "yaxis tick minor ticks 9"); if (vmax >vmin) { GracePrintf ( "world ymin %d",vmin); GracePrintf ( "world ymax %d",vmax); } } if (LogType == 0) { int tickmajor = (int)(vmax-vmin)/5; // GracePrintf ( "yaxis tick major %d",tickmajor); if (vmax >vmin) { GracePrintf ( "world ymin %d",vmin); GracePrintf ( "world ymax %d",vmax); } } } void XmgraceGraph::Scale_yAxis(int LogType,double vmin,double vmax) { if (LogType ==1){ GracePrintf ( "yaxes scale Logarithmic"); // GracePrintf ( "yaxis tick major 10"); // GracePrintf ( "yaxis tick minor ticks 9"); if (vmax >vmin) { GracePrintf ( "world ymin %e",vmin); GracePrintf ( "world ymax %e",vmax); } } if (LogType == 0) { double tickmajor = (vmax-vmin)/5.0; // GracePrintf ( "yaxis tick major %e",tickmajor); if (vmax >vmin) { GracePrintf ( "world ymin %e",vmin); GracePrintf ( "world ymax %e",vmax); } } } void XmgraceGraph::Display_titles (std::string title, std::string subtitle, std::string xlabel, std::string ylabel) { GracePrintf ( "title size 1.2"); GracePrintf ( "title \"%s\"",title.c_str()); GracePrintf ( "subtitle \"%s\"",subtitle.c_str()); GracePrintf ( "xaxis label place 0.0, 0.05"); GracePrintf ( "xaxis label \"%s\"",xlabel.c_str()); GracePrintf ( "yaxis label \"%s\"",ylabel.c_str()); //GracePrintf ( "redraw"); } void XmgraceGraph::SetLegend(int ndx, std::string legend) { GracePrintf ("legend on"); GracePrintf ("legend string %d \"%s\"", ndx,legend.c_str()); } void XmgraceGraph::Set_legend_location(char *xlocation, char *ylocation) { GracePrintf ( "legend on"); GracePrintf ( "legend x1 %s",xlocation); GracePrintf ( "legend y1 %s",ylocation); GracePrintf ( "legend layout 0"); return; } Xmgrace::Xmgrace(unsigned int size) { max_graph_size = -1; init(); add(size); } Xmgrace::Xmgrace( const std::string ¶meter_file,unsigned int size ) { max_graph_size = -1; init(parameter_file); add(size); } void Xmgrace::add(unsigned int size) { for(unsigned int i=0;i