Skip to content

Commit

Permalink
Merge pull request #7 from Kei18/feature/capture_only
Browse files Browse the repository at this point in the history
Feature/capture only
  • Loading branch information
Kei18 authored Feb 18, 2024
2 parents 75cb865 + dadab31 commit 59387c3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
3 changes: 2 additions & 1 deletion include/ofApp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class ofApp : public ofBaseApp
const int font_size;

// flg
bool flg_capture_only;
bool flg_autoplay;
bool flg_loop;
bool flg_goal;
Expand Down Expand Up @@ -58,5 +59,5 @@ class ofApp : public ofBaseApp
void dragEvent(ofDragInfo dragInfo);
void gotMessage(ofMessage msg);

ofApp(Graph* _G, Solution* _P);
ofApp(Graph* _G, Solution* _P, bool flg_capture_only = false);
};
5 changes: 3 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const std::regex r_pos = std::regex(R"(\((\d+),(\d+)\),)");
int main(int argc, char *argv[])
{
// simple arguments check
if (argc != 3 || !std::ifstream(argv[1]) || !std::ifstream(argv[2])) {
if (argc < 3 || !std::ifstream(argv[1]) || !std::ifstream(argv[2])) {
std::cout << "Please check the arguments, e.g.,\n"
<< "> mapf-visualizer assets/random-32-32-20.map "
"assets/demo_random-32-32-20.txt"
Expand Down Expand Up @@ -45,6 +45,7 @@ int main(int argc, char *argv[])

// visualize
ofSetupOpenGL(100, 100, OF_WINDOW);
ofRunApp(new ofApp(&G, &solution));
ofRunApp(new ofApp(&G, &solution,
(argc > 3 && std::string(argv[3]) == "--capture-only")));
return 0;
}
10 changes: 6 additions & 4 deletions src/ofApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ static void printKeys()
std::cout << "- esc : terminate" << std::endl;
}

ofApp::ofApp(Graph* _G, Solution* _P)
ofApp::ofApp(Graph* _G, Solution* _P, bool _flg_capture_only)
: G(_G),
P(_P),
N(P->front().size()),
Expand All @@ -42,14 +42,15 @@ ofApp::ofApp(Graph* _G, Solution* _P)
agent_rad(scale / std::sqrt(2) / 2),
goal_rad(scale / 4.0),
font_size(std::max(scale / 8, 6)),
flg_capture_only(_flg_capture_only),
flg_autoplay(true),
flg_loop(true),
flg_goal(true),
flg_font(false),
flg_snapshot(false),
flg_snapshot(flg_capture_only),
flg_zoomout(false),
flg_zoomin(false),
line_mode(LINE_MODE::STRAIGHT)
line_mode(flg_capture_only ? LINE_MODE::PATH : LINE_MODE::STRAIGHT)
{
}

Expand All @@ -73,7 +74,7 @@ void ofApp::setup()
cam.removeAllInteractions();
cam.addInteraction(ofEasyCam::TRANSFORM_TRANSLATE_XY, OF_MOUSE_BUTTON_LEFT);

printKeys();
if (!flg_capture_only) printKeys();
}

void ofApp::update()
Expand Down Expand Up @@ -209,6 +210,7 @@ void ofApp::draw()
if (flg_snapshot) {
ofEndSaveScreenAsPDF();
flg_snapshot = false;
if (flg_capture_only) std::exit(0);
}

cam.end();
Expand Down

0 comments on commit 59387c3

Please sign in to comment.