graph_displayer_canvas.cc
changeset 187 b465e2c34f23
parent 184 4e8704aae278
child 190 2cac5b936a2b
child 204 8fec6a6472fe
equal deleted inserted replaced
53:22eaca3a0cf5 54:dd891249dc35
    26   isbutton(0), active_item(NULL), target_item(NULL), nodemap_to_edit(""),
    26   isbutton(0), active_item(NULL), target_item(NULL), nodemap_to_edit(""),
    27   edgemap_to_edit(""), autoscale(true), zoomtrack(false), radius_size(20), edge_width(10),
    27   edgemap_to_edit(""), autoscale(true), zoomtrack(false), radius_size(20), edge_width(10),
    28   was_redesigned(false), is_drawn(false), mytab(mainw),
    28   was_redesigned(false), is_drawn(false), mytab(mainw),
    29   background_set(false)
    29   background_set(false)
    30 {
    30 {
       
    31   //add mouse scroll event handler - it won't be changed, it handles zoom
       
    32   signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::scrollEventHandler), false);
       
    33 
    31   //base event handler is move tool
    34   //base event handler is move tool
    32   actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::moveEventHandler), false);
    35   actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::moveEventHandler), false);
    33   actual_tool=MOVE;
    36   actual_tool=MOVE;
       
    37 
    34 
    38 
    35   active_node=INVALID;
    39   active_node=INVALID;
    36   active_edge=INVALID;
    40   active_edge=INVALID;
    37   forming_edge=INVALID;
    41   forming_edge=INVALID;
    38 
    42 
   317   radius_p=radius_size;
   321   radius_p=radius_size;
   318 }
   322 }
   319 
   323 
   320 void GraphDisplayerCanvas::reDesignGraph()
   324 void GraphDisplayerCanvas::reDesignGraph()
   321 {
   325 {
       
   326   double max_coord=50000;
   322   double min_dist=20;
   327   double min_dist=20;
   323   double init_vector_length=25;
   328   double init_vector_length=25;
   324 
   329 
   325   if(!was_redesigned)
   330   if(!was_redesigned)
   326     {
   331     {
   399 		actual_forces.set(i,actual_forces[i]-delta);
   404 		actual_forces.set(i,actual_forces[i]-delta);
   400 	    }
   405 	    }
   401 	}
   406 	}
   402       for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
   407       for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
   403 	{
   408 	{
       
   409 	  if(((mytab.mapstorage).coords[i].x)+actual_forces[i].x>max_coord)
       
   410 	    {
       
   411 	      actual_forces[i].x=max_coord-((mytab.mapstorage).coords[i].x);
       
   412 	      std::cout << "Correction! " << (((mytab.mapstorage).coords[i].x)+actual_forces[i].x) << std::endl;
       
   413 	    }
       
   414 	  else if(((mytab.mapstorage).coords[i].x)+actual_forces[i].x<(0-max_coord))
       
   415 	    {
       
   416 	      actual_forces[i].x=0-max_coord-((mytab.mapstorage).coords[i].x);
       
   417 	      std::cout << "Correction! " << (((mytab.mapstorage).coords[i].x)+actual_forces[i].x) << std::endl;
       
   418 	    }
       
   419 	  if(((mytab.mapstorage).coords[i].y)+actual_forces[i].y>max_coord)
       
   420 	    {
       
   421 	      actual_forces[i].y=max_coord-((mytab.mapstorage).coords[i].y);
       
   422 	      std::cout << "Correction! " << (((mytab.mapstorage).coords[i].y)+actual_forces[i].y) << std::endl;
       
   423 	    }
       
   424 	  else if(((mytab.mapstorage).coords[i].y)+actual_forces[i].y<(0-max_coord))
       
   425 	    {
       
   426 	      actual_forces[i].y=0-max_coord-((mytab.mapstorage).coords[i].y);
       
   427 	      std::cout << "Correction! " << (((mytab.mapstorage).coords[i].y)+actual_forces[i].y) << std::endl;
       
   428 	    }
   404 	  moveNode(actual_forces[i].x, actual_forces[i].y, nodesmap[i], i);
   429 	  moveNode(actual_forces[i].x, actual_forces[i].y, nodesmap[i], i);
   405 	}
   430 	}
   406     }
   431     }
   407 }
   432 }
   408 
   433