Skip to content

Commit bf1d2ae

Browse files
authored
Merge pull request #35 from natir/master
Add posibility to colors node in cli image generation
2 parents 109c3cb + 53a7917 commit bf1d2ae

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

command_line/image.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,26 @@ int bandageImage(QStringList arguments)
130130
g_settings->startingNodes,
131131
"all");
132132

133+
QString errormsg;
134+
QStringList columns;
135+
bool coloursLoaded = false;
136+
QString csvPath = parseColorsOption(arguments);
137+
if (csvPath != "")
138+
{
139+
if(!g_assemblyGraph->loadCSV(csvPath, &columns, &errormsg, &coloursLoaded))
140+
{
141+
err << errormsg << endl;
142+
return 1;
143+
}
144+
145+
if(coloursLoaded == false)
146+
{
147+
err << csvPath << " didn't contains color" << endl;
148+
return 1;
149+
}
150+
g_settings->nodeColourScheme = CUSTOM_COLOURS;
151+
}
152+
133153
if (errorMessage != "")
134154
{
135155
err << errorMessage << endl;
@@ -212,6 +232,7 @@ void printImageUsage(QTextStream * out, bool all)
212232
text << "";
213233
text << "Options: --height <int> Image height (default: 1000)";
214234
text << "--width <int> Image width (default: not set)";
235+
text << "--color <file> csv file with 2 column first the node name second the node color";
215236
text << "";
216237
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.";
217238
text << "";
@@ -232,6 +253,9 @@ QString checkForInvalidImageOptions(QStringList arguments)
232253
error = checkOptionForInt("--width", &arguments, IntSetting(0, 1, 32767), false);
233254
if (error.length() > 0) return error;
234255

256+
error = checkOptionForString("--colors", &arguments, QStringList(), "a path of csv file");
257+
if (error.length() > 0) return error;
258+
235259
return checkForInvalidOrExcessSettings(&arguments);
236260
}
237261

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

278+
//This function parses the command line options. It assumes that the options
279+
//have already been checked for correctness.
280+
QString parseColorsOption(QStringList arguments)
281+
{
282+
QString path = "";
283+
if (isOptionPresent("--colors", &arguments))
284+
path = getStringOption("--colors", &arguments);
285+
286+
parseSettings(arguments);
287+
288+
return path;
289+
}

command_line/image.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,6 @@ int bandageImage(QStringList arguments);
2828
void printImageUsage(QTextStream * out, bool all);
2929
QString checkForInvalidImageOptions(QStringList arguments);
3030
void parseImageOptions(QStringList arguments, int * width, int * height);
31+
QString parseColorsOption(QStringList arguments);
3132

3233
#endif // IMAGE_H

0 commit comments

Comments
 (0)