Skip to content

Commit be5352e

Browse files
committed
Merge branch 'release-1.3'
2 parents 35a0fb7 + e54d10c commit be5352e

4 files changed

Lines changed: 188 additions & 50 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ SET (APPLICATION_NAME "LeMonADE-Viewer")
3333
SET (APPLICATION_CODENAME "${PROJECT_NAME}")
3434
SET (APPLICATION_COPYRIGHT_YEARS "2015")
3535
SET (APPLICATION_VERSION_MAJOR 1)
36-
SET (APPLICATION_VERSION_MINOR 2)
37-
SET (APPLICATION_VERSION_PATCH 4)
36+
SET (APPLICATION_VERSION_MINOR 3)
37+
SET (APPLICATION_VERSION_PATCH 0)
3838
SET (APPLICATION_VERSION_TYPE SNAPSHOT)
3939
SET (APPLICATION_VERSION_STRING "${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH}-${APPLICATION_VERSION_TYPE}")
4040
SET (APPLICATION_ID "${APPLICATION_VENDOR_ID}.${PROJECT_NAME}")

include/LeMonADE-Viewer/LeMonADEViewer.h

Lines changed: 59 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ class LeMonADEViewer: public AbstractUpdater
194194
public:
195195

196196
inline IngredientsType const & getIngredients( void ) const { return this->ingredients; };
197+
197198
inline void executeCommand( std::string line )
198199
{
199200
std::string const command = CommandLineParser.findRead( line );
@@ -208,10 +209,21 @@ class LeMonADEViewer: public AbstractUpdater
208209
}
209210
else
210211
{
212+
if(command.compare("!exit") == 0)
213+
quit();
214+
211215
T_TextBuffer->append( "command not found\n" );
212216
}
213217
}
214218

219+
// shutdown and hide all windows -> leads to exit
220+
inline void quit()
221+
{
222+
while( Fl::first_window() ) {
223+
Fl::first_window()->hide();
224+
}
225+
}
226+
215227
void initialize()
216228
{
217229
std::cout <<"Initialize the BFM- File-Reader...";
@@ -223,8 +235,7 @@ void initialize()
223235
window = new Fl_Double_Window(25,25,300, 585+35, "LeMonADE-Viewer");
224236
{
225237
{
226-
Fl_Group* o = new Fl_Group(10, 15, 285, 50);
227-
238+
Fl_Group* o = new Fl_Group(10, 15, 170, 30);
228239

229240
B_ReverseWindingStart = new Fl_Button(10, 22, 30, 30, "@|<");
230241
B_ReverseWindingStart->tooltip("Show the first frame");
@@ -262,27 +273,37 @@ void initialize()
262273
B_ForwardWindingEnd->when(FL_WHEN_CHANGED);
263274
B_ForwardWindingEnd->callback(( Fl_Callback*)cb_changeForwardWindingEnd, this );
264275

276+
o->end();
277+
}
278+
279+
{
280+
Fl_Group* o = new Fl_Group(195, 15, 70, 80);
265281

266282
Fl_Button* bo = new Fl_Button(195, 22, 30, 30, "P");
267283
bo->tooltip("Generates POV-Ray-script");
268284
bo->labelfont(FL_BOLD+FL_ITALIC);
269285
bo->labelsize(22);
270286
bo->callback(( Fl_Callback*)cb_povray, this );
271287

272-
273288
Fl_Button* co = new Fl_Button(230, 22, 30, 30, "C");
274289
co->tooltip("ColorChooser");
275290
co->labelfont(FL_BOLD+FL_ITALIC);
276291
co->labelsize(22);
277292
co->callback(( Fl_Callback*)cb_colorchooser, this );
278293

279294

280-
Fl_Button* ao = new Fl_Button(265, 22, 30, 30, "i");
295+
Fl_Button* ao = new Fl_Button(195, 57, 30, 30, "i");
281296
ao->tooltip("License Information");
282297
ao->labelfont(FL_BOLD+FL_ITALIC);
283298
ao->labelsize(22);
284299
ao->callback(( Fl_Callback*)cb_license, this );
285300

301+
Fl_Button* aquit = new Fl_Button(230, 57, 30, 30, "Q");
302+
aquit->tooltip("Quit");
303+
aquit->labelfont(FL_BOLD+FL_ITALIC);
304+
aquit->labelsize(22);
305+
aquit->callback(( Fl_Callback*)cb_quit, this );
306+
286307
o->end();
287308

288309
}
@@ -488,7 +509,8 @@ void initialize()
488509
"!setRadius:all=radius\n"
489510
"!setRadiusAttributes:att=radius\n"
490511
"!setRadiusLinks:numLinks=radius\n"
491-
"!setRadiusGroups:idxGroup=radius\n");
512+
"!setRadiusGroups:idxGroup=radius\n"
513+
"!exit\n");
492514

493515
I_CommandInput->when(FL_WHEN_ENTER_KEY|FL_WHEN_NOT_CHANGED);
494516
I_CommandInput->callback(( Fl_Callback*)cb_changeCommandInput, this );
@@ -523,8 +545,8 @@ void initialize()
523545
} // Fl_Double_Window* o
524546

525547
// fill the groups with connected structures by an functor
526-
// fill_connected_groups( this->ingredients.getMolecules(), linearGroupsVector, MonomerGroup<typename IngredientsType::molecules_type>(&(this->ingredients.getMolecules())),alwaysTrue() );
527-
fill_connected_groups( this->ingredients.getMolecules(), linearGroupsVector, MonomerGroup<typename IngredientsType::molecules_type>((this->ingredients.getMolecules())),belongsToLinearStrand() );
548+
fill_connected_groups( this->ingredients.getMolecules(), linearGroupsVector, MonomerGroup<typename IngredientsType::molecules_type>((this->ingredients.getMolecules())),alwaysTrue() );
549+
//fill_connected_groups( this->ingredients.getMolecules(), linearGroupsVector, MonomerGroup<typename IngredientsType::molecules_type>((this->ingredients.getMolecules())),belongsToLinearStrand() );
528550

529551
// create the OpenGL window
530552
winOpenGL= new LeMonADEOpenGL<IngredientsType>(ingredients, linearGroupsVector, 400,25,800,800, "LeMonADE-Viewer OpenGL");
@@ -627,6 +649,10 @@ inline void cb_license_i( Fl_Button*, void* );
627649
static void cb_colorchooser( Fl_Button*, void* );
628650
inline void cb_colorchooser_i( Fl_Button*, void* );
629651

652+
// quit button
653+
static void cb_quit( Fl_Button*, void* );
654+
inline void cb_quit_i( Fl_Button*, void* );
655+
630656
// show bonds button
631657
static void cb_showbonds( Fl_Check_Button*, void* );
632658
inline void cb_showbonds_i( Fl_Check_Button*);
@@ -795,6 +821,32 @@ void LeMonADEViewer<IngredientsType>::cb_license_i( Fl_Button* , void* )
795821

796822
}
797823

