Make PositionLabels have direction status indicators
[cs356-p1-elevator.git] / elevatorgui.cpp
index f9d03a1..2c82772 100644 (file)
@@ -30,8 +30,6 @@ ElevatorGUI::ElevatorGUI (int floors, int elevators)
        /* Fill in all of the ElevatorDoors and CallButtons */
        for (f_attach=0, f=floors-1; f>=0; --f, ++f_attach)
        {
-               std::cout << "at floor: " << f << std::endl;
-
                /* Create and attach the VBox */
                Gtk::VBox *box = new Gtk::VBox ();
                table_.attach (*box, 0, 1, f_attach, f_attach+1);
@@ -74,7 +72,6 @@ ElevatorGUI::ElevatorGUI (int floors, int elevators)
 
                for (e=0; e<elevators; ++e) // run left-to-right
                {
-                       std::cout << "Attaching ElevatorDoor (e=" << e << ", f=" << f << ")" << std::endl;
                        ElevatorDoor *door = new ElevatorDoor (e, f);
                        elevator_doors_.push_back (door);
                        table_.attach (*door, e+1, e+2, f_attach, f_attach+1);
@@ -232,20 +229,14 @@ void ElevatorGUI::on_call_button_toggled (CallButton *button)
        }
 }
 
-void ElevatorGUI::gui_update_position_label (int elevator, float new_position)
+void ElevatorGUI::gui_update_position_label (int elevator, float new_position, Direction direction)
 {
-       std::ostringstream str;
-
-       // Generate the text
-       str << std::setiosflags (std::ios_base::showpoint | std::ios_base::fixed)
-               << std::setprecision(1) << new_position;
-
        // Find the correct label and set it
        PositionLabelVector::iterator it;
 
        for (it=position_labels_.begin(); it!=position_labels_.end(); it++)
                if ((*it)->getElevatorNumber() == elevator)
-                       (*it)->set_text (str.str());
+                       (*it)->update_position (new_position, direction);
 }
 
 void ElevatorGUI::gui_unpress_call_button (int floor, Direction direction)