3 * This file is a part of LEMON, a generic C++ optimization library
5 * Copyright (C) 2003-2006
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
9 * Permission to use, modify and distribute this software is granted
10 * provided that this copyright notice appears in all copies. For
11 * precise terms see the accompanying LICENSE file.
13 * This software is provided "AS IS" with no warranty of any kind,
14 * express or implied, and with no claim as to its suitability for any
19 #include <graph_displayer_canvas.h>
20 #include <mapstorage.h>
25 bool GraphDisplayerCanvas::on_expose_event(GdkEventExpose *event)
27 Gnome::Canvas::CanvasAA::on_expose_event(event);
33 void GraphDisplayerCanvas::changeEditorialTool(int newtool)
35 if(actual_tool!=newtool)
38 actual_handler.disconnect();
44 GdkEvent * generated=new GdkEvent();
45 generated->type=GDK_BUTTON_RELEASE;
46 generated->button.button=3;
47 createEdgeEventHandler(generated);
69 actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::moveEventHandler), false);
73 actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::createNodeEventHandler), false);
77 actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::createEdgeEventHandler), false);
81 actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::eraserEventHandler), false);
86 actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::mapEditEventHandler), false);
95 int GraphDisplayerCanvas::getActualTool()
100 bool GraphDisplayerCanvas::scrollEventHandler(GdkEvent* e)
103 if(e->type==GDK_SCROLL)
106 //pointer shows this win point before zoom
107 XY win_coord(((GdkEventScroll*)e)->x, ((GdkEventScroll*)e)->y);
109 //the original scroll settings
110 int scroll_offset_x, scroll_offset_y;
111 get_scroll_offsets(scroll_offset_x, scroll_offset_y);
113 //pointer shows this canvas point before zoom
115 window_to_world(win_coord.x, win_coord.y, canvas_coord.x, canvas_coord.y);
117 if(((GdkEventScroll*)e)->direction) //IN
126 //pointer shows this window point after zoom
128 world_to_window(canvas_coord.x, canvas_coord.y, post_win_coord.x, post_win_coord.y);
130 //we have to add the difference between new and old window point to original scroll offset
131 scroll_to(scroll_offset_x+(int)(post_win_coord.x-win_coord.x),scroll_offset_y+(int)(post_win_coord.y-win_coord.y));
133 //no other eventhandler is needed
139 bool GraphDisplayerCanvas::moveEventHandler(GdkEvent* e)
141 static Gnome::Canvas::Text *coord_text = 0;
144 case GDK_BUTTON_PRESS:
145 //we mark the location of the event to be able to calculate parameters of dragging
146 window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
148 active_item=(get_item_at(clicked_x, clicked_y));
150 for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
152 if(nodesmap[i]==active_item)
157 isbutton=e->button.button;
159 case GDK_BUTTON_RELEASE:
169 case GDK_MOTION_NOTIFY:
170 //we only have to do sg. if the mouse button is pressed AND the click was on a node that was found in the set of nodes
171 if(active_node!=INVALID)
173 (mytab.mapstorage)->modified = true;
175 //new coordinates will be the old values,
176 //because the item will be moved to the
177 //new coordinate therefore the new movement
178 //has to be calculated from here
182 window_to_world (e->motion.x, e->motion.y, new_x, new_y);
184 double dx=new_x-clicked_x;
185 double dy=new_y-clicked_y;
192 // reposition the coordinates text
193 std::ostringstream ostr;
195 (mytab.mapstorage)->coords[active_node].x << ", " <<
196 (mytab.mapstorage)->coords[active_node].y << ")";
198 (nodesmap[active_node]->property_x2().get_value() -
199 nodesmap[active_node]->property_x1().get_value()) / 2.0;
202 coord_text->property_text().set_value(ostr.str());
203 coord_text->property_x().set_value((mytab.mapstorage)->coords[active_node].x +
205 coord_text->property_y().set_value((mytab.mapstorage)->coords[active_node].y -
210 coord_text = new Gnome::Canvas::Text(
212 (mytab.mapstorage)->coords[active_node].x + radius,
213 (mytab.mapstorage)->coords[active_node].y - radius,
215 coord_text->property_fill_color().set_value("black");
216 coord_text->property_anchor().set_value(Gtk::ANCHOR_SOUTH_WEST);
227 XY GraphDisplayerCanvas::calcArrowPos(XY moved_node_1, XY moved_node_2, XY fix_node, XY old_arrow_pos, int move_code)
232 return XY((moved_node_2.x + fix_node.x) / 2.0, (moved_node_2.y + fix_node.y) / 2.0);
235 return old_arrow_pos;
239 //////////////////////////////////////////////////////////////////////////////////////////////////////
240 /////////// keeps shape-with scalar multiplication - version 2.
241 //////////////////////////////////////////////////////////////////////////////////////////////////////
243 //old vector from one to the other node - a
244 XY a_v(moved_node_1.x-fix_node.x,moved_node_1.y-fix_node.y);
245 //new vector from one to the other node - b
246 XY b_v(moved_node_2.x-fix_node.x,moved_node_2.y-fix_node.y);
248 double absa=sqrt(a_v.normSquare());
249 double absb=sqrt(b_v.normSquare());
251 if ((absa == 0.0) || (absb == 0.0))
253 return old_arrow_pos;
257 //old vector from one node to the breakpoint - c
258 XY c_v(old_arrow_pos.x-fix_node.x,old_arrow_pos.y-fix_node.y);
260 //unit vector with the same direction to a_v
261 XY a_v_u(a_v.x/absa,a_v.y/absa);
263 //normal vector of unit vector with the same direction to a_v
264 XY a_v_u_n(((-1)*a_v_u.y),a_v_u.x);
266 //unit vector with the same direction to b_v
267 XY b_v_u(b_v.x/absb,b_v.y/absb);
269 //normal vector of unit vector with the same direction to b_v
270 XY b_v_u_n(((-1)*b_v_u.y),b_v_u.x);
272 //vector c in a_v_u and a_v_u_n co-ordinate system
273 XY c_a(c_v*a_v_u,c_v*a_v_u_n);
275 //new vector from one node to the breakpoint - d - we have to calculate this one
276 XY d_v=absb/absa*(c_a.x*b_v_u+c_a.y*b_v_u_n);
278 return XY(d_v.x+fix_node.x,d_v.y+fix_node.y);
288 bool GraphDisplayerCanvas::createNodeEventHandler(GdkEvent* e)
293 case GDK_MOTION_NOTIFY:
295 GdkEvent * generated=new GdkEvent();
296 generated->motion.x=e->motion.x;
297 generated->motion.y=e->motion.y;
298 generated->type=GDK_MOTION_NOTIFY;
299 moveEventHandler(generated);
303 case GDK_BUTTON_RELEASE:
304 (mytab.mapstorage)->modified = true;
310 active_node=(mytab.mapstorage)->graph.addNode();
312 //initiating values corresponding to new node in maps
314 window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
316 // update coordinates
317 (mytab.mapstorage)->coords.set(active_node, XY(clicked_x, clicked_y));
319 // update all other maps
320 for (std::map<std::string, Graph::NodeMap<double>*>::const_iterator it =
321 (mytab.mapstorage)->nodemap_storage.begin(); it !=
322 (mytab.mapstorage)->nodemap_storage.end(); ++it)
324 if ((it->first != "coordinates_x") &&
325 (it->first != "coordinates_y"))
327 (*(it->second))[active_node] =
328 (mytab.mapstorage)->nodemap_default[it->first];
331 // increment the id map's default value
332 (mytab.mapstorage)->nodemap_default["label"] += 1.0;
334 nodesmap[active_node]=new Gnome::Canvas::Ellipse(displayed_graph,
335 clicked_x-20, clicked_y-20, clicked_x+20, clicked_y+20);
336 active_item=(Gnome::Canvas::Item *)(nodesmap[active_node]);
337 *(nodesmap[active_node]) <<
338 Gnome::Canvas::Properties::fill_color("blue");
339 *(nodesmap[active_node]) <<
340 Gnome::Canvas::Properties::outline_color("black");
341 active_item->raise_to_top();
343 (nodesmap[active_node])->show();
345 nodetextmap[active_node]=new Gnome::Canvas::Text(displayed_graph,
346 clicked_x+node_property_defaults[N_RADIUS]+5,
347 clicked_y+node_property_defaults[N_RADIUS]+5, "");
348 nodetextmap[active_node]->property_fill_color().set_value("darkblue");
349 nodetextmap[active_node]->raise_to_top();
351 // mapwin.updateNode(active_node);
352 propertyUpdate(active_node);
365 bool GraphDisplayerCanvas::createEdgeEventHandler(GdkEvent* e)
369 case GDK_BUTTON_PRESS:
370 //in edge creation right button has special meaning
371 if(e->button.button!=3)
373 //there is not yet selected node
374 if(active_node==INVALID)
376 //we mark the location of the event to be able to calculate parameters of dragging
378 window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
380 active_item=(get_item_at(clicked_x, clicked_y));
382 for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
384 if(nodesmap[i]==active_item)
389 //the clicked item is really a node
390 if(active_node!=INVALID)
392 *(nodesmap[active_node]) << Gnome::Canvas::Properties::fill_color("red");
395 //clicked item was not a node. It could be e.g. edge.
401 //we only have to do sg. if the mouse button
402 // is pressed already once AND the click was
403 // on a node that was found in the set of
404 //nodes, and now we only search for the second
408 window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
409 target_item=(get_item_at(clicked_x, clicked_y));
410 Node target_node=INVALID;
411 for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
413 if(nodesmap[i]==target_item)
418 //the clicked item is a node, the edge can be drawn
419 if(target_node!=INVALID)
421 (mytab.mapstorage)->modified = true;
423 *(nodesmap[target_node]) <<
424 Gnome::Canvas::Properties::fill_color("red");
427 active_edge=(mytab.mapstorage)->graph.addEdge(active_node,
431 for (std::map<std::string,
432 Graph::EdgeMap<double>*>::const_iterator it =
433 (mytab.mapstorage)->edgemap_storage.begin(); it !=
434 (mytab.mapstorage)->edgemap_storage.end(); ++it)
436 (*(it->second))[active_edge] =
437 (mytab.mapstorage)->edgemap_default[it->first];
439 // increment the id map's default value
440 (mytab.mapstorage)->edgemap_default["label"] += 1.0;
442 if(target_node!=active_node)
444 // set the coordinates of the arrow on the new edge
445 MapStorage& ms = *mytab.mapstorage;
446 ms.arrow_pos.set(active_edge,
447 (ms.coords[ms.graph.source(active_edge)] +
448 ms.coords[ms.graph.target(active_edge)])/ 2.0);
451 edgesmap[active_edge]=new BrokenEdge(displayed_graph, active_edge,
456 // set the coordinates of the arrow on the new edge
457 MapStorage& ms = *mytab.mapstorage;
458 ms.arrow_pos.set(active_edge,
459 (ms.coords[ms.graph.source(active_edge)] +
463 edgesmap[active_edge]=new LoopEdge(displayed_graph, active_edge,
467 //initializing edge-text as well, to empty string
468 XY text_pos=mytab.mapstorage->arrow_pos[active_edge];
469 text_pos+=(XY(10,10));
471 edgetextmap[active_edge]=new Gnome::Canvas::Text(displayed_graph,
472 text_pos.x, text_pos.y, "");
473 edgetextmap[active_edge]->property_fill_color().set_value(
475 edgetextmap[active_edge]->raise_to_top();
477 propertyUpdate(active_edge);
479 //clicked item was not a node. it could be an e.g. edge. we do not
480 //deal with it furthermore.
488 case GDK_BUTTON_RELEASE:
490 //we clear settings in two cases
491 //1: the edge is ready (target_item has valid value)
492 //2: the edge creation is cancelled with right button
493 if((target_item)||(e->button.button==3))
497 propertyUpdate(active_node,N_COLOR);
502 propertyUpdate((mytab.mapstorage)->graph.target(active_edge),N_COLOR);
515 bool GraphDisplayerCanvas::eraserEventHandler(GdkEvent* e)
519 case GDK_BUTTON_PRESS:
520 //finding the clicked items
521 window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
522 active_item=(get_item_at(clicked_x, clicked_y));
526 for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
528 if(nodesmap[i]==active_item)
534 if(active_node==INVALID)
536 for (EdgeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
538 if(edgesmap[i]->getLine()==active_item)
545 // return if the clicked object is neither an edge nor a node
546 if (active_edge == INVALID) return false;
548 //recolor activated item
551 *active_item << Gnome::Canvas::Properties::fill_color("red");
555 case GDK_BUTTON_RELEASE:
556 window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
559 //the cursor was not moved since pressing it
560 if( active_item == ( get_item_at (clicked_x, clicked_y) ) )
563 if(active_node!=INVALID)
565 (mytab.mapstorage)->modified = true;
567 std::set<Graph::Edge> edges_to_delete;
569 for(OutEdgeIt e((mytab.mapstorage)->graph,active_node);e!=INVALID;++e)
571 edges_to_delete.insert(e);
574 for(InEdgeIt e((mytab.mapstorage)->graph,active_node);e!=INVALID;++e)
576 edges_to_delete.insert(e);
579 //deleting collected edges
580 for(std::set<Graph::Edge>::iterator
581 edge_set_it=edges_to_delete.begin();
582 edge_set_it!=edges_to_delete.end();
585 deleteItem(*edge_set_it);
587 deleteItem(active_node);
589 //a simple edge was chosen
590 else if (active_edge != INVALID)
592 deleteItem(active_edge);
595 //pointer was moved, deletion is cancelled
598 if(active_node!=INVALID)
600 *active_item << Gnome::Canvas::Properties::fill_color("blue");
602 else if (active_edge != INVALID)
604 *active_item << Gnome::Canvas::Properties::fill_color("green");
614 case GDK_MOTION_NOTIFY:
623 bool GraphDisplayerCanvas::mapEditEventHandler(GdkEvent* e)
625 if(actual_tool==MAP_EDIT)
629 case GDK_BUTTON_PRESS:
631 //for determine, whether it was an edge
632 Edge clicked_edge=INVALID;
633 //for determine, whether it was a node
634 Node clicked_node=INVALID;
636 window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
637 active_item=(get_item_at(clicked_x, clicked_y));
639 //find the activated item between text of nodes
640 for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
642 //at the same time only one can be active
643 if(nodetextmap[i]==active_item)
649 //if there was not, search for it between nodes
650 if(clicked_node==INVALID)
652 for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
654 //at the same time only one can be active
655 if(nodesmap[i]==active_item)
662 if(clicked_node==INVALID)
664 //find the activated item between texts
665 for (EdgeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
667 //at the same time only one can be active
668 if(edgetextmap[i]==active_item)
674 //if it was not between texts, search for it between edges
675 if(clicked_edge==INVALID)
677 for (EdgeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
679 //at the same time only one can be active
680 if((edgesmap[i]->getLine())==active_item)
688 //if it was really a node...
689 if(clicked_node!=INVALID)
691 // the id map is not editable
692 if (nodemap_to_edit == "label") return 0;
694 //and there is activated map
695 if(nodetextmap[clicked_node]->property_text().get_value()!="")
697 //activate the general variable for it
698 active_node=clicked_node;
701 Gtk::Dialog dialog("Edit value", true);
702 dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
703 dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT);
704 Gtk::VBox* vbox = dialog.get_vbox();
705 Gtk::SpinButton spin(0.0, 4);
706 spin.set_increments(1.0, 10.0);
707 spin.set_range(-1000000.0, 1000000.0);
708 spin.set_numeric(true);
709 spin.set_value(atof(nodetextmap[active_node]->property_text().get_value().c_str()));
712 switch (dialog.run())
714 case Gtk::RESPONSE_NONE:
715 case Gtk::RESPONSE_CANCEL:
717 case Gtk::RESPONSE_ACCEPT:
718 double new_value = spin.get_value();
719 (*(mytab.mapstorage)->nodemap_storage[nodemap_to_edit])[active_node] =
721 std::ostringstream ostr;
723 nodetextmap[active_node]->property_text().set_value(ostr.str());
724 //mapwin.updateNode(active_node);
725 //mapwin.updateNode(Node(INVALID));
726 propertyUpdate(Node(INVALID));
731 //if it was really an edge...
732 if(clicked_edge!=INVALID)
734 // the id map is not editable
735 if (edgemap_to_edit == "label") return 0;
737 //and there is activated map
738 if(edgetextmap[clicked_edge]->property_text().get_value()!="")
740 //activate the general variable for it
741 active_edge=clicked_edge;
744 Gtk::Dialog dialog("Edit value", true);
745 dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
746 dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT);
747 Gtk::VBox* vbox = dialog.get_vbox();
748 Gtk::SpinButton spin(0.0, 4);
749 spin.set_increments(1.0, 10.0);
750 spin.set_range(-1000000.0, 1000000.0);
751 spin.set_numeric(true);
752 spin.set_value(atof(edgetextmap[active_edge]->property_text().get_value().c_str()));
755 switch (dialog.run())
757 case Gtk::RESPONSE_NONE:
758 case Gtk::RESPONSE_CANCEL:
760 case Gtk::RESPONSE_ACCEPT:
761 double new_value = spin.get_value();
762 (*(mytab.mapstorage)->edgemap_storage[edgemap_to_edit])[active_edge] =
764 std::ostringstream ostr;
766 edgetextmap[active_edge]->property_text().set_value(
768 //mapwin.updateEdge(active_edge);
769 // mapwin.updateEdge(Edge(INVALID));
770 propertyUpdate(Edge(INVALID));
783 void GraphDisplayerCanvas::deleteItem(Node node_to_delete)
785 delete(nodetextmap[node_to_delete]);
786 delete(nodesmap[node_to_delete]);
787 (mytab.mapstorage)->graph.erase(node_to_delete);
790 void GraphDisplayerCanvas::deleteItem(Edge edge_to_delete)
792 delete(edgetextmap[edge_to_delete]);
793 delete(edgesmap[edge_to_delete]);
794 (mytab.mapstorage)->graph.erase(edge_to_delete);
797 void GraphDisplayerCanvas::textReposition(XY new_place)
799 new_place+=(XY(10,10));
800 edgetextmap[forming_edge]->property_x().set_value(new_place.x);
801 edgetextmap[forming_edge]->property_y().set_value(new_place.y);
804 void GraphDisplayerCanvas::toggleEdgeActivity(EdgeBase* active_bre, bool on)
808 if(forming_edge!=INVALID)
810 std::cerr << "ERROR!!!! Valid edge found!" << std::endl;
814 for (EdgeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
816 if(edgesmap[i]==active_bre)
825 if(forming_edge!=INVALID)
827 forming_edge=INVALID;
831 std::cerr << "ERROR!!!! Invalid edge found!" << std::endl;
836 void GraphDisplayerCanvas::moveNode(double dx, double dy, Gnome::Canvas::Item * item, Node node)
838 Gnome::Canvas::Item * moved_item=item;
839 Node moved_node=node;
841 if(item==NULL && node==INVALID)
843 moved_item=active_item;
844 moved_node=active_node;
851 //repositioning node and its text
852 moved_item->move(dx, dy);
853 nodetextmap[moved_node]->move(dx, dy);
855 // the new coordinates of the centre of the node
856 double coord_x = dx + (mytab.mapstorage)->coords[moved_node].x;
857 double coord_y = dy + (mytab.mapstorage)->coords[moved_node].y;
859 // write back the new coordinates to the coords map
860 (mytab.mapstorage)->coords.set(moved_node, XY(coord_x, coord_y));
862 //all the edges connected to the moved point has to be redrawn
863 for(OutEdgeIt ei((mytab.mapstorage)->graph,moved_node);ei!=INVALID;++ei)
867 if (mytab.mapstorage->graph.source(ei) == mytab.mapstorage->graph.target(ei))
869 arrow_pos = mytab.mapstorage->arrow_pos[ei] + XY(dx, dy);
873 XY moved_node_1(coord_x - dx, coord_y - dy);
874 XY moved_node_2(coord_x, coord_y);
875 Node target = mytab.mapstorage->graph.target(ei);
876 XY fix_node(mytab.mapstorage->coords[target].x,
877 mytab.mapstorage->coords[target].y);
878 XY old_arrow_pos(mytab.mapstorage->arrow_pos[ei]);
880 arrow_pos = calcArrowPos(moved_node_1, moved_node_2, fix_node, old_arrow_pos, isbutton);
883 mytab.mapstorage->arrow_pos.set(ei, arrow_pos);
884 edgesmap[ei]->draw();
886 //reposition of edgetext
887 XY text_pos=mytab.mapstorage->arrow_pos[ei];
888 text_pos+=(XY(10,10));
889 edgetextmap[ei]->property_x().set_value(text_pos.x);
890 edgetextmap[ei]->property_y().set_value(text_pos.y);
893 for(InEdgeIt ei((mytab.mapstorage)->graph,moved_node);ei!=INVALID;++ei)
895 if (mytab.mapstorage->graph.source(ei) != mytab.mapstorage->graph.target(ei))
897 XY moved_node_1(coord_x - dx, coord_y - dy);
898 XY moved_node_2(coord_x, coord_y);
899 Node source = mytab.mapstorage->graph.source(ei);
900 XY fix_node(mytab.mapstorage->coords[source].x,
901 mytab.mapstorage->coords[source].y);
902 XY old_arrow_pos(mytab.mapstorage->arrow_pos[ei]);
905 arrow_pos = calcArrowPos(moved_node_1, moved_node_2, fix_node, old_arrow_pos, isbutton);
907 mytab.mapstorage->arrow_pos.set(ei, arrow_pos);
908 edgesmap[ei]->draw();
910 //reposition of edgetext
911 XY text_pos=mytab.mapstorage->arrow_pos[ei];
912 text_pos+=(XY(10,10));
913 edgetextmap[ei]->property_x().set_value(text_pos.x);
914 edgetextmap[ei]->property_y().set_value(text_pos.y);
919 Gdk::Color GraphDisplayerCanvas::rainbowColorCounter(double min, double max, double w)
923 double pos=(w-min)/(max-min);
926 //rainbow transitions contain 6 phase
927 //in each phase only one color is changed
928 //first we determine the phase, in which
929 //the actual value belongs to
930 for (int i=0;i<=5;i++)
932 if(((double)i/6<pos)&&(pos<=(double(i+1)/6)))
939 //within its 1/6 long phase the relativ position
940 //determines the power of the color changed in
942 //we normalize that to one, to be able to give percentage
943 //value for the function
944 double rel_pos=(pos-(phase/6))*6;
949 color.set_rgb_p (1, 0, 1-rel_pos);
952 color.set_rgb_p (1, rel_pos, 0);
955 color.set_rgb_p (1-rel_pos, 1, 0);
958 color.set_rgb_p (0, 1, rel_pos);
961 color.set_rgb_p (0, 1-rel_pos, 1);
964 color.set_rgb_p ((rel_pos/3), 0, 1);
967 std::cout << "Wrong phase: " << phase << " " << pos << std::endl;
972 std::cout << "Wrong phase: " << phase << " " << pos << std::endl;