Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/capture only #7

Merged
merged 2 commits into from
Feb 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading