示例#1
0
GuiElement::GuiElement(std::string text, SDL_Keycode hotKey, int x, int y) : 
	GUI_BUTTON_WIDTH(Config::get().getValue("gui_button_width")),
	GUI_BUTTON_HEIGHT(Config::get().getValue("gui_button_height")),
	mX(x),
	mY(y),
	mText(text),
	mHotKey(hotKey),
	mRect(createRectangle(mX, mY, GUI_BUTTON_WIDTH, GUI_BUTTON_HEIGHT))
{ }
示例#2
0
HighlightedGrid::HighlightedGrid( Grid &grid,ResourceHolder* res_container, const int &starting_index)  {       //creates a 3x3 grid representing playable areas

    highlighted_grid_sprite.setTexture(res_container->textures.get("Highlight"));
    highlighted_grid = createRectangle(sf::Vector2f(grid.getGridSize(),grid.getGridSize()),grid.getPosition(starting_index));
    highlighted_grid.setOutlineColor(sf::Color::Transparent);
    highlighted_grid_sprite.setPosition(highlighted_grid.getPosition().x-39,
                                        highlighted_grid.getPosition().y-39);
    highlighted_grid_sprite.setColor(sf::Color::White);
    grid_ptr = &grid;
}
示例#3
0
Gui::BrowserPanel::BrowserPanel(int sh, int sw, int geh, int bpw, int bph, int gbh, int gplp, int gptp) :
	SCREEN_HEIGHT(sh),
	SCREEN_WIDTH(sw),
	GUI_ELEMENT_HEIGHT(geh),
	GUI_BROWSERPANEL_WIDTH(bpw),
	GUI_BROWSERPANEL_HEIGHT(bph),
	GUI_BUTTON_HEIGHT(gbh),
	GUI_PANEL_LEFT_PADDING(gplp),
	GUI_PANEL_TOP_PADDING(gptp),
	mRect(createRectangle(SCREEN_WIDTH / 2 - GUI_BROWSERPANEL_WIDTH / 2, SCREEN_HEIGHT / 2 - GUI_BROWSERPANEL_HEIGHT / 2, GUI_BROWSERPANEL_WIDTH, GUI_BROWSERPANEL_HEIGHT))
{}
示例#4
0
GLC_3DViewInstance GLC_Factory::createRectangle(const GLC_Point3d& point, const GLC_Vector3d& normal, double l1, double l2)
{
	// Create the rectangle to (0,0) and  z normal
	GLC_3DViewInstance rectangleInstance(createRectangle(l1, l2));

	// Create the plane rotation matrix
	const GLC_Matrix4x4 rotationMatrix(glc::Z_AXIS, normal);
	// Vector from origin to the plane
	rectangleInstance.setMatrix(GLC_Matrix4x4(point) * rotationMatrix);

	return rectangleInstance;
}
示例#5
0
osg::Node* createModel(const std::string& filename)
{
    osg::Group* root = new osg::Group;

    if (filename != "X") {
        osg::BoundingBox bb(0.0f,0.0f,0.0f,1.0f,1.0f,1.0f);
        root->addChild(createRectangle(bb, filename)); // XXX
    }

    root->addChild(createHUD());

    return root;
}
示例#6
0
文件: Image.cpp 项目: Gerjo/phantom
    Image::Image(const std::string filelocation, float x, float y, float width, float height) {
        this->x = x;
        this->y = y;
        this->_width = width;
        this->_height = height;
        isImage = true;

        ImageCache *imageCache = ImageCache::getInstance();

        if(!imageCache->isCached(filelocation)) {
            imageCache->insertIntoCache(filelocation, ImageLoader::createPNG(filelocation));
        }
        _imageItem = imageCache->getFromCache(filelocation);

        createRectangle();
    }
