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

Add posibility to colors node in cli image generation #35

Merged
merged 1 commit into from
Mar 18, 2017
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
36 changes: 36 additions & 0 deletions command_line/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,26 @@ int bandageImage(QStringList arguments)
g_settings->startingNodes,
"all");

QString errormsg;
QStringList columns;
bool coloursLoaded = false;
QString csvPath = parseColorsOption(arguments);
if (csvPath != "")
{
if(!g_assemblyGraph->loadCSV(csvPath, &columns, &errormsg, &coloursLoaded))
{
err << errormsg << endl;
return 1;
}

if(coloursLoaded == false)
{
err << csvPath << " didn't contains color" << endl;
return 1;
}
g_settings->nodeColourScheme = CUSTOM_COLOURS;
}

if (errorMessage != "")
{
err << errorMessage << endl;
Expand Down Expand Up @@ -212,6 +232,7 @@ void printImageUsage(QTextStream * out, bool all)
text << "";
text << "Options: --height <int> Image height (default: 1000)";
text << "--width <int> Image width (default: not set)";
text << "--color <file> csv file with 2 column first the node name second the node color";
text << "";
text << "If only height or width is set, the other will be determined automatically. If both are set, the image will be exactly that size.";
text << "";
Expand All @@ -232,6 +253,9 @@ QString checkForInvalidImageOptions(QStringList arguments)
error = checkOptionForInt("--width", &arguments, IntSetting(0, 1, 32767), false);
if (error.length() > 0) return error;

error = checkOptionForString("--colors", &arguments, QStringList(), "a path of csv file");
if (error.length() > 0) return error;

return checkForInvalidOrExcessSettings(&arguments);
}

Expand All @@ -251,3 +275,15 @@ void parseImageOptions(QStringList arguments, int * width, int * height)
parseSettings(arguments);
}

//This function parses the command line options. It assumes that the options
//have already been checked for correctness.
QString parseColorsOption(QStringList arguments)
{
QString path = "";
if (isOptionPresent("--colors", &arguments))
path = getStringOption("--colors", &arguments);

parseSettings(arguments);

return path;
}
1 change: 1 addition & 0 deletions command_line/image.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ int bandageImage(QStringList arguments);
void printImageUsage(QTextStream * out, bool all);
QString checkForInvalidImageOptions(QStringList arguments);
void parseImageOptions(QStringList arguments, int * width, int * height);
QString parseColorsOption(QStringList arguments);

#endif // IMAGE_H