824+
template <class IngredientsType>
825+
void LeMonADEViewer<IngredientsType>::cb_quit( Fl_Button* obj, void* v )
826+
{
827+
//should be replace by the info -box
828+
LeMonADEViewer<IngredientsType> * T=( LeMonADEViewer<IngredientsType>* )v;
829+
T->cb_quit_i(obj,v);
830+
831+
}
832+
833+
template <class IngredientsType>
834+
void LeMonADEViewer<IngredientsType>::cb_quit_i( Fl_Button* , void* )
835+
{
836+
std::cout << "EXITing..." << std::endl;
837+
838+
/*while(Fl::first_window())
839+
{
840+
delete Fl::first_window();
841+
}
842+
*/
843+
844+
quit();
845+
846+
}
847+
848+
849+
798850
template <class IngredientsType>
799851
void LeMonADEViewer<IngredientsType>::cb_colorchooser( Fl_Button* obj, void* v )
800852
{

include/LeMonADE-Viewer/LeMonADEViewerAboutWin.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ const std::string LeMonADEViewerAboutWin::getText() const
9292

9393
std::string msg=
9494

95-
"This is the application LeMonADE-Viewer V1.2.4.\n"
95+
"This is the application LeMonADE-Viewer V1.3.0.\n"
9696
"==============================================="
9797
"\n"
9898
"The abbreviation \"LeMonADE\" stands for \n"
@@ -150,6 +150,7 @@ const std::string LeMonADEViewerAboutWin::getText() const
150150
"!setRadiusAttributes:att=radius\n"
151151
"!setRadiusLinks:numLinks=radius\n"
152152
"!setRadiusGroups:idxGroup=radius\n"
153+
"!exit\n"
153154
"\n"
154155
"LeMonADE-Viewer Authors\n"
155156
"==============================\n"
@@ -160,6 +161,7 @@ const std::string LeMonADEViewerAboutWin::getText() const
160161
"Principal developers:\n"
161162
"---------------------\n"
162163
"Ron Dockhorn, Germany\n"
164+
"Martin Wengenmayr, Germany\n"
163165
"\n"
164166
"\n"
165167
"Following people contributed fixes and small enhancements to\n"

include/LeMonADE-Viewer/LeMonADEViewerLineCommand.h

Lines changed: 124 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ along with LeMonADE-Viewer. If not, see <http://www.gnu.org/licenses/>.
3232

3333
#include <string>
3434
#include <sstream>
35-
#include <algorithm> // std::find_if
35+
#include <algorithm> // std::find_if std::max
3636
#include <cstddef> // NULL
3737
#include <cstdlib> // std::strtod
3838
#include <iostream>
@@ -403,66 +403,145 @@ class CommandSetColorTopology : public LineCommandBase<IngredientsType, Molecule
403403
float redEnd, greenEnd, blueEnd;
404404
readColor( vex[2], &redEnd, &greenEnd, &blueEnd, "!setColorTopology (end)" );
405405

406-
//color all monomers
407-
/*for(uint32_t i = 0; i < ingredients.modifyMolecules().size(); i++)
408-
{
409-
if(ingredients.modifyMolecules().getNumLinks(i) == numLinks)
410-
ingredients.modifyMolecules()[i].setColor( red ,green , blue);
411-
}*/
412406

413-
Graph treeGraph;
414407

408+
/* ################################################################ */
415409

416-
Nodelist degreeNode; // Degree of node
410+
// if the coloring should be calculated using the systems larges topological distance, replace MonomerGroupsVector molecules_type by ingredients and the true index by the monomer index
411+
// do the coloring groupwise
412+
for(uint32_t groupIdx=0; groupIdx<molecules_type.size(); groupIdx++ ){
417413

418-
for (int k= 0; k < ingredients.getMolecules().size(); k++)
414+
//typedef std::map<NodeIdx, Nodelist> Graph;
415+
Graph treeGraph;
416+
//typedef std::map<NodeIdx, int> Nodelist;
417+
Nodelist degreeNode; // Degree of node
418+
for( uint32_t k=0; k<molecules_type[groupIdx].size(); k++){
419+
// get the index from the group
420+
int32_t monoIdx(molecules_type[groupIdx].trueIndex(k));
421+
for( uint32_t link=0; link< ingredients.getMolecules().getNumLinks(monoIdx); link++){
422+
// connect from idxAA to idxBB with value ZZ
423+
// all (symmetric) connections
424+
treeGraph[monoIdx][ingredients.getMolecules().getNeighborIdx(monoIdx, link)]=1;
425+
}
426+
// fill with degree of nodes
427+
degreeNode[monoIdx]=ingredients.getMolecules().getNumLinks(monoIdx);
428+
}
429+
430+
// calculate eccentricity of graph for all nodes
431+
std::cout << "Calculate eccentricity can take time..." << std::endl;
432+
std::map<NodeIdx, int> eccentricity;
433+
//std::map<NodeIdx, Nodelist> distance;
434+
435+
for( uint32_t k=0; k<molecules_type[groupIdx].size(); k++)
419436
{
420-
for (int l = 0; l < ingredients.getMolecules().getNumLinks(k); l++)
437+
NodeIdx startNode = molecules_type[groupIdx].trueIndex(k);
438+
Nodelist topo_distance;
439+
dijkstra(treeGraph, startNode, topo_distance);
440+
441+
int maxTopologicalDistance = 0;
442+
443+
for(Nodelist::iterator it=topo_distance.begin(); it!=topo_distance.end(); ++it)
421444
{
422-
// connect from idxAA to idxBB with value ZZ
423-
// all (symmetric) connections
424-
treeGraph[k][ingredients.getMolecules().getNeighborIdx(k, l)]=1;
445+
//std::cout<< startNode << " -> " << it->first << " => "<<it->second<<std::endl;
446+
//distance[startNode][it->first] = it->second;
425447

448+
if(maxTopologicalDistance < it->second)
449+
maxTopologicalDistance=it->second;
426450
}
427-
// fill with degree of nodes
428-
degreeNode[k]=ingredients.getMolecules().getNumLinks(k);
451+
452+
eccentricity[startNode]=maxTopologicalDistance;
453+
std::cout<< startNode << " -> eccentricity: " << eccentricity[startNode] <<std::endl;
429454
}
430455

456+
// calculate the radius of the graph = min eccentricity
457+
int radiusGraph = std::numeric_limits<int>::max();
431458

432-
//finding the center of the tree (either one or two)
433-
NodeVector centerNodes;
434-
findCentersOfTree(treeGraph, degreeNode, centerNodes);
459+
for (std::map<NodeIdx, int>::iterator it_ecc=eccentricity.begin(); it_ecc!=eccentricity.end(); ++it_ecc)
460+
{
461+
if(it_ecc->second < radiusGraph)
462+
radiusGraph = it_ecc->second;
463+
}
464+
std::cout << "Radius Graph = " << radiusGraph <<std::endl;
435465

436-
//calculate the topological distance of center to all nodes and fill histogram
437-
NodeVector::iterator itv;
438-
for(itv=centerNodes.begin(); itv!=centerNodes.end(); ++itv){
466+
// calculate center nodes: eccentricity[center] == radiusGraph
467+
NodeVector centerGraph;
468+
for (std::map<NodeIdx, int>::iterator it_ecc=eccentricity.begin(); it_ecc!=eccentricity.end(); ++it_ecc)
469+
{
470+
if(it_ecc->second == radiusGraph)
471+
centerGraph.push_back(it_ecc->first);
472+
}
439473

474+
std::cout << "Center Graph = ( ";
475+
for(NodeVector::iterator it_center=centerGraph.begin(); it_center!=centerGraph.end(); ++it_center){
476+
std::cout << *it_center << " : ";
477+
}
478+
std::cout << " )" << std::endl;
440479

480+
// calculate the diameter of the graph = max eccentricity
481+
int diameterGraph = std::numeric_limits<int>::min();
441482

442-
NodeIdx startNode = (*itv);
443-
std::cout << std::endl << "startNode: " << startNode << std::endl;
483+
for (std::map<NodeIdx, int>::iterator it_ecc=eccentricity.begin(); it_ecc!=eccentricity.end(); ++it_ecc)
484+
{
485+
if(diameterGraph < it_ecc->second)
486+
diameterGraph = it_ecc->second;
487+
}
488+
std::cout << "Diameter Graph = " << diameterGraph <<std::endl;
444489

445-
// idx -> distance from center
446-
Nodelist topo_distance;
447-
dijkstra(treeGraph, startNode, topo_distance);
448490

449-
std::cout << "startNode -> node => distance" <<std::endl;
491+
// pick an arbitrary center node
492+
{
493+
NodeIdx startNode = centerGraph.at(0);
494+
Nodelist topo_distance;
495+
dijkstra(treeGraph, startNode, topo_distance);
450496

451-
int maxTopologicalDistance = 0;
497+
int maxTopologicalDistance = 0;
452498

453-
Nodelist::iterator it;
454-
for(it=topo_distance.begin(); it!=topo_distance.end(); ++it){
499+
for(Nodelist::iterator it=topo_distance.begin(); it!=topo_distance.end(); ++it)
500+
{
501+
//find the maximum topological distance from the tree center
502+
if(maxTopologicalDistance < it->second)
503+
maxTopologicalDistance=it->second;
504+
}
505+
506+
std::cout<< startNode << " -> max center distance " << maxTopologicalDistance <<std::endl;
507+
508+
509+
/*
510+
511+
//finding the center of the tree (either one or two)
512+
//typedef std::vector<NodeIdx> NodeVector;
513+
NodeVector centerNodes;
514+
findCentersOfTree(treeGraph, degreeNode, centerNodes);
515+
516+
//calculate the topological distance of center to all nodes and fill histogram
517+
NodeVector::iterator itv;
518+
519+
for(itv=centerNodes.begin(); itv!=centerNodes.end(); ++itv){
520+
NodeIdx startNode = (*itv);
521+
522+
523+
// idx -> distance from center
524+
Nodelist topo_distance;
525+
dijkstra(treeGraph, startNode, topo_distance);
526+
527+
int maxTopologicalDistance = 0;
528+
529+
530+
Nodelist::iterator it;
531+
for(it=topo_distance.begin(); it!=topo_distance.end(); ++it){
532+
//find the maximum topological distance from the tree center
533+
if(maxTopologicalDistance < it->second)
534+
maxTopologicalDistance=it->second;
535+
}
536+
537+
538+
std::cout << "startNode -> node => distance" <<std::endl;
539+
*/
455540

456-
// std::cout<< startNode << " -> " << it->first << " => "<<it->second<<std::endl;
457541

458-
//find the maximum topological distance from the tree center
459-
if(maxTopologicalDistance < it->second)
460-
maxTopologicalDistance=it->second;
461-
}
462-
std::cout<< startNode << " -> max topological distance " << maxTopologicalDistance <<std::endl;
463542

464543
//color the structure
465-
for(it=topo_distance.begin(); it!=topo_distance.end(); ++it){
544+
for(Nodelist::iterator it=topo_distance.begin(); it!=topo_distance.end(); ++it){
466545

467546
// std::cout<< startNode << " -> " << it->first << " => "<<it->second<<std::endl;
468547

@@ -480,7 +559,11 @@ class CommandSetColorTopology : public LineCommandBase<IngredientsType, Molecule
480559
}
481560

482561

483-
}
562+
563+
564+
565+
}
566+
} // end loop monomerGroups
484567

485568

486569
return std::string("apply color to all monomers with numTopology");
@@ -1297,6 +1380,7 @@ class CommandGetHelp : public LineCommandBase<IngredientsType, MoleculesType>
12971380
"!setRadius:all=radius\n"
12981381
"!setRadiusAttributes:att=radius\n"
12991382
"!setRadiusLinks:numLinks=radius\n"
1300-
"!setRadiusGroups:idxGroup=radius\n");
1383+
"!setRadiusGroups:idxGroup=radius\n"
1384+
"!exit\n");
13011385
}
13021386
};

0 commit comments

Comments
 (0)