예제 #1
0
void ComboBox::updateSelectionFromEditor(void)
{
    if(getEditable() && getEditor() != NULL)
    {
        const boost::any& EditorItem = getEditor()->getItem();

        std::string EditorString;
        std::string ModelItemString;
        bool ExitLoop(false);
        for(UInt32 i(0) ; i<getModel()->getSize() && !ExitLoop ; ++i)
        {
            try
            {
                EditorString = lexical_cast(EditorItem);
                ModelItemString = lexical_cast(getModel()->getElementAt(i));
            }
            catch (boost::bad_lexical_cast &)
            {
                //Could not convert to string
            }
            if(EditorString.compare(ModelItemString) == 0)
            {
                ExitLoop = true;

                getModel()->setSelectedItem(i);
            }
        }
    }
}
예제 #2
0
 void *compile(const std::string code){
     static int count = 0;
     std::string cpp_file_name, o_file_name, so_file_name, clang_command_line;
     ++count;
     std::string count_str = lexical_cast(count);
     cpp_file_name = "cmpxx-temp-" + count_str + ".cpp";
     o_file_name = "cmpxx-temp-" + count_str + ".o";
     so_file_name = "./cmpxx-temp-" + count_str + CMPXX_DLEXT;
     {
         std::ofstream ofile(cpp_file_name.c_str());
         if(ofile.fail()){
             throw(ofile_error("cannot open file '" + cpp_file_name + "'."));
         }
         ofile << code;
     }
     int status;
     clang_command_line = "clang++ -std=c++11 -c -O2 " + cpp_file_name;
     status = std::system(clang_command_line.c_str());
     if(status != 0){
         throw(compile_error("compile failed. '" + clang_command_line + "'."));
     }
     clang_command_line = "clang++ -shared -o " + so_file_name + " " + o_file_name + " -lgmpxx -lgmp";
     status = std::system(clang_command_line.c_str());
     if(status != 0){
         throw(compile_error("compile failed. '" + clang_command_line + "'."));
     }
     void *handle = dlopen(so_file_name.c_str(), RTLD_LAZY);
     if(!handle){
         throw(compile_error("dlopen failed. '" + so_file_name + "'."));
     }
     return handle;
 }
예제 #3
0
파일: spu_pseudo.cpp 프로젝트: grumpos/spuc
std::string spu_make_pseudo( SPU_INSTRUCTION Instr, uint32_t IP )
{	
	const std::string		mnem = spu_decode_op_mnemonic(Instr.Instruction);

	if ( mnem.empty() )
		return ErrorUnknownInstruction(Instr.Instruction);

	const SPU_OP_TYPE		itype = spu_decode_op_type( Instr.Instruction );

	std::string				result = GetIntrinsicForm( mnem, itype );

	const SPU_OP_COMPONENTS comp = spu_decode_op_components( Instr.Instruction );
		
	replace_all( result, "$RT$", std::string("GPR(") + lexical_cast((uint16_t)comp.RT) + std::string(")") ); 

	switch (itype)
	{
	case SPU_OP_TYPE_RRR:
		{				
			replace_all( result, "$RC$", std::string("GPR(") + lexical_cast((uint16_t)comp.RC) + std::string(")") ); 
		}
	case SPU_OP_TYPE_RR:
		{
			replace_all( result, "$RB$", std::string("GPR(") + lexical_cast((uint16_t)comp.RB) + std::string(")") ); 
			replace_all( result, "$CA$", (comp.RA < 31) ? ChannelNames[comp.RA] : lexical_cast((uint16_t)comp.RA) );
		}
	case SPU_OP_TYPE_RI7:
	case SPU_OP_TYPE_RI8:
	case SPU_OP_TYPE_RI10:
	case SPU_OP_TYPE_RI16:
		{
			replace_all( result, "$RA$", std::string("GPR(") + lexical_cast((uint16_t)comp.RA) + std::string(")") ); 

			replace_all( result, "$IMM$", lexical_cast_hex((int32_t)comp.IMM) );
				
			replace_all( result, "$ADDR_REL$", lexical_cast_hex( 0x3fff0 & (IP + ((int32_t)comp.IMM * 2) )));
			break;
		}
	case SPU_OP_TYPE_RI18:
		{
			replace_all( result, "$RA$", std::string("GPR(") + lexical_cast((uint16_t)comp.RA) + std::string(")") ); 
			const size_t LSLR = 0x3FFFF;
			replace_all( result, "$IMM18$", lexical_cast_hex(comp.IMM & LSLR) );
			break;
		}
	case SPU_OP_TYPE_LBT:
	case SPU_OP_TYPE_LBTI:
		{
			replace_all( result, "$RA$", std::string("GPR(") + lexical_cast((uint16_t)comp.RA) + std::string(")") ); 

			replace_all( result, "$BRINST$", lexical_cast_hex((int32_t)comp.IMM) );
			replace_all( result, "$BRTARG$", lexical_cast_hex((int32_t)((uint64_t)comp.IMM >> 32)) );
			break;
		}
	}

	return result;
}
예제 #4
0
int HttpHeader::getStatusCode() const {
    ASSERT(valid());

    ASSERT(m_header.find("HTTP/1.1 ") == 0);
    const std::string statusString = m_header.substr(9, 3);
    int rVal;
    if (lexical_cast(statusString, rVal)) {
        return rVal;
    }
    return 502;
}
void DefaultComboBoxEditor::setItem(const boost::any& anObject)
{	
	//Update the text of the TextField to this new Item
	std::string TheText;
    try
    {
        TheText = lexical_cast(anObject);
    }
    catch (boost::bad_lexical_cast &)
    {
        //Could not convert to string
    }
    getEditor()->setText(TheText);
}
ComponentRefPtr DefaultTreeCellEditor::getTreeCellEditorComponent(TreeRefPtr TheTree, const boost::any& Value, bool IsSelected, bool IsExpanded, UInt32 row)
{
    _EditingValue = Value;

    if(_EditingValue.empty()){
        return NULL;
    }

    if(_EditingValue.type() == typeid(std::string))
    {
        //Use String Text Field As Editing Component
        std::string tempString;
        try
        {
            tempString = lexical_cast(_EditingValue);
        }
        catch (boost::bad_lexical_cast &)
        {
            //Could not convert to string
        }
        getDefaultStringEditor()->setText(tempString);
        getDefaultStringEditor()->selectAll();
        getDefaultStringEditor()->setCaretPosition(getDefaultStringEditor()->getText().size());

        getDefaultStringEditor()->addActionListener(&_DefaultTextFieldEditorListener);
        getDefaultStringEditor()->addFocusListener(&_DefaultTextFieldEditorListener);
        getDefaultStringEditor()->addKeyListener(&_DefaultTextFieldEditorListener);

        return getDefaultStringEditor();
    }
    else
    {
        //Use Default Text Field As Editing Component
        std::string tempString;
        getDefaultEditor()->setText(tempString);
        getDefaultEditor()->selectAll();
        getDefaultEditor()->setCaretPosition(getDefaultEditor()->getText().size());

        getDefaultEditor()->addActionListener(&_DefaultTextFieldEditorListener);
        getDefaultEditor()->addFocusListener(&_DefaultTextFieldEditorListener);
        getDefaultEditor()->addKeyListener(&_DefaultTextFieldEditorListener);

        return getDefaultEditor();
    }
}
ComponentTransitPtr DefaultTableCellEditor::getTableCellEditorComponent(Table* const table, const boost::any& value, bool isSelected, UInt32 row, UInt32 column)
{
    if(value.empty()){
        return ComponentTransitPtr(NULL);
    }
    TextFieldRefPtr TheTextField = TextField::create();
    std::string tempString;
    try
    {
        tempString = lexical_cast(value);
    }
    catch (boost::bad_lexical_cast &)
    {
        //Could not convert to string
    }
    TheTextField->setText(tempString);
    TheTextField->setPreferredSize(Vec2f(100,30));
    TheTextField->setAlignment(Vec2f(0.5,0.5));
    TheTextField->selectAll();
    TheTextField->setCaretPosition(TheTextField->getText().size());
    ColorLayerRefPtr tempBackground;
    tempBackground = ColorLayer::create();

    TheTextField->setBackground(tempBackground);

    //if(isSelected){
    //	tempBackground->setColor(Color4f(0.4, 0.4, 1.0, 1.0));
    //}
    //else{
    tempBackground->setColor(Color4f(1.0, 1.0, 1.0, 1.0));
    //}

    LineBorderRefPtr tempBorder;

    tempBorder = LineBorder::create();
    tempBorder->setColor(Color4f(0.0, 0.0, 1.0, 1.0));

    TheTextField->setBorder(tempBorder);

    setDefaultStringEditor(TheTextField);
    _EditorActionConnection = getDefaultStringEditor()->connectActionPerformed(boost::bind(&DefaultTableCellEditor::handleEditorAction, this, _1));
    _EditorFocusLostConnection = getDefaultStringEditor()->connectFocusLost(boost::bind(&DefaultTableCellEditor::handleEditorFocusLost, this, _1));
    _EditorKeyPressedConnection = getDefaultStringEditor()->connectKeyPressed(boost::bind(&DefaultTableCellEditor::handleEditorKeyPressed, this, _1));
    return ComponentTransitPtr(getDefaultStringEditor());
}
ComponentTransitPtr DefaultTreeCellEditor::getTreeCellEditorComponent(Tree* const TheTree, const boost::any& Value, bool IsSelected, bool IsExpanded, UInt32 row)
{
    _EditingValue = Value;

    if(_EditingValue.empty()){
        return ComponentTransitPtr(NULL);
    }

    if(_EditingValue.type() == typeid(std::string))
    {
        //Use String Text Field As Editing Component
        std::string tempString;
        try
        {
            tempString = lexical_cast(_EditingValue);
        }
        catch (boost::bad_lexical_cast &)
        {
            //Could not convert to string
        }
        getDefaultStringEditor()->setText(tempString);
        getDefaultStringEditor()->selectAll();
        getDefaultStringEditor()->setCaretPosition(getDefaultStringEditor()->getText().size());

        _EditorActionConnection = getDefaultStringEditor()->connectActionPerformed(boost::bind(&DefaultTreeCellEditor::handleEditorAction, this, _1));
        _EditorFocusLostConnection = getDefaultStringEditor()->connectFocusLost(boost::bind(&DefaultTreeCellEditor::handleEditorFocusLost, this, _1));
        _EditorKeyPressedConnection = getDefaultStringEditor()->connectKeyPressed(boost::bind(&DefaultTreeCellEditor::handleEditorKeyPressed, this, _1));

        return ComponentTransitPtr(getDefaultStringEditor());
    }
    else
    {
        //Use Default Text Field As Editing Component
        std::string tempString;
        getDefaultEditor()->setText(tempString);
        getDefaultEditor()->selectAll();
        getDefaultEditor()->setCaretPosition(getDefaultEditor()->getText().size());

        _EditorActionConnection = getDefaultEditor()->connectActionPerformed(boost::bind(&DefaultTreeCellEditor::handleEditorAction, this, _1));
        _EditorFocusLostConnection = getDefaultEditor()->connectFocusLost(boost::bind(&DefaultTreeCellEditor::handleEditorFocusLost, this, _1));
        _EditorKeyPressedConnection = getDefaultEditor()->connectKeyPressed(boost::bind(&DefaultTreeCellEditor::handleEditorKeyPressed, this, _1));

        return ComponentTransitPtr(getDefaultEditor());
    }
}
ComponentPtr DefaultDialogComponentGenerator::getQuestionComponent(DialogInterfacePtr Parent, const boost::any& Value)
{
    std::string questionString("");
    try
    {
        questionString = lexical_cast(Value);
    }
    catch (boost::bad_lexical_cast &)
    {
        std::cout<<"Unable to display question"<<std::endl;
    }

    LabelPtr TheQuestionString = Label::Ptr::dcast(getQuestionPrototype()->shallowCopy());
    beginEditCP(TheQuestionString, Label::TextFieldMask);
        TheQuestionString->setText(questionString);
    endEditCP(TheQuestionString, Label::TextFieldMask);

    return TheQuestionString;
}
/***************************************************************************\
 *                           Instance methods                              *
\***************************************************************************/
ComponentPtr DefaultCaptionComponentGenerator::getCaptionComponent(CaptionPtr Parent, const boost::any& Value)
{
    std::string CaptionSegment("");
    try
    {
        CaptionSegment = lexical_cast(Value);
    }
    catch (boost::bad_lexical_cast &)
    {
        std::cout<<"Unable to display segment"<<std::endl;
    }

    LabelPtr TheCaptionSegment = Label::Ptr::dcast(getCaptionSegmentPrototype()->shallowCopy());
    beginEditCP(TheCaptionSegment, Label::TextFieldMask);
        TheCaptionSegment->setText(CaptionSegment);
    endEditCP(TheCaptionSegment, Label::TextFieldMask);

    return TheCaptionSegment;
}
/***************************************************************************\
 *                           Instance methods                              *
\***************************************************************************/
ComponentPtr DefaultDialogComponentGenerator::getResponseComponent(DialogInterfacePtr Parent, const boost::any& Value)
{
    std::string responseString("");
    try
    {
        responseString = lexical_cast(Value);
    }
    catch (boost::bad_lexical_cast &)
    {
        std::cout<<"Unable to display response"<<std::endl;
    }

    ButtonPtr TheResponseButton = Button::Ptr::dcast(getResponseButtonPrototype()->shallowCopy());

    beginEditCP(TheResponseButton, Button::TextFieldMask);
        TheResponseButton->setText(responseString);
    endEditCP(TheResponseButton, Button::TextFieldMask);

    return TheResponseButton;
}
예제 #12
0
bool ComboBox::selectWithKey(KeyEventDetails::Key TheKey)
{
    UInt32 i(1);
    boost::any ModelElement;
    std::string TheText;

    bool ExitLoop(false);
    while(i<getModel()->getSize()  && !ExitLoop)
    {
        //Get The first character of this item
        ModelElement = getModel()->getElementAt((getModel()->getSelectedItemIndex() + i) % getModel()->getSize());

        try
        {
            TheText = lexical_cast(ModelElement);
        }
        catch (boost::bad_lexical_cast &)
        {
            //Could not convert to string
        }

        if(TheText.size() > 0 &&
           (TheText[0] == KeyEventDetails::getCharFromKey(TheKey, 0) ||
            TheText[0] == KeyEventDetails::getCharFromKey(TheKey, KeyEventDetails::KEY_MODIFIER_CAPS_LOCK)))
        {
            ExitLoop = true;
        }
        else
        {
            ++i;
        }
    }

    if(ExitLoop)
    {
        getModel()->setSelectedItem((getModel()->getSelectedItemIndex() + i) % getModel()->getSize());
    }

    return false;
}
void ListGeneratedPopupMenu::updateMenuItems(void)
{
    clearChildren();

    if(getModel() != NULL)// && )
    {
        MenuItemRefPtr Item;
        for(Int32 i(0) ; i<getModel()->getSize() ; ++i)
        {
            if(getCellGenerator() != NULL)
            {
                Item = ComponentMenuItem::create();
                ComponentRefPtr TheComponent = getCellGenerator()->getComponent(ListGeneratedPopupMenuRefPtr(this), getModel()->getElementAt(i), i, 0, false, false);

                TheComponent->setBackgrounds(NULL);


                dynamic_pointer_cast<ComponentMenuItem>(Item)->setComponent(TheComponent);
            }
            else
            {
                //Generate the Menu Item
                Item = MenuItem::create();
                std::string TheText;
                try
                {
                    TheText = lexical_cast(getModel()->getElementAt(i));
                }
                catch (boost::bad_lexical_cast &)
                {
                    //Could not convert to a string
                }
                dynamic_pointer_cast<MenuItem>(Item)->setText(TheText);
            }
            pushToChildren(Item);
        }
    }
    producePopupMenuContentsChanged(PopupMenuEvent::create(PopupMenuRefPtr(this), getSystemTime()));
}
ComponentTransitPtr ColorChooserComboBoxComponentGenerator::getComboBoxComponent(ComboBox* const Parent, const boost::any& Value, UInt32 Index, bool IsSelected, bool HasFocus)
{
	if(Value.empty()){
		return ComponentTransitPtr(NULL);
	}

	PanelRefPtr TheComponent = Panel::create();//dynamic_pointer_cast<Component>(getDrawObjectPrototype()->shallowCopy());
	TheComponent->setLayout(LayoutRefPtr(FlowLayout::create()));

	LabelRefPtr theColorLabel = Label::create();
	//theColorLabel->setPreferredSize(Vec2f(50.0f,50.0f));
	theColorLabel->setBorders(NULL);

	try
	{
		Color4f theColor = boost::any_cast<Color4f>(Value);

		if(theColor != NULL)
		{
			ColorLayerRefPtr theColorLabelBackground = ColorLayer::create();
			theColorLabelBackground->setColor(theColor);
			theColorLabel->setBackgrounds(theColorLabelBackground);
		}
	}
	catch(boost::bad_any_cast &)
	{
		std::string ValueString;

		try
		{
			ValueString = lexical_cast(Value);
		}
		catch (boost::bad_lexical_cast &)
		{
			//Could not convert to string
			SWARNING << "ColorChooserComboBoxComponentGenerator::getComboBoxComponent - The elements should either be a Color4f value or a std::string\n";
		}

		theColorLabel->setText(ValueString);

		if(IsSelected && HasFocus)
		{
			if(getFocusedTextColorHasPriority())
			{
				theColorLabel->setTextColors(getFocusedTextColor());
			}
			else
			{
				theColorLabel->setTextColors(getSelectedTextColor());
			}
		}
		else if(IsSelected)
		{
				theColorLabel->setTextColors(getSelectedTextColor());
		}
		else if(HasFocus)
		{
				theColorLabel->setTextColors(getFocusedTextColor());
		}
	}

	TheComponent->pushToChildren(theColorLabel);
    
	if(IsSelected && HasFocus)
	{
			if(getFocusedBorderHasPriority())
			{
				TheComponent->setBorders(getFocusedBorder());
			}
			else
			{
				TheComponent->setBorders(getSelectedBorder());
			}
			if(getFocusedBackgroundHasPriority())
			{
				TheComponent->setBackgrounds(getFocusedBackground());
			    TheComponent->setForegrounds(getFocusedForeground());
			}
			else
			{
				TheComponent->setBackgrounds(getSelectedBackground());
			    TheComponent->setForegrounds(getSelectedForeground());
			}
	}
	else if(IsSelected)
	{
			TheComponent->setBorders(getSelectedBorder());
			TheComponent->setBackgrounds(getSelectedBackground());
			TheComponent->setForegrounds(getSelectedForeground());
	}
	else if(HasFocus)
	{
			TheComponent->setBorders(getFocusedBorder());
			TheComponent->setBackgrounds(getFocusedBackground());
			TheComponent->setForegrounds(getFocusedForeground());
	}
	return ComponentTransitPtr(TheComponent.get());
}
OSG_BEGIN_NAMESPACE

/***************************************************************************\
 *                            Description                                  *
\***************************************************************************/

/*! \class OSG::DefaultStringTableCellRenderer
A DefaultStringTableCellRenderer.
*/

/***************************************************************************\
 *                           Class variables                               *
\***************************************************************************/

/***************************************************************************\
 *                           Class methods                                 *
\***************************************************************************/


/***************************************************************************\
 *                           Instance methods                              *
\***************************************************************************/

ComponentRefPtr DefaultStringTableCellRenderer::getTableCellRendererComponent(TableRefPtr table, const boost::any& value, bool isSelected, bool hasFocus, UInt32 row, UInt32 column)
{
    if(value.empty()){
        return NULL;
    }
    LabelRefPtr TheLabel = Label::create();
    std::string tempString;
    try
    {
        tempString = lexical_cast(value);
    }
    catch (boost::bad_lexical_cast &)
    {
        //Could not convert to string
    }
    TheLabel->setText(tempString);
    TheLabel->setPreferredSize(Vec2f(100,30));
    ColorLayerRefPtr tempBackground;
    tempBackground = ColorLayer::create();

    TheLabel->setBackgrounds(tempBackground);

    if(isSelected){
        tempBackground->setColor(Color4f(0.4, 0.4, 1.0, 1.0));
    }
    else{
        tempBackground->setColor(Color4f(1.0, 1.0, 1.0, 1.0));
    }

    if(hasFocus){
        LineBorderRefPtr tempBorder;

        tempBorder = LineBorder::create();
        TheLabel->setBorders(tempBorder);

        tempBorder->setColor(Color4f(0.0, 0.0, 1.0, 1.0));
    }
    else{
        EmptyBorderRefPtr tempBorder;

        tempBorder = EmptyBorder::create();
        TheLabel->setBorders(tempBorder);
    }
    return dynamic_pointer_cast<Component>(TheLabel);


}
예제 #16
0
void Robot::planAction(void) {
	ownTime_ms_delta_t hurryUp = 1000*60*11; // If it's time to abandon everything else and get current targets to the goal 
	static ownTime_ms_delta_t explRollStartTime = 0;
	static ownTime_ms_delta_t hidasprkl = 0;
	if (!manual.enabled) {
		if(statistics.taskStartTime == 0)
			statistics.taskStartTime = ownTime_get_ms();
		SLAM::RobotLocation p = slam.getCurrentMapData().getRobotLocation();
		std::cout << "PLANNER: ROBOT LOCATION " << p.x << " " << p.y << " " << p.theta << std::endl;
		switch (taskState) {
			case START: // roll around to discover empty areas
				if (!motionControl.rollStart(p))
					taskState = EXPLORE;
				break;
			case EXPLORE: // seek unexplored areas until targets visible
				if (ownTime_get_ms_since(hidasprkl) >= 5000) {
					hidasprkl = ownTime_get_ms();
					updateTargets();
				}
				if (targets.size()) {
					if (motionControl.running())
						motionControl.stop();
					taskState = GO_TO_TARGET;
					selectTarget();
					navigateTarget();
				} else {
					if (!motionControl.iterate(p) && explRollStartTime == 0) {
						explRollStartTime = ownTime_get_ms();
						motionControl.setCtrl(0, 1.0 / 10 * M_PI);
					} else if (explRollStartTime != 0 && ownTime_get_ms_since(explRollStartTime) > 3000) {
						motionControl.setCtrl(0, 0);
						SLAM::Location to(navigation.farthest());
						explRollStartTime = 0;
						std::cout << "PLANNER: explore to farthest " << to.x << " " << to.y << std::endl;
						navigation.solveTo(to);
						navigate();
						//explore();
					}
				}
				break;
			case GO_TO_TARGET: // Move near the nearest target to open the hatch
				if (motionControl.routeLeft() < HATCH_OPEN_DISTANCE) {
					if (approachStarted < 1) {
						approachStarted = ownTime_get_ms();
						break;
					}
					camera.rotateNear();
					if(ownTime_get_ms_since(approachStarted) < 1000) {
						if (motionControl.running()) {
							motionControl.stop();
						}
						break;
					}
					servoControl.setHatch(false);
					navigateTarget();
					approachStarted = 0;
					taskState = APPROACH_PICK_UP;
				}
				motionControl.iterate(p);
				break;
			case APPROACH_PICK_UP: // Move on close to target
				if (!motionControl.iterate(p)) {
					float clear = navigation.wallClearance(p);
					float walk = clear < PICKUPWALK ? clear : PICKUPWALK;
					navigation.solveTo(SLAM::Location(p.x + cos(p.theta) * walk, p.y + sin(p.theta) * walk));
					navigate();
					taskState = PICK_UP;
				}
				break;
			case GO_RETURN_TO_GOAL: // Try to find a route to the goal -- if cannot, explore more
				ownSleep_ms(1000);
				updateTargets();
				if (navigation.solveTo(SLAM::Location(0, 0))) {
					navigate();
					taskState = RETURN_TO_GOAL;
				} else {
					taskState = EXPLORE;
				}
				break;
			case RETURN_TO_GOAL: // Going to goal
				if (!motionControl.iterate(p)) {
					float clear = navigation.wallClearance(p);
					float walk = clear < GOALWALK ? clear : GOALWALK;
					navigation.solveTo(SLAM::Location(p.x + cos(p.theta) * walk, p.y + sin(p.theta) * walk));
					navigate();
					camera.rotateFar();
					taskState = GOAL_WALKHAX;
				}
				break;
			case GOAL_WALKHAX: // in goal, drive a bit forwards to be able to drop targets correctly
				if (!motionControl.iterate(p)) {
					taskState = RELEASE_TARGETS;
					servoControl.setHatch(false);
				}
				break;
			case PICK_UP: // when target is near, drive a bit forwards to be sure
				if (!motionControl.iterate(p)) {
					servoControl.setHatch(true);
					camera.rotateFar();
					numberOfPickUps++;
					speak("Pallo " + lexical_cast(numberOfPickUps));
					if(numberOfPickUps >= 10) {
						taskState = GO_RETURN_TO_GOAL;
					} else {
						if (targets.empty()) {
							taskState = EXPLORE;
						} else {
							selectTarget();
							navigateTarget();
							taskState = GO_TO_TARGET;
						}
						taskState = EXPLORE;
					}
				}
				break;
			case RELEASE_TARGETS: // eggs hatching, get back
				servoControl.setHatch(false);
				if (!motionControl.backFromGoal(p)) {
					taskState = RETURN_TO_GOAL_AGAIN;
					navigation.solveTo(SLAM::Location(0, 0));
					navigate();
				}
				break;
			case RETURN_TO_GOAL_AGAIN: // Going to goal another time to get last balls rolling
				if (!motionControl.iterate(p)) {
					float clear = navigation.wallClearance(p);
					float walk = clear < GOALWALK_AGAIN ? clear : GOALWALK_AGAIN;
					navigation.solveTo(SLAM::Location(p.x + cos(p.theta) * walk, p.y + sin(p.theta) * walk));
					navigate();
					camera.rotateFar();
					taskState = GOAL_WALKHAX_AGAIN;
				}
				break;
			case GOAL_WALKHAX_AGAIN: // in goal, drive a bit forwards to be able to drop targets correctly
				if (!motionControl.iterate(p)) {
					taskState = RELEASE_TARGETS_AGAIN;
				}
				break;
			case RELEASE_TARGETS_AGAIN: // they see me rollin', they hatin'
				if (!motionControl.backFromGoal(p)) {
					taskState = END_STATE;
				}
				break;
			case END_STATE: // world domination succeeded
				camera.rotateNear();
				speak("Hurraa");
				manual.enabled = true;
				break;
			case BACK_OFF: // bumpers hit. exit to exploring when bumpers not hitting anymore
				std::cout << "PLANNER: DYNDYNDYY" << std::endl;
				motionControl.backOff();
				break;
			default: throw std::runtime_error("Bad task state number"); break;
		}
		float timeSince = ownTime_get_ms_since(statistics.taskStartTime);
		if (timeSince >= hurryUp && (
				taskState == START
				|| taskState == EXPLORE
				|| taskState == GO_TO_TARGET
				|| taskState == APPROACH_PICK_UP
				|| taskState == PICK_UP
		   )) {
			taskState = GO_RETURN_TO_GOAL;
			speak("Hop hop hop");
		}
		std::cout << "PLANNER: CURRENT TASK: " << taskdescr[taskState] << ", time elapsed " << (timeSince / 1000) << std::endl;
	}
}
ComponentTransitPtr PanelListComponentGenerator::getListComponent(List* const Parent, const boost::any& Value, UInt32 Index, bool IsSelected, bool HasFocus)
{
	if(Value.empty()){
		return ComponentTransitPtr(NULL);
	}

	std::string ValueString;

    try
    {
        ValueString = lexical_cast(Value);
		PanelRefPtr theComponent = Panel::create();
	
		GridLayoutRefPtr PanelLayout = OSG::GridLayout::create();
		PanelLayout->setRows(3);
		PanelLayout->setColumns(1);
		PanelLayout->setHorizontalGap(0);
		PanelLayout->setVerticalGap(2);

		

		std::stringstream is;
		is<<Index;
		std::string iss;
		is>>iss;
		TextFieldRefPtr theName = TextField::create();
		theName->setText("Group"+iss);
		theName->setPreferredSize(Vec2f(146,20));
		

		PanelRefPtr rangePanel = Panel::create();
		
		GridLayoutRefPtr rangePanelLayout = OSG::GridLayout::create();
		rangePanelLayout->setRows(1);
		rangePanelLayout->setColumns(4);
		rangePanelLayout->setHorizontalGap(2);
		rangePanelLayout->setVerticalGap(0);

		
		LabelRefPtr rangeLabel = Label::create();
		rangeLabel->setText("Range:");
		rangeLabel->setPreferredSize(Vec2f(35,20));

		TextFieldRefPtr from = TextField::create();
		from->setEmptyDescText("From");
		from->setPreferredSize(Vec2f(35,20));

		LabelRefPtr hiphenLabel = Label::create();
		hiphenLabel->setText(" - ");
		hiphenLabel->setPreferredSize(Vec2f(35,20));

		TextFieldRefPtr to = TextField::create();
		to->setPreferredSize(Vec2f(35,20));
		to->setEmptyDescText("To");

		rangePanel->pushToChildren(rangeLabel);
		rangePanel->pushToChildren(from);
		rangePanel->pushToChildren(hiphenLabel);
		rangePanel->pushToChildren(to);
		rangePanel->setLayout(rangePanelLayout);
		rangePanel->setPreferredSize(Vec2f(146,20));

		DefaultMutableComboBoxModelRefPtr TheComboBoxModel = DefaultMutableComboBoxModel::create();
		TheComboBoxModel->addElement(boost::any(Color4f(1.0,0.0,0.0,1.0)));
		TheComboBoxModel->addElement(boost::any(Color4f(0.0,1.0,0.0,1.0)));
		TheComboBoxModel->addElement(boost::any(Color4f(0.0,0.0,1.0,1.0)));
		TheComboBoxModel->addElement(boost::any(Color4f(0.0,0.0,0.0,1.0)));
		TheComboBoxModel->addElement(boost::any(Color4f(1.0,1.0,1.0,1.0)));
		TheComboBoxModel->addElement(boost::any(std::string("More Colors")));

		ColorChooserComboBoxComponentGeneratorRefPtr TheColorChooserComboBoxComponentGenerator = ColorChooserComboBoxComponentGenerator::create();
		
		//Create the ComboBox
		ComboBoxRefPtr TheComboBox = ComboBox::create();
		TheComboBox->setModel(TheComboBoxModel);
		TheComboBox->setCellGenerator(TheColorChooserComboBoxComponentGenerator);
		TheComboBox->setEditable(false);
		TheComboBox->setSelectedIndex(0);
		TheComboBox->setPreferredSize(Vec2f(146,20));

		theComponent->pushToChildren(theName);
		theComponent->pushToChildren(rangePanel);
		theComponent->pushToChildren(TheComboBox);
		theComponent->setLayout(PanelLayout);
		theComponent->setPreferredSize(Vec2f(146,66));

		Parent->setCellMajorAxisLength(66);

		return ComponentTransitPtr(theComponent.get());

    }
    catch (boost::bad_lexical_cast &)
    {
        return ComponentTransitPtr(NULL);
    }

}