示例#7
0
Gui::Gui() : 
	mRect(createRectangle(0, 0, Config::get().getValue("gui_width"), Config::get().getValue("screen_height"))),
	mIsInputActive(false),
	mIsBrowserActive(false),	
	GUI_ELEMENT_HEIGHT(Config::get().getValue("gui_element_height")),
	GUI_LEFT_PADDING(Config::get().getValue("gui_left_padding")),
	GUI_BUTTON_WIDTH(Config::get().getValue("gui_button_width")),
	GUI_BUTTON_HEIGHT(Config::get().getValue("gui_button_height")),
	SCREEN_WIDTH(Config::get().getValue("screen_width")),
	SCREEN_HEIGHT(Config::get().getValue("screen_height")),
	GUI_INPUTPANEL_WIDTH(Config::get().getValue("gui_inputpanel_width")),
	GUI_INPUTPANEL_HEIGHT(Config::get().getValue("gui_inputpanel_height")),
	GUI_BROWSERPANEL_WIDTH(Config::get().getValue("gui_browserpanel_width")),
	GUI_BROWSERPANEL_HEIGHT(Config::get().getValue("gui_browserpanel_height")),	
	GUI_PANEL_LEFT_PADDING(Config::get().getValue("gui_panel_left_padding")),
	GUI_PANEL_TOP_PADDING(Config::get().getValue("gui_panel_top_padding")),
	mInputPanel(SCREEN_WIDTH, SCREEN_HEIGHT, GUI_INPUTPANEL_WIDTH, GUI_INPUTPANEL_HEIGHT, GUI_PANEL_LEFT_PADDING, GUI_PANEL_TOP_PADDING),
	mBrowserPanel(SCREEN_HEIGHT, SCREEN_WIDTH, GUI_ELEMENT_HEIGHT, GUI_BROWSERPANEL_WIDTH, GUI_BROWSERPANEL_HEIGHT, GUI_BUTTON_HEIGHT, GUI_PANEL_LEFT_PADDING, GUI_PANEL_TOP_PADDING)
{
}
示例#8
0
Path Path::createRoundedRectangle(const FloatRect& rectangle, const FloatSize& topLeftRadius, const FloatSize& topRightRadius, const FloatSize& bottomLeftRadius, const FloatSize& bottomRightRadius)
{
    Path path;

    float width = rectangle.width();
    float height = rectangle.height();
    if (width <= 0.0 || height <= 0.0)
        return path;

    if (width < topLeftRadius.width() + topRightRadius.width()
            || width < bottomLeftRadius.width() + bottomRightRadius.width()
            || height < topLeftRadius.height() + bottomLeftRadius.height()
            || height < topRightRadius.height() + bottomRightRadius.height())
        // If all the radii cannot be accommodated, return a rect.
        return createRectangle(rectangle);

    float x = rectangle.x();
    float y = rectangle.y();

    path.moveTo(FloatPoint(x + topLeftRadius.width(), y));

    path.addLineTo(FloatPoint(x + width - topRightRadius.width(), y));

    path.addBezierCurveTo(FloatPoint(x + width - topRightRadius.width() * (1 - QUARTER), y), FloatPoint(x + width, y + topRightRadius.height() * (1 - QUARTER)), FloatPoint(x + width, y + topRightRadius.height()));

    path.addLineTo(FloatPoint(x + width, y + height - bottomRightRadius.height()));

    path.addBezierCurveTo(FloatPoint(x + width, y + height - bottomRightRadius.height() * (1 - QUARTER)), FloatPoint(x + width - bottomRightRadius.width() * (1 - QUARTER), y + height), FloatPoint(x + width - bottomRightRadius.width(), y + height));

    path.addLineTo(FloatPoint(x + bottomLeftRadius.width(), y + height));

    path.addBezierCurveTo(FloatPoint(x + bottomLeftRadius.width() * (1 - QUARTER), y + height), FloatPoint(x, y + height - bottomLeftRadius.height() * (1 - QUARTER)), FloatPoint(x, y + height - bottomLeftRadius.height()));

    path.addLineTo(FloatPoint(x, y + topLeftRadius.height()));

    path.addBezierCurveTo(FloatPoint(x, y + topLeftRadius.height() * (1 - QUARTER)), FloatPoint(x + topLeftRadius.width() * (1 - QUARTER), y), FloatPoint(x + topLeftRadius.width(), y));

    path.closeSubpath();

    return path;
}
示例#9
0
void SelectionPlugin::onMouseDrag( const MouseDragEvent& event )
{
	EventManager* events = editor->getEventManager();

	if( events->getCurrentToolId() != SelectionTool::Select )
		return;

	if( !event.info->leftButton )
		return;

	if( !selections->dragRectangle )
	{
		selections->dragRectangle = createRectangle();

		Document* document = editor->getDocument();
		if( !document ) return;
	
		SceneDocument* sceneDocument = (SceneDocument*) document;
		sceneDocument->editorScene->entities.add(selections->dragRectangle);
	}
	
	updateRectangle( event, selections->dragRectangle.get() );
}
示例#10
0
	void initialize (GLfloat cx, GLfloat cy, GLfloat l, GLfloat b, GLfloat ang, GLfloat col_R, GLfloat col_G, GLfloat col_B)
	{
		centre_x = cx;	centre_y = cy;		length = l; breadth = b;		angle = ang;
		GLfloat tx, ty;

		tx = length/2;
		ty = breadth/2;

		x1 = (-tx*cos(angle)) - (-ty*sin(angle));
		y1 = (-tx*sin(angle)) + (-ty*cos(angle));
		x1+=centre_x;
		y1+=centre_y;


		x2 = (-tx*cos(angle)) - (ty*sin(angle));
		y2 = (-tx*sin(angle)) + (ty*cos(angle));
		x2+=centre_x;
		y2+=centre_y;

		
		x3 = (tx*cos(angle)) - (ty*sin(angle));
		y3 = (tx*sin(angle)) + (ty*cos(angle));
		x3+=centre_x;
		y3+=centre_y;



		x4 = (tx*cos(angle)) - (-ty*sin(angle));
		y4 = (tx*sin(angle)) + (-ty*cos(angle));
		x4+=centre_x;
		y4+=centre_y;

		radius = (length+breadth)/2;

		createRectangle(x1, y1, x2, y2, x3, y3, x4, y4, col_R, col_G, col_B);
	}
