32
32
#include " io/eigparserelectrons.hpp"
33
33
#include " io/electrondos.hpp"
34
34
35
+ const char Graph::HTMLcolor[15 ][8 ] = {
36
+ " #505050" , // Grey
37
+ " #CF009E" , // line04
38
+ " #6EC4E8" , // line13
39
+ " #FF7E2E" , // line05
40
+ " #6ECA97" , // line06
41
+ " #FA9ABA" , // line07
42
+ " #003CA6" , // line03
43
+ " #E19BDF" , // line08
44
+ " #C9910D" , // line10
45
+ " #B6BD00" , // line09
46
+ " #704B1C" , // line11
47
+ " #007852" , // line12
48
+ " #62259D" , // line14
49
+ " #FFCD00" , // line01
50
+ " #837902" // line02
51
+ };
52
+
35
53
//
36
54
Graph::Graph () : _xlabel(),
37
55
_ylabel(),
@@ -232,8 +250,8 @@ void Graph::clearCustom() {
232
250
_arrows.clear ();
233
251
}
234
252
235
- void Graph::plotBand (EigParser &eigparser, ConfigParser &parser, Graph* gplot, Graph::GraphSave save) {
236
- Graph::Config config;
253
+ void Graph::plotBand (EigParser &eigparser, ConfigParser &parser, Graph * gplot,
254
+ Graph::Config & config) {
237
255
std::vector<double > &x = config.x ;
238
256
std::list<std::vector<double >> &y = config.y ;
239
257
std::list<std::string> &labels = config.labels ;
@@ -244,6 +262,14 @@ void Graph::plotBand(EigParser &eigparser, ConfigParser &parser, Graph* gplot, G
244
262
std::string &title = config.title ;
245
263
bool &doSumUp = config.doSumUp ;
246
264
265
+ static int colorId = 0 ;
266
+ if (config.x .size () == 0 )
267
+ colorId = 0 ;
268
+ auto color_1 = Graph::rgb (HTMLcolor[colorId++]);
269
+ colorId = colorId % 15 ;
270
+ auto color_2 = Graph::rgb (HTMLcolor[colorId++]);
271
+ colorId = colorId % 15 ;
272
+
247
273
if ( gplot != nullptr )
248
274
gplot->setWinTitle (" Band Structure" );
249
275
doSumUp = false ;
@@ -318,19 +344,24 @@ void Graph::plotBand(EigParser &eigparser, ConfigParser &parser, Graph* gplot, G
318
344
std::vector<unsigned > projectionUMask;
319
345
bool projection = false ;
320
346
if ( parser.hasToken (" fatband" ) ) {
347
+ if (parser.hasToken (" color" )) {
348
+ Exception e =
349
+ EXCEPTION (" fatband and color options are exclusive" , ERRWAR);
350
+ std::clog << e.fullWhat () << std::endl;
351
+ }
321
352
projection = true ;
322
353
try {
323
- projectionUMask = parser. getToken < unsigned >( " fatband " ,eigparser. getNband ());
324
- }
325
- catch ( Exception &e ) {
326
- if ( e.getReturnValue () & ConfigParser::ERDIM ) {
327
- auto blabla = e.what (" " ,true );
354
+ projectionUMask =
355
+ parser. getToken < unsigned >( " fatband " , eigparser. getNband ());
356
+ } catch (Exception &e) {
357
+ if (e.getReturnValue () & ConfigParser::ERDIM) {
358
+ auto blabla = e.what (" " , true );
328
359
auto pos = blabla.find (" Could only read " );
329
360
int maxToRead = 0 ;
330
- if ( pos != std::string::npos ) {
331
- std::istringstream sub (blabla.substr (pos+ 16 ));
361
+ if (pos != std::string::npos) {
362
+ std::istringstream sub (blabla.substr (pos + 16 ));
332
363
sub >> maxToRead;
333
- projectionUMask = parser.getToken <unsigned >(" fatband" ,maxToRead);
364
+ projectionUMask = parser.getToken <unsigned >(" fatband" , maxToRead);
334
365
}
335
366
}
336
367
}
@@ -376,13 +407,21 @@ void Graph::plotBand(EigParser &eigparser, ConfigParser &parser, Graph* gplot, G
376
407
eeig = nullptr ;
377
408
}
378
409
410
+ if (parser.hasToken (" color" )) {
411
+ std::vector<unsigned > rgb =
412
+ parser.getToken <unsigned >(" color" , eigparser.isPolarized () ? 6 : 3 );
413
+ color_1 = Graph::rgb (rgb[0 ], rgb[1 ], rgb[2 ]);
414
+ if (eigparser.isPolarized ())
415
+ color_2 = Graph::rgb (rgb[3 ], rgb[4 ], rgb[5 ]);
416
+ }
417
+
379
418
x = eigparser.getPath ();
380
419
std::list<std::vector<unsigned >> &projectionsColor = config.rgb ;
381
420
for ( unsigned iband = ignore ; iband < eigparser.getNband () ; ++iband ) {
382
421
y.push_back (eigparser.getBand (iband,fermi,1 ));
383
422
if ( projection )
384
423
projectionsColor.push_back (eigparser.getBandColor (iband,1 ,projectionUMask));
385
- colors.push_back (Graph::rgb ( 0 , 0 , 0 ) );
424
+ colors.push_back (color_1 );
386
425
labels.push_back (" " );
387
426
}
388
427
if ( eigparser.isPolarized () ) {
@@ -392,7 +431,7 @@ void Graph::plotBand(EigParser &eigparser, ConfigParser &parser, Graph* gplot, G
392
431
y.push_back (eigparser.getBand (iband,fermi,2 ));
393
432
if ( projection )
394
433
projectionsColor.push_back (eigparser.getBandColor (iband,2 ,projectionUMask));
395
- colors.push_back (Graph::rgb ( 255 , 0 , 0 ) );
434
+ colors.push_back (color_2 );
396
435
labels.push_back (" " );
397
436
}
398
437
labels.pop_back ();
@@ -431,12 +470,13 @@ void Graph::plotBand(EigParser &eigparser, ConfigParser &parser, Graph* gplot, G
431
470
throw EXCEPTION (" Number of ndiv not compatible with number of labels: " +tmp.str (),ERRDIV);
432
471
}
433
472
}
434
- if ( save == Graph::GraphSave::DATA ) {
473
+ auto save = config.save ;
474
+ if (config.save == Graph::GraphSave::DATA) {
435
475
eigparser.dump (filename+" .dat" ,EigParser::PRTKPT|EigParser::PRTIKPT|(projection ? EigParser::PRTPROJ : 0 ));
436
- save = Graph::GraphSave::NONE;
476
+ config. save = Graph::GraphSave::NONE;
437
477
}
478
+ Graph::plot (config, gplot);
438
479
config.save = save;
439
- Graph::plot (config,gplot);
440
480
if ( gplot != nullptr )
441
481
gplot->clearCustom ();
442
482
}
0 commit comments