diff --git a/ChangeLog.md b/ChangeLog.md index 179afa4..a7dbe2f 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -3,6 +3,11 @@ # DGtalTools-contrib 0.9.4 +- *visualisation* + - graphViewer: new option to generate edges from vertex points and to + customize vertex color (Bertrand Kerautret, + [#33](https://github.com/DGtal-team/DGtalTools-contrib/pull/33)) + - *Geometry2d* - LUTBasedNSDistanceTransform: Removed the dependency to libNetPBM. (Nicolas Normand, [#32](https://github.com/DGtal-team/DGtalTools-contrib/pull/32)) diff --git a/visualisation/graphViewer.cpp b/visualisation/graphViewer.cpp index d581bbe..4928689 100644 --- a/visualisation/graphViewer.cpp +++ b/visualisation/graphViewer.cpp @@ -74,10 +74,12 @@ int main( int argc, char** argv ) ("help,h", "display this message") ("inputVertex,v", po::value(), "input file containing the vertex list.") ("inputEdge,e", po::value(), "input file containing the edge list.") + ("autoEdge,a", "generate edge list from vertex order.") ("inputRadii,r", po::value(), "input file containing the radius for each vertex.") ("ballRadius,b", po::value()->default_value(1.0), "radius of vertex balls.") ("addMesh,m", po::value(), "add mesh in the display.") ("meshColor", po::value >()->multitoken(), "specify the color mesh.") + ("vertexColor", po::value >()->multitoken(), "specify the color of vertex.") ("edgeColor", po::value >()->multitoken(), "specify the color of edges.") ("colormap,c", "display vertex colored by order in vertex file or by radius scale if the radius file is specidfied (-r).") ("doSnapShotAndExit,d", po::value(), "save display snapshot into file. Notes that the camera setting is set by default according the last saved configuration (use SHIFT+Key_M to save current camera setting in the Viewer3D). If the camera setting was not saved it will use the default camera setting." ); @@ -96,7 +98,7 @@ int main( int argc, char** argv ) parseOK = false; } po::notify(vm); - if( !parseOK || argc<=1 || vm.count("help") || !vm.count("inputVertex") || !vm.count("inputEdge") ) + if( !parseOK || argc<=1 || vm.count("help") || !vm.count("inputVertex") || (!vm.count("inputEdge")&& !vm.count("autoEdge") )) { trace.info() << "Basic display graph" << std::endl << "Options:" << std::endl @@ -111,15 +113,28 @@ int main( int argc, char** argv ) DGtal::Color meshColor(240,240,240); DGtal::Color edgeColor(240,240,240); + DGtal::Color vertexColor(240,240,240); std::string nameFileVertex = vm["inputVertex"].as(); - std::string nameFileEdge = vm["inputEdge"].as(); + double r = vm["ballRadius"].as(); bool useRadiiFile = vm.count("inputRadii"); // Structures to store vertex and edges read in input files std::vector vectVertex = PointListReader::getPointsFromFile(nameFileVertex); - std::vector vectEdges = PointListReader::getPointsFromFile(nameFileEdge); + std::vector vectEdges; + if(!vm.count("autoEdge")) + { + std::string nameFileEdge = vm["inputEdge"].as(); + vectEdges = PointListReader::getPointsFromFile(nameFileEdge); + } + else + { + for(unsigned int i=0; i vectRadii( std::max(vectVertex.size(),vectEdges.size()), r ); // read the mesh and ege colors @@ -137,6 +152,15 @@ int main( int argc, char** argv ) } edgeColor.setRGBi(vectCol[0],vectCol[1],vectCol[2],vectCol[3]); } + if(vm.count("vertexColor")) + { + std::vector vectCol = vm["vertexColor"].as >(); + if( vectCol.size()!=4 ) + { + trace.error() << "The color specification should contain R,G,B and Alpha values."<< std::endl; + } + vertexColor.setRGBi(vectCol[0],vectCol[1],vectCol[2],vectCol[3]); + } // Create the color scale dpending on the specified radius file HueShadeColorMap hueShade(0,vectVertex.size()-1); @@ -161,6 +185,7 @@ int main( int argc, char** argv ) Color currentColor; for ( int i=0 ; i