void TrackDisplay::update(float wall_dt, float ros_dt) {
	V_TrackMsg local_queue;

	{
		boost::mutex::scoped_lock lock(queue_mutex_);

		local_queue.swap(message_queue_);
	}

	for (size_t t = 0; t < local_queue.size(); t++) {
		const articulation_msgs::TrackMsg::ConstPtr& track_message =
				local_queue[t];

		for(size_t l=0;l<lines[track_message->id].size();l++)
			lines[track_message->id][l]->clear();
		recycleLines.insert(recycleLines.begin(),
				lines[track_message->id].begin(),
				lines[track_message->id].end());

		lines[track_message->id].clear();
	}

	for (size_t t = 0; t < local_queue.size(); t++) {
		const articulation_msgs::TrackMsg::ConstPtr& track_message =
				local_queue[t];

		btTransform framePose;
		btVector3 lineScale(lineWidth_, lineWidth_, lineWidth_);
		transform(track_message, framePose);

		int channel_w = -1;
		int channel_h = -1;
		for (size_t i = 0; i < track_message->channels.size(); i++) {
			if (track_message->channels[i].name == "width")
				channel_w = (int) i;
			if (track_message->channels[i].name == "height")
				channel_h = (int) i;
		}

		Ogre::Vector3 old_pos(0,0,0);
		for (size_t i = 0; i < track_message->pose.size(); i++) {
			const geometry_msgs::Pose& geo_pose = track_message->pose[i];

			btTransform rectangle_pose(btQuaternion(geo_pose.orientation.x,
					geo_pose.orientation.y, geo_pose.orientation.z,
					geo_pose.orientation.w), btVector3(geo_pose.position.x,
					geo_pose.position.y, geo_pose.position.z));

			Ogre::Vector3 pos, scale;
			Ogre::Quaternion orient;
			transform(framePose * rectangle_pose, lineScale, pos, orient, scale);

			btVector3 color(color_.r_, color_.g_, color_.b_);	// fixed color

			double f =track_message->id / 7.0;
			color = modifyColor( color,  trackColor_, f - floor(f) );
			color = modifyColor( color,  poseColor_, i / (double)track_message->pose.size() );

			if(displayStyle_ == ds_line) {
				if(i==0) old_pos = pos;
				createLine(pos, old_pos, scale,
						color,
						lines[track_message->id],false);
				old_pos = pos;
			} else
			if(displayStyle_ == ds_cross_line) {
				if(i==0) old_pos = pos;
				createLine(pos, old_pos, scale,
						color,
						lines[track_message->id],true);
				old_pos = pos;
			} else
			if(displayStyle_ == ds_axes) {
				createAxes(pos, orient, scale,
						color,
						lines[track_message->id]);
			} else
			if(displayStyle_ == ds_rectangle) {
				createRectangle(pos, orient, scale,
						channel_w==-1? lineWidth_*5 : track_message->channels[channel_w].values[i],
						channel_h==-1? lineWidth_*5 : track_message->channels[channel_h].values[i],
						color,
						lines[track_message->id]);
			}
		}
	}
}
示例#12
0
Gui::InputPanel::InputPanel(int SCREEN_WIDTH, int SCREEN_HEIGHT, int GUI_INPUTPANEL_WIDTH, int GUI_INPUTPANEL_HEIGHT, int GUI_PANEL_LEFT_PADDING, int GUI_PANEL_TOP_PADDING) :
	GUI_PANEL_LEFT_PADDING(GUI_PANEL_LEFT_PADDING),
	GUI_PANEL_TOP_PADDING(GUI_PANEL_TOP_PADDING),
	mRect(createRectangle(SCREEN_WIDTH / 2 - GUI_INPUTPANEL_WIDTH / 2, SCREEN_HEIGHT / 2 - GUI_INPUTPANEL_HEIGHT / 2, GUI_INPUTPANEL_WIDTH, GUI_INPUTPANEL_HEIGHT)),
	mTextBorder(createRectangle(mRect.x + 5, mRect.y + 35, GUI_INPUTPANEL_WIDTH - 10, 25 ))
{}
示例#13
0
Gui::BrowserButton::BrowserButton(int x, int y, int w, int h, std::string text) : mRect(createRectangle(x,y,w,h)), mText(text)
{}
示例#14
0
Label::Label(std::string text, std::string content, SDL_Color color, int x, int y) : GuiElement(text, SDLK_UNKNOWN, x, y), mContent(content), mColor(color)
{
	mRect = createRectangle(-10, -10, 0, 0);
}
示例#15
0
void init_measurestate() {
	COMPONENT* lblTitle;
	COMPONENT* btnRound;
	COMPONENT* circle;
	COMPONENT* btnFlat;
	COMPONENT* rectangle;
	COMPONENT* btnOval;
	COMPONENT* oval;
	COMPONENT* btnRoundRect;
	COMPONENT* roundrect;

	int btnWidth, circleWidth, rectWidth, ovalWidth, roundrectWidth;

#if DEBUG_STATES > 1
	printf("Measure state! \n");
#endif
	containerClear();

	lblTitle = createLabel(LBL_TITLE, "Select spoke type:", 10, 5);
	if (!lblTitle) {
		// error
	}

	circle = createCircle(NAME_CIRCLE, 0, componentGetBottom(lblTitle) + 5,
			CIRCLE_RADIUS, 0x00FF0000, GUI_PEN_SOLID);
	if (!circle) {
		// error
	}

	btnRound = createButton(BTN_ROUND, "Round spoke", 20, componentGetBottom(
			circle) + 2);
	if (!btnRound) {
		// error
	}

	rectangle = createRectangle(NAME_RECT, 0, componentGetBottom(btnRound) + 5,
			RECT_WIDTH, RECT_HEIGHT, 0x00FF0000, GUI_PEN_SOLID);
	if (!rectangle) {
		// error
	}

	btnFlat = createButton(BTN_FLAT, "Flatten spoke", 20, componentGetBottom(
			rectangle) + 2);
	if (!btnFlat) {
		// error
	}

	oval = createOval(NAME_RECT, 0, componentGetBottom(btnFlat) + 5, OVAL_X,
			OVAL_Y, 0x00FF0000, GUI_PEN_SOLID);
	if (!oval) {
		// error
	}

	btnOval = createButton(BTN_OVAL, "Oval spoke", 20, componentGetBottom(oval)
			+ 2);
	if (!btnOval) {
		// error
	}

	roundrect = createRoundrect(NAME_ROUND_RECT, 0, componentGetBottom(btnOval)
			+ 5, RND_RECT_OUTER_WIDTH, RND_RECT_INNER_WIDTH, RND_RECT_HEIGHT,
			0x00FF0000, GUI_PEN_SOLID);
	if (!roundrect) {
		// error
	}

	btnRoundRect = createButton(BTN_ROUNDRECT, "Rounded rect spoke", 20,
			componentGetBottom(roundrect) + 2);
	if (!btnRoundRect) {
		// error
	}

	btnWidth = componentGetWidth(btnRound);
	circleWidth = componentGetWidth(circle);
	rectWidth = componentGetWidth(rectangle);
	ovalWidth = componentGetWidth(oval);
	roundrectWidth = componentGetWidth(roundrect);

	componentSetX(circle, (btnWidth - circleWidth) / 2
			+ componentGetX(btnRound));

	btnWidth = componentGetWidth(btnFlat);
	componentSetX(rectangle, (btnWidth - rectWidth) / 2
			+ componentGetX(btnFlat));

	btnWidth = componentGetWidth(btnOval);
	componentSetX(oval, (btnWidth - ovalWidth) / 2 + componentGetX(btnOval));

	btnWidth = componentGetWidth(btnRoundRect);
	componentSetX(roundrect, (btnWidth - roundrectWidth) / 2 + componentGetX(
			btnRoundRect));

#if DEBUG_STATES > 1
	printf("Rectangle:\nx: %d\ny: %d\nwidth: %d\nheight: %d\n", componentGetX(
					rectangle), componentGetY(rectangle), componentGetWidth(rectangle),
			componentGetHeight(rectangle));
	fflush(stdout);
#endif
}