Skip to content
Snippets Groups Projects
Commit c231d44f authored by Olivier Couet's avatar Olivier Couet
Browse files

Some tutorials generate pictures (png or pdf) with `Print` or `SaveAs`.

Such pictures can (now) be displayed with `\macro_image (picture_name.png[.pdf])`
parent 08fd17fc
No related branches found
No related tags found
No related merge requests found
...@@ -50,7 +50,10 @@ ...@@ -50,7 +50,10 @@
/// ///
/// 1. `\macro_image` /// 1. `\macro_image`
/// The images produced by this macro are shown. A caption can be added to document /// The images produced by this macro are shown. A caption can be added to document
/// the pictures: `\macro_image This is a picture` /// the pictures: `\macro_image This is a picture`. When the option `(nobatch)`
/// is passed, the macro is executed without the batch option.
/// Some tutorials generate pictures (png or pdf) with `Print` or `SaveAs`.
/// Such pictures can be displayed with `\macro_image (picture_name.png[.pdf])`
/// ///
/// 2. `\macro_code` /// 2. `\macro_code`
/// The macro code is shown. A caption can be added: `\macro_code This is code` /// The macro code is shown. A caption can be added: `\macro_code This is code`
...@@ -313,25 +316,38 @@ void FilterTutorial() ...@@ -313,25 +316,38 @@ void FilterTutorial()
if (gLineString.find("\\macro_image") != string::npos) { if (gLineString.find("\\macro_image") != string::npos) {
bool nobatch = (gLineString.find("(nobatch)") != string::npos); bool nobatch = (gLineString.find("(nobatch)") != string::npos);
ReplaceAll(gLineString,"(nobatch)",""); ReplaceAll(gLineString,"(nobatch)","");
if (gPython) { bool image_created_by_macro = (gLineString.find(".png)") != string::npos) ||
if (nobatch) { (gLineString.find(".pdf)") != string::npos);
ExecuteCommand(StringFormat("./makeimage.py %s %s %s 0 1 0", if (image_created_by_macro) {
gFileName.c_str(), gImageName.c_str(), gOutDir.c_str())); string image_name = gLineString;
} else { ReplaceAll(image_name, " ", "");
ExecuteCommand(StringFormat("./makeimage.py %s %s %s 0 1 1", ReplaceAll(image_name, "///\\macro_image(", "");
gFileName.c_str(), gImageName.c_str(), gOutDir.c_str())); ReplaceAll(image_name, ")\n", "");
} ExecuteCommand(StringFormat("root -l -b -q %s", gFileName.c_str()));
ExecuteCommand(StringFormat("mv %s %s/html", image_name.c_str(), gOutDir.c_str()));
ReplaceAll(gLineString, "macro_image (", "image html ");
ReplaceAll(gLineString, ")", "");
} else { } else {
if (nobatch) { if (gPython) {
ExecuteCommand(StringFormat("root -l -q \"makeimage.C(\\\"%s\\\",\\\"%s\\\",\\\"%s\\\",false,false)\"", if (nobatch) {
gFileName.c_str(), gImageName.c_str(), gOutDir.c_str())); ExecuteCommand(StringFormat("./makeimage.py %s %s %s 0 1 0",
gFileName.c_str(), gImageName.c_str(), gOutDir.c_str()));
} else {
ExecuteCommand(StringFormat("./makeimage.py %s %s %s 0 1 1",
gFileName.c_str(), gImageName.c_str(), gOutDir.c_str()));
}
} else { } else {
ExecuteCommand(StringFormat("root -l -b -q \"makeimage.C(\\\"%s\\\",\\\"%s\\\",\\\"%s\\\",false,false)\"", if (nobatch) {
gFileName.c_str(), gImageName.c_str(), gOutDir.c_str())); ExecuteCommand(StringFormat("root -l -q \"makeimage.C(\\\"%s\\\",\\\"%s\\\",\\\"%s\\\",false,false)\"",
gFileName.c_str(), gImageName.c_str(), gOutDir.c_str()));
} else {
ExecuteCommand(StringFormat("root -l -b -q \"makeimage.C(\\\"%s\\\",\\\"%s\\\",\\\"%s\\\",false,false)\"",
gFileName.c_str(), gImageName.c_str(), gOutDir.c_str()));
}
} }
ReplaceAll(gLineString, "\\macro_image", ImagesList(gImageName));
remove(gOutputName.c_str());
} }
ReplaceAll(gLineString, "\\macro_image", ImagesList(gImageName));
remove(gOutputName.c_str());
} }
// \macro_code found // \macro_code found
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment