Exemplo n.º 1
0
// dieses Rect relativ zum anderen...
eTouchType Rect::getTouchType(const Rect& rect) const
{
	if(!isTouched(rect)) {
		return TOUCHES_NO_TOUCH;
	}

	// ist 'rect' innerhalb dieses Rects?
	if(isRectInside(rect)) {
		return TOUCHES_IS_COMPLETELY_INSIDE;
	} else if(isTopLeftCornerInside(rect.getTopLeft()) && isBottomLeftCornerInside(rect.getBottomLeft())) {
		return TOUCHES_CROSSES_RIGHT_BORDER;
	} else if(isTopLeftCornerInside(rect.getTopLeft()) && isTopRightCornerInside(rect.getTopRight())) {
		return TOUCHES_CROSSES_LOWER_BORDER;
	} else if(isTopRightCornerInside(rect.getTopRight()) && isBottomRightCornerInside(rect.getBottomRight())) {
		return TOUCHES_CROSSES_LEFT_BORDER;
	} else if(isBottomRightCornerInside(rect.getBottomRight()) && isBottomLeftCornerInside(rect.getBottomLeft())) {
		return TOUCHES_CROSSES_UPPER_BORDER;
	} else if(isTopLeftCornerInside(rect.getTopLeft())) {
		return TOUCHES_CROSSES_BOTTOM_RIGHT_CORNER;
	} else if(isTopRightCornerInside(rect.getTopRight())) {
		return TOUCHES_CROSSES_BOTTOM_LEFT_CORNER;
	} else if(isBottomRightCornerInside(rect.getBottomRight())) {
		return TOUCHES_CROSSES_TOP_LEFT_CORNER;
	} else if(isBottomLeftCornerInside(rect.getBottomLeft())) {
		return TOUCHES_CROSSES_TOP_RIGHT_CORNER;
	}

	else if((rect.getLeft() < getLeft()) && (rect.getRight() > getRight()) && (rect.getTop() >= getTop()) && (rect.getBottom() <= getBottom())) { // ? = 
		return TOUCHES_CROSSES_LEFT_AND_RIGHT_BORDER;
	} else if((rect.getTop() < getTop()) && (rect.getBottom() > getBottom()) && (rect.getLeft() >= getLeft()) && (rect.getRight() <= getRight())) {
		return TOUCHES_CROSSES_TOP_AND_BOTTOM_BORDER;
	}

	else if((rect.getLeft() == getRight()) && (rect.getTop() == getTop()) && (rect.getBottom() == getBottom())) {
		return TOUCHES_RIGHT_BORDER;
	} else if((rect.getTop() == getBottom()) && (rect.getLeft() == getLeft()) && (rect.getRight() == getRight())) {
		return TOUCHES_LOWER_BORDER;
	} else if((rect.getRight() == getLeft()) && (rect.getTop() == getTop()) && (rect.getBottom() == getBottom())) {
		return TOUCHES_LEFT_BORDER;
	} else if((rect.getBottom() == getTop()) && (rect.getLeft() == getLeft()) && (rect.getRight() == getRight())) {
		return TOUCHES_UPPER_BORDER;
	}

	else if((rect.isTopLeftCornerInside(getTopLeft())) && (rect.isTopRightCornerInside(getTopRight())) && (!rect.isBottomRightCornerInside(getBottomRight())) && (!rect.isBottomLeftCornerInside(getBottomLeft()))) {
		return TOUCHES_CROSSES_UPPER_AREA;
	} else if((!rect.isTopLeftCornerInside(getTopLeft())) && (rect.isTopRightCornerInside(getTopRight())) && (rect.isBottomRightCornerInside(getBottomRight())) && (!rect.isBottomLeftCornerInside(getBottomLeft()))) {
		return TOUCHES_CROSSES_RIGHT_AREA;
	} else if((!rect.isTopLeftCornerInside(getTopLeft())) && (!rect.isTopRightCornerInside(getTopRight())) && (rect.isBottomRightCornerInside(getBottomRight())) && (rect.isBottomLeftCornerInside(getBottomLeft()))) {
		return TOUCHES_CROSSES_LOWER_AREA;
	} else if((rect.isTopLeftCornerInside(getTopLeft())) && (!rect.isTopRightCornerInside(getTopRight())) && (!rect.isBottomRightCornerInside(getBottomRight())) && (rect.isBottomLeftCornerInside(getBottomLeft()))) {
		return TOUCHES_CROSSES_LEFT_AREA;
	}

	else { 
		return TOUCHES_NO_TOUCH;
	}
}
Exemplo n.º 2
0
bool Field::qcanBeatTL(const Cell *arg)
{
    if( arg == NULL || !arg->getFigure().isQueen() )
    {
        string exep = "ERROR! qcanBeatTL function cannot take not queen, or arg is NULL\n";
        throw exep;
    }

    unsigned char tmpcol = arg->getFigure().getColor();
    bool was_token = false;

    Cell* temp = getTopLeft(arg);                          // Top Left element

    while( temp != NULL )                                   // while it's not an end of field
    {
        if( temp->isEmpty() )                               // if it's empty cell
        {
            if( was_token )                                 // and we beated some figure
            {
                temp->setCanMove(true);                     // then we can move on this
            }
            temp = getTopLeft(temp);                       // set checking on next top right cell
        }

        else                                                // if it's not empty cell
        {
            if( temp->getFigure().getColor() == tmpcol )    // if it's friendly figure
            {
                break;
            }
            else                                            // !!! if it's an empty cell
            {
                if( was_token )                             // we can beat only 1 time per move!
                {
                    break;
                }

                // !!! not token
                if( getTopLeft(temp)->isEmpty() )          // if next one is empty
                {
                    was_token = true;                       // we beated!
                    temp = getTopLeft(temp);               // move to that pozition
                    temp->setCanMove(true);
                }
            }
        }
    }
    return was_token;
}
Exemplo n.º 3
0
void ofxQuadImage::draw(){

    ofSetColor(255);
    ofEnableAlphaBlending();
    img.draw(getTopLeft().x,
             getTopLeft().y,
             getWidth(),
             getHeight()
             );

    ofxQuad::draw();

    
    
}
Exemplo n.º 4
0
bool glmRectangle::clip( glm::vec3& _p0, glm::vec3& _p1) const {
    
    glm::vec3 topLeft     = getTopLeft();
    glm::vec3 topRight    = getTopRight();
    glm::vec3 bottomRight = getBottomRight();
    glm::vec3 bottomLeft  = getBottomLeft();
    
    if (!inside(_p0)) {
        glm::vec3 r;
        if (LineSegmentIntersection(_p0, _p1, topLeft,     topRight,    r)){
            _p0 = r;
        } else if (LineSegmentIntersection(_p0, _p1, topRight,    bottomRight, r)){
            _p0 = r;
        } else if (LineSegmentIntersection(_p0, _p1, bottomRight, bottomLeft,  r)){
            _p0 = r;
        } else if (LineSegmentIntersection(_p0, _p1, bottomLeft,  topLeft,     r)){
            _p0 = r;
        }
    }
    
    if (!inside(_p1)) {
        glm::vec3 r;
        if (LineSegmentIntersection(_p1, _p0, topLeft,     topRight,    r)){
            _p1 = r;
        } else if (LineSegmentIntersection(_p1, _p0, topRight,    bottomRight, r)){
            _p1 = r;
        } else if (LineSegmentIntersection(_p1, _p0, bottomRight, bottomLeft,  r)){
            _p1 = r;
        } else if (LineSegmentIntersection(_p1, _p0, bottomLeft,  topLeft,     r)){
            _p1 = r;
        }
    }
}
Exemplo n.º 5
0
QPainterPath LineBand::path()
{
	//move the path so it accounts for the position of the selectionband
	QPainterPath temppath = mIntersectionPath;
	temppath.translate(getTopLeft());
	return temppath;
}
Exemplo n.º 6
0
void TabList::draw () const {
    Vector2f origin = getTopLeft();

    int mirror(locales::getCurrentLocale().LTR_ ? 1 : -1);

    glBlendFunc(GL_SRC_ALPHA, GL_ONE);

    glLineWidth(2.f);
    glBegin(GL_LINES);
        if (isTopMost())  glColor4f(1.f, 0.5f, 0.8f, 1.0f);
        else              glColor4f(0.4f, 0.4f, 0.4f, 1.0f);
        glVertex2f(origin.x_,origin.y_+20);
        if (isTopMost())  glColor4f(1.f, 0.5f, 0.8f, 0.0f);
        else              glColor4f(0.4f, 0.4f, 0.4f, 0.0f);
        glVertex2f(origin.x_,origin.y_+height_);

        if (isTopMost())  glColor4f(1.f, 0.5f, 0.8f, 1.0f);
        else              glColor4f(0.4f, 0.4f, 0.4f, 1.0f);
        glVertex2f(origin.x_+lastTabEnd_*mirror,origin.y_+20);
        if (isTopMost())  glColor4f(1.f, 0.5f, 0.8f, 0.0f);
        else              glColor4f(0.4f, 0.4f, 0.4f, 0.0f);
        glVertex2f(origin.x_+width(),origin.y_+20);
    glEnd();

    for (std::vector<Tab*>::const_iterator i=tabs_.begin(); i != tabs_.end(); ++i)
        (*i)->draw();
}
Exemplo n.º 7
0
		//----------
		AbstractPin::AbstractPin(string name) : name(name) {
			this->pinView = make_shared<Editor::PinView>();

			this->onDraw += [this](ofxCvGui::DrawArguments & args) {
				//hover mouse = change background
				if (this->isMouseOver() && this->getMouseState() == LocalMouseState::Waiting) {
					ofPushStyle();
					{
						ofSetColor(100);
						ofRect(args.localBounds);
					}
					ofPopStyle();
				}

				//line to indicate connection status
				ofPushStyle();
				{
					ofSetLineWidth(0.0f);
					ofFill();
					if (this->isConnected()) {
						ofSetColor(100, 200, 100);
					}

					ofPushMatrix();
					{
						ofTranslate(this->getPinHeadPosition());
						ofDrawRectangle(0, -3.0f, 10.0f, 6.0f);
					}
					ofPopMatrix();
				}
				ofPopStyle();
			};

			this->onMouse += [this](ofxCvGui::MouseArguments & args) {
				if (args.takeMousePress(this)) {
					if (args.button == 0) {
						ofEventArgs dummyArgs;
						this->onBeginMakeConnection(dummyArgs);
						this->globalElementPosition = args.global - args.local;
					}
					else if (args.button == 2) {
						this->resetConnection();
					}
				}
				if (args.action == ofxCvGui::MouseArguments::Action::Released && args.getOwner() == this) {
					//mouse drag is released, we took the mouse, and it could have been released outside of this element
					this->onReleaseMakeConnection(args);
				}
			};

			this->onBoundsChange += [this](ofxCvGui::BoundsChangeArguments & args) {
				auto ourBounds = this->getLocalBounds();
				this->pinHeadPosition = ourBounds.getTopLeft() + ofVec2f(0.0f, ourBounds.getHeight() / 2.0f);
				this->pinView->setBounds(ofRectangle(this->getPinHeadPosition() + ofVec2f(32, -16), 32, 32));
			};

			this->setBounds(ofRectangle(0, 0, 100, 20));

			this->pinView->addListenersToParent(this);
		}
Exemplo n.º 8
0
void Tab::draw () const {
    int mirror(locales::getCurrentLocale().LTR_ ? 1 : -1);

    Vector2f origin = getTopLeft() + topLeft_*mirror-Vector2f(0.f, 10.f);


    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    if (!focusedWidget_ && parent_->isFocused() && isTopMost() && active_) {
        glBegin(GL_QUADS);
            glColor4f(1,0.5,0.8,0.7);
            glVertex2f(origin.x_+width(),origin.y_);
            glVertex2f(origin.x_,origin.y_);
            glColor4f(0.5,0.25,0.4,0.0);
            glVertex2f(origin.x_,origin.y_+height_);
            glVertex2f(origin.x_+width(),origin.y_+height_);
        glEnd();
    }

    if (active_) {
        if (isTopMost()) {
            glBegin(GL_QUADS);
                glColor4f(1,0.5,0.8,0.7);
                glVertex2f(origin.x_+width(),origin.y_);
                glVertex2f(origin.x_,origin.y_);
                glColor4f(0.5,0.25,0.4,0.0);
                glVertex2f(origin.x_,origin.y_+height_*0.5);
                glVertex2f(origin.x_+width(),origin.y_+height_*0.5);
            glEnd();
        }

        glLineWidth(2.f);
        glBegin(GL_LINE_STRIP);
            if (isTopMost())  glColor4f(1.f, 0.5f, 0.8f, 1.0f);
            else              glColor4f(0.4f, 0.4f, 0.4f, 1.0f);
            glVertex2f(origin.x_,origin.y_+height_);
            glVertex2f(origin.x_,origin.y_);
            glVertex2f(origin.x_+width(),origin.y_);
            glVertex2f(origin.x_+width(),origin.y_+height_);
        glEnd();
    }
    else {
        glLineWidth(2.f);
        glBegin(GL_LINES);
            if (isTopMost())  glColor4f(1.f, 0.5f, 0.8f, 1.0f);
            else              glColor4f(0.4f, 0.4f, 0.4f, 1.0f);
            glVertex2f(origin.x_,origin.y_+height_);
            glVertex2f(origin.x_+width(),origin.y_+height_);
        glEnd();

    }

    // draw Label
    label_->draw();

    if (active_)
        for (std::vector<UiElement*>::const_iterator i=widgets_.begin(); i != widgets_.end(); ++i)
            (*i)->draw();
}
Exemplo n.º 9
0
void VerticalSlider::mouseMoved(Vector2f const& position) {
    UiElement::mouseMoved(position);

    if (pressed_ && focused_) {
        *value_ = (position.y_+(0.5f*(height_ - 10))/(maxValue_ - minValue_)-getTopLeft().y_-5)*(maxValue_ - minValue_)/(height_ - 10) + minValue_;
        if (*value_ < minValue_) *value_ = minValue_;
        if (*value_ > maxValue_) *value_ = maxValue_;
    }
}
Exemplo n.º 10
0
SceneLoader::SceneLoader(Ogre::SceneManager* sceneMgr, Ogre::SceneNode *baseSceneNode)
{
	mSceneMgr = sceneMgr;
	mSceneRootNode = baseSceneNode->createChildSceneNode("SceneRootNode");
	mSceneRootNode->setPosition(0,0,0);
	mSceneRootNode->setDirection(0,0,-1);

	mForceHide = false;

	mWallCount = 0;
	mWallCubeScale = 15;

	mMatrixSize.x = 9;
	mMatrixSize.y= 7;

 	short tmpMatrix[9][7] = {	1, 1, 1, 1, 1, 1, 1,
 								1, 0, 0, 0, 1, 1, 1,
 								1, 0, 1, 0, 0, 0, 0,
 								1, 0, 1, 1, 1, 1, 1,
 								1, 0, 0, 0, 0, 0, 1,
 								1, 1, 1, 1, 1, 0, 1,
 								0, 0, 1, 0, 0, 0, 1,
 								1, 0, 0, 0, 1, 1, 1,
 								1, 1, 1, 1, 1, 1, 1};
 								
	//short tmpMatrix[9][7] = {	1, 1, 1, 1, 1, 1, 1,
	//							1, 0, 0, 0, 0, 0, 1,
	//							1, 0, 1, 1, 1, 0, 1,
	//							1, 0, 1, 0, 1, 0, 1,
	//							1, 0, 1, 0, 1, 0, 1,
	//							1, 0, 0, 0, 1, 0, 1,
	//							1, 1, 1, 1, 1, 0, 1,
	//							0, 0, 0, 0, 0, 0, 1,
	//							1, 1, 1, 1, 1, 1, 1};

	mStartPos.x = 6; mStartPos.y = 0;

	for(int i = 0; i < mMatrixSize.x; i++)
	{
		for (int j = 0; j < mMatrixSize.y; j++)
		{
			mSceneMatrix[i][j] = tmpMatrix[i][j];
		}
	}

	mTopLeft = getTopLeft();

// 	for(int i = 0; i < mMatrixSize.x; i++)
// 	{
// 		for (int j = 0; j < mMatrixSize.y; j++)
// 		{
// 			std::cout << mSceneMatrix[i][j] << ", ";
// 		}
// 		std::cout << std::endl;
// 	}
}
Exemplo n.º 11
0
bool Field::canBeatTL(const Cell *arg)
{
    Cell* temp = getTopLeft(arg);
    Cell* tempTR = getTopLeft(temp);

    if( tempTR != NULL && !arg->isEmpty() )    // getTopRight checks arg for NULL value
    {
        if( !temp->isEmpty() )
        {
            if( arg->getFigure().getColor() == temp->getFigure().getColor() )
            {
                return false;
            }
            if( tempTR->isEmpty() )
            {
                tempTR->setCanMove(true);
            }
         }
    }
    return false;
}
Exemplo n.º 12
0
	//----------
	void Controller::filesDragged(ofDragInfo & args) {
		if (!initialised)
			return;
		auto rootBounds = this->rootGroup->getBounds();
		auto panel = this->findPanelUnderCursor(rootBounds);
		if (panel != PanelPtr()) {
			auto panelBounds = panel->getBounds();
			ofVec2f panelTopLeft = panelBounds.getTopLeft();
			auto newArgs = FilesDraggedArguments((ofVec2f) args.position - panelTopLeft, (ofVec2f) args.position, args.files);
			panel->onFilesDragged(newArgs);
		}
	}
Exemplo n.º 13
0
// ok, laeuft perfekt.
std::list<Rect> Rect::withoutRect(const Rect& rect) const
{

	// Schnittmenge:
	std::list<Rect> rects;
	if(rect == *this) {
		return rects;
	}

	Rect cut = commonRect(rect);

	// Schnitt ist gleich dem Rechteck
	if(cut == *this) {
		return rects;
	} else if(cut.getWidth() == 0 || cut.getHeight() == 0) {
		rects.push_back(*this);
		return rects;
	} else
	{
		// Sonst: bis zu 4 rectangles:
		// Rechteck mit vollstaendiger Breite, wenn cut im unteren Teil stattgefunden hat
		if(cut.getTop() > getTop()) {
			Rect r(getTopLeft(), Point(getRight(), cut.getTop()));
			if(r.getWidth() > 0 && r.getHeight() > 0) {
				rects.push_back(r);
			}
		}
		// links
		if(cut.getLeft() > getLeft()) {
			Rect r(Point(getLeft(), cut.getTop()), cut.getBottomLeft());
			if(r.getWidth() > 0 && r.getHeight() > 0) {
				rects.push_back(r);
			}
		}
		// rechts
		if(cut.getRight() < getRight()) {
			Rect r(cut.getTopRight(), Point(getRight(), cut.getBottom()));
			if(r.getWidth() > 0 && r.getHeight() > 0) {
				rects.push_back(r);
			}
		}
		// unten
		// Rechteck mit vollstaendiger Breite, wenn unter dem cut Recht noch Platz ist
		if(cut.getBottom() < getBottom()) {
			Rect r(Point(getLeft(), cut.getBottom()), getBottomRight());
			if(r.getWidth() > 0 && r.getHeight() > 0) {
				rects.push_back(r);
			}
		}
	}
	return rects;
}
Exemplo n.º 14
0
void VerticalSlider::draw() const {
    UiElement::draw();

    Vector2f origin = getTopLeft();

    int mirror(locales::getCurrentLocale().LTR_ ? 1 : -1);

    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    // draw line
    // Hover effect
    Color3f((Color3f(1, 1, 1)*(1-hoveredFadeTime_) + hoveredFadeTime_*Color3f(1.f, 0.8f, 0.9f))*(0.7f+focusedFadeTime_*0.3f)).gl4f(0.7f);

    glLineWidth(2);
    glBegin(GL_LINES);
        glVertex2f(10*mirror + origin.x_, origin.y_);
        glVertex2f(10*mirror + origin.x_, height_ + origin.y_);
    glEnd();

    // Hover effect
    Vector2f sliderPosition(10*mirror + origin.x_, (height_-10)*(*value_- minValue_)/(maxValue_ - minValue_) + origin.y_+5);

    glEnable(GL_TEXTURE_2D);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    glBindTexture(GL_TEXTURE_2D, texture::getTexture(texture::Widgets));

    int x(0), y(0);

    if (hovered_ && pressed_) {
        x = 3;
        y = 2;
    }
    else if (hovered_){
        x = 3;
        y = 1;
    }
    else {
        x = 3;
        y = 0;
    }

    glColor3f(1.f, 1.f, 1.f);
    glBegin(GL_QUADS);
        glTexCoord2f(x*0.25f, y*0.25f+0.25f);       glVertex2f(sliderPosition.x_-8.f,  sliderPosition.y_-8.f);
        glTexCoord2f(x*0.25f+0.25f, y*0.25f+0.25f); glVertex2f(sliderPosition.x_-8.f,  sliderPosition.y_+8.f);
        glTexCoord2f(x*0.25f+0.25f, y*0.25f);       glVertex2f(sliderPosition.x_+8.f,  sliderPosition.y_+8.f);
        glTexCoord2f(x*0.25f, y*0.25f);             glVertex2f(sliderPosition.x_+8.f,  sliderPosition.y_-8.f);
    glEnd();

    glDisable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, 0);
}
Exemplo n.º 15
0
bool OccArea::isFreeBuilding() const
{
  if ( m_occupant || !hasFreeFloor() )
  {
    return false;
  }
  for (int a = getTopLeft().x - 1; a < getBottomRight().x + 1; a++)
  {
    if (!equiv(Field::current()->getItem(Coord(a, getTopLeft().y - 1)), WALL))
      return false;
    if (!equiv(Field::current()->getItem(Coord(a, getBottomRight().y)), WALL))
      return false;
  }
  for (int b = getTopLeft().y;b < getBottomRight().y; b++)
  {
    if (!equiv(Field::current()->getItem(Coord(getTopLeft().x - 1, b)), WALL))
      return false;
    if (!equiv(Field::current()->getItem(Coord(getBottomRight().x, b)), WALL))
      return false;
  }
  return true;
}
Exemplo n.º 16
0
void ConvolutionMatrixComponent::resized() {
    auto matrix_height = optimum_routing_size * model.get_num_inputs();
    auto matrix_width = optimum_routing_size * model.get_num_outputs();

    auto input_width = getWidth() - matrix_width;

    auto bounds = getLocalBounds();
    auto left = bounds.removeFromLeft(input_width);
    auto input_area = left.removeFromTop(matrix_height);

    hrtf_component.setBounds(left.reduced(4, 4));

    auto matrix_area = bounds.removeFromTop(matrix_height);
    auto output_area = bounds;

    for (auto i = 0u; i != routings.size(); ++i) {
        auto y = i * optimum_routing_size;
        for (auto j = 0u; j != routings[i].size(); ++j) {
            auto x = j * optimum_routing_size;
            routings[i][j]->setSize(optimum_routing_size, optimum_routing_size);
            routings[i][j]->setTopLeftPosition(matrix_area.getTopLeft() +
                                               juce::Point<int>(x, y));
        }
    }

    for (auto i = 0u; i != inputs.size(); ++i) {
        inputs[i]->setSize(input_area.getWidth(), optimum_routing_size);
        inputs[i]->setTopLeftPosition(
                input_area.getTopLeft() +
                juce::Point<int>(0, i * optimum_routing_size));
    }

    for (auto i = 0u; i != outputs.size(); ++i) {
        outputs[i]->setSize(optimum_routing_size, output_area.getHeight());
        outputs[i]->setTopLeftPosition(
                output_area.getTopLeft() +
                juce::Point<int>(i * optimum_routing_size, 0));
    }
}
Exemplo n.º 17
0
// Schnitt
const Rect Rect::commonRect(const Rect& rect) const
{
	if(!this->isTouched(rect)) {
		return Rect();
	}

	eTouchType k = getTouchType(rect);
	switch(k)
	{
	case TOUCHES_NO_TOUCH:
		{
			if(rect.getTouchType(*this) == TOUCHES_IS_COMPLETELY_INSIDE)
				return *this;
			else return Rect();
		}break;				
	case TOUCHES_IS_COMPLETELY_INSIDE:return rect;break;
	case TOUCHES_CROSSES_RIGHT_BORDER:return Rect(rect.getTopLeft(), Point(getRight(), rect.getBottom()));break;
	case TOUCHES_CROSSES_LOWER_BORDER:return Rect(rect.getTopLeft(), Point(rect.getRight(), getBottom()));break;
	case TOUCHES_CROSSES_LEFT_BORDER:return Rect(Point(getLeft(), rect.getTop()), rect.getBottomRight());break;
	case TOUCHES_CROSSES_UPPER_BORDER:return Rect(Point(rect.getLeft(), getTop()), rect.getBottomRight());break;
	case TOUCHES_CROSSES_BOTTOM_RIGHT_CORNER:return Rect(rect.getTopLeft(), getBottomRight());break;
	case TOUCHES_CROSSES_BOTTOM_LEFT_CORNER:return Rect(Point(getLeft(), rect.getTop()), Point(rect.getRight(), getBottom()));break;
	case TOUCHES_CROSSES_TOP_LEFT_CORNER:return Rect(getTopLeft(), rect.getBottomRight());break;
	case TOUCHES_CROSSES_TOP_RIGHT_CORNER:return Rect(Point(rect.getLeft(), getTop()), Point(getRight(), rect.getBottom()));break;
	case TOUCHES_CROSSES_LEFT_AND_RIGHT_BORDER:return Rect(Point(getLeft(), rect.getTop()), Point(getRight(), rect.getBottom()));break;
	case TOUCHES_CROSSES_TOP_AND_BOTTOM_BORDER:return Rect(Point(rect.getLeft(), getTop()), Point(rect.getRight(), getBottom()));break;

	case TOUCHES_CROSSES_UPPER_AREA:return Rect(getTopLeft(), Point(getRight(), rect.getBottom()));break;
	case TOUCHES_CROSSES_RIGHT_AREA:return Rect(Point(rect.getLeft(), getTop()), getBottomRight());break;
	case TOUCHES_CROSSES_LOWER_AREA:return Rect(Point(getLeft(), rect.getTop()), getBottomRight());break;
	case TOUCHES_CROSSES_LEFT_AREA:return Rect(getTopLeft(), Point(rect.getRight(), getBottom()));break;
	case TOUCHES_UPPER_BORDER:
	case TOUCHES_LEFT_BORDER:
	case TOUCHES_LOWER_BORDER:
	case TOUCHES_RIGHT_BORDER:
	default:return Rect();break;
	}
}
Exemplo n.º 18
0
//----------------------------------------------------------
bool glmRectangle::intersects(const glm::vec3& p0, const glm::vec3& p1) const {
    // check for a line intersection
    glm::vec3 p;
    
    glm::vec3 topLeft     = getTopLeft();
    glm::vec3 topRight    = getTopRight();
    glm::vec3 bottomRight = getBottomRight();
    glm::vec3 bottomLeft  = getBottomLeft();
    
    return inside(p0) || // check end inside
    inside(p1) || // check end inside
    LineSegmentIntersection(p0, p1, topLeft,     topRight,    p) || // cross top
    LineSegmentIntersection(p0, p1, topRight,    bottomRight, p) || // cross right
    LineSegmentIntersection(p0, p1, bottomRight, bottomLeft,  p) || // cross bottom
    LineSegmentIntersection(p0, p1, bottomLeft,  topLeft,     p);   // cross left
}
Exemplo n.º 19
0
//----------------------------------------------------------
bool ofRectangle::intersects(const ofPoint& p0, const ofPoint& p1) const {
    // check for a line intersection
    ofPoint p;

    ofPoint topLeft     = getTopLeft();
    ofPoint topRight    = getTopRight();
    ofPoint bottomRight = getBottomRight();
    ofPoint bottomLeft  = getBottomLeft();

    return inside(p0) || // check end inside
           inside(p1) || // check end inside
           ofLineSegmentIntersection(p0, p1, topLeft,     topRight,    p) || // cross top
           ofLineSegmentIntersection(p0, p1, topRight,    bottomRight, p) || // cross right
           ofLineSegmentIntersection(p0, p1, bottomRight, bottomLeft,  p) || // cross bottom
           ofLineSegmentIntersection(p0, p1, bottomLeft,  topLeft,     p);   // cross left
}
Exemplo n.º 20
0
//------------------------------------------------------------------------
Point& Rect::toPoint (Direction dir, Point& p) const
{
	switch (dir) {
	case kSouthWest:		return p = getBottomLeft ();
	case kWest:				return p = getLeftCenter ();
	case kNorthWest:		return p = getTopLeft ();
	case kNorth:			return p = getTopCenter ();
	case kNorthEast:		return p = getTopRight ();
	case kEast:				return p = getRightCenter ();
	case kSouthEast:		return p = getBottomRight ();
	case kSouth:			return p = getBottomCenter ();
	case kNoDirection:		return p = getCenter ();
	}

	return p;
}
Exemplo n.º 21
0
void Rect::unionRect(const Rect &rect)
{
    const Vector2 topLeft = getTopLeft(),
	          bottomRight = getBottomRight(),
	          unionTopLeft = rect.getTopLeft(),
	          unionBottomRight = rect.getBottomRight();
	
    const Vector2 newTopLeft = Vector2(
	std::min(topLeft.x, unionTopLeft.x),
	std::min(topLeft.y, unionTopLeft.y));
    const Vector2 newBottomRight = Vector2(
	std::max(bottomRight.x, unionBottomRight.x),
	std::max(bottomRight.y, unionBottomRight.y));

    pos = newTopLeft;
    diagonal = newBottomRight - newTopLeft;
}
Exemplo n.º 22
0
void Rect::clipRect(const Rect &rect)
{
    const Vector2 topLeft = getTopLeft(),
	          bottomRight = getBottomRight(),
	          clipTopLeft = rect.getTopLeft(),
	          clipBottomRight = rect.getBottomRight();
	
    const Vector2 newTopLeft = Vector2(
	std::max(topLeft.x, clipTopLeft.x),
	std::max(topLeft.y, clipTopLeft.y));
    const Vector2 newBottomRight = Vector2(
	std::min(bottomRight.x, clipBottomRight.x),
	std::min(bottomRight.y, clipBottomRight.y));

    pos = newTopLeft;
    diagonal = newBottomRight - newTopLeft;
    if (!isNormal())
	pos = diagonal = Vector2();
}
Exemplo n.º 23
0
void Tab::mouseMoved(Vector2f const& position) {
    int mirror(locales::getCurrentLocale().LTR_ ? 1 : -1);
    Vector2f topLeftAbs(getTopLeft() + topLeft_*mirror-Vector2f(0.f, 10.f));
    if (locales::getCurrentLocale().LTR_) {
        if ((!sf::Mouse::isButtonPressed(sf::Mouse::Left) || pressed_) && topLeftAbs.x_+width_ > position.x_ && topLeftAbs.y_+height_ > position.y_ && topLeftAbs.x_ < position.x_ && topLeftAbs.y_ < position.y_)
            hovered_ = true;
        else
            hovered_ = false;
    }
    else {
        if ((!sf::Mouse::isButtonPressed(sf::Mouse::Left) || pressed_) && topLeftAbs.x_-width_ < position.x_ && topLeftAbs.y_+height_ > position.y_ && topLeftAbs.x_ > position.x_ && topLeftAbs.y_ < position.y_)
            hovered_ = true;
        else
            hovered_ = false;
    }

    if (active_)
        for (std::vector<UiElement*>::iterator i=widgets_.begin(); i != widgets_.end(); ++i)
            (*i)->mouseMoved(position);
}
Exemplo n.º 24
0
Rectangle Rectangle::translate(Vec2 v) const {
  return Rectangle(getTopLeft() + v, getBottomRight() + v);
}
Exemplo n.º 25
0
ErrVal
PictureParameterSet::write( HeaderSymbolWriteIf* pcWriteIf ) const
{
  //===== NAL unit header =====
  ETRACE_DECLARE( Bool m_bTraceEnable = true );
  ETRACE_LAYER  ( 0 );
  ETRACE_HEADER ( "PICTURE PARAMETER SET" );
  RNOK  ( pcWriteIf->writeFlag( 0,                                        "NAL unit header: forbidden_zero_bit" ) );
  RNOK  ( pcWriteIf->writeCode( 3, 2,                                     "NAL unit header: nal_ref_idc" ) );
  RNOK  ( pcWriteIf->writeCode( m_eNalUnitType, 5,                        "NAL unit header: nal_unit_type" ) );

  //===== NAL unit payload =====
  RNOK( pcWriteIf->writeUvlc( getPicParameterSetId(),                     "PPS: pic_parameter_set_id" ) );
  RNOK( pcWriteIf->writeUvlc( getSeqParameterSetId(),                     "PPS: seq_parameter_set_id" ) );
  RNOK( pcWriteIf->writeFlag( getEntropyCodingModeFlag(),                 "PPS: entropy_coding_mode_flag" ) );
  RNOK( pcWriteIf->writeFlag( getPicOrderPresentFlag(),                   "PPS: pic_order_present_flag" ) );

  //--ICU/ETRI FMO Implementation : FMO stuff start
  Int iNumberBitsPerSliceGroupId;
  RNOK( pcWriteIf->writeUvlc( getNumSliceGroupsMinus1(),                         "PPS: num_slice_groups_minus1" ) );

  if(getNumSliceGroupsMinus1() > 0)
  {
    RNOK( pcWriteIf->writeUvlc( getSliceGroupMapType(),                             "PPS: slice_group_map_type" ) );
    if(getSliceGroupMapType() ==0)
    {
      for(UInt iSliceGroup=0;iSliceGroup<=getNumSliceGroupsMinus1();iSliceGroup++)
      {
        RNOK( pcWriteIf->writeUvlc( getRunLengthMinus1(iSliceGroup),                             "PPS: run_length_minus1 [iSliceGroup]" ) );
      }
    }
    else if (getSliceGroupMapType() ==2)
    {
      for(UInt iSliceGroup=0;iSliceGroup<getNumSliceGroupsMinus1();iSliceGroup++)
      {
        RNOK( pcWriteIf->writeUvlc( getTopLeft(iSliceGroup),                             "PPS: top_left [iSliceGroup]" ) );
        RNOK( pcWriteIf->writeUvlc( getBottomRight(iSliceGroup),                             "PPS: bottom_right [iSliceGroup]" ) );
      }
    }
    else if(getSliceGroupMapType() ==3 ||
      getSliceGroupMapType() ==4 ||
      getSliceGroupMapType() ==5)
    {
      RNOK( pcWriteIf->writeFlag( getSliceGroupChangeDirection_flag(),                      "PPS: slice_group_change_direction_flag" ) );
      RNOK( pcWriteIf->writeUvlc( getSliceGroupChangeRateMinus1(),                             "PPS: slice_group_change_rate_minus1" ) );
    }
    else if (getSliceGroupMapType() ==6)
    {
      if (getNumSliceGroupsMinus1()+1 >4)
        iNumberBitsPerSliceGroupId = 3;
      else if (getNumSliceGroupsMinus1()+1 > 2)
        iNumberBitsPerSliceGroupId = 2;
      else
        iNumberBitsPerSliceGroupId = 1;
      //! JVT-F078, exlicitly signal number of MBs in the map
      RNOK( pcWriteIf->writeUvlc( getNumSliceGroupMapUnitsMinus1(),                             "PPS: num_slice_group_map_units_minus1" ) );
      ROF ( getNumSliceGroupMapUnitsMinus1() < m_uiSliceGroupIdArraySize );
      for (UInt iSliceGroup=0; iSliceGroup<=getNumSliceGroupMapUnitsMinus1(); iSliceGroup++)
        RNOK( pcWriteIf->writeCode( getSliceGroupId(iSliceGroup), iNumberBitsPerSliceGroupId ,                                    "PPS: slice_group_id[iSliceGroup]" ) );
    }

  }
  //--ICU/ETRI FMO Implementation : FMO stuff end

  RNOK( pcWriteIf->writeUvlc( getNumRefIdxActive(LIST_0)-1,               "PPS: num_ref_idx_l0_active_minus1" ) );
  RNOK( pcWriteIf->writeUvlc( getNumRefIdxActive(LIST_1)-1,               "PPS: num_ref_idx_l1_active_minus1" ) );
  RNOK( pcWriteIf->writeFlag( m_bWeightedPredFlag,                        "PPS: weighted_pred_flag" ) );
  RNOK( pcWriteIf->writeCode( m_uiWeightedBiPredIdc, 2,                   "PPS: weighted_bipred_idc" ) );
  RNOK( pcWriteIf->writeSvlc( (Int)getPicInitQp() - 26,                   "PPS: pic_init_qp_minus26" ) );
  RNOK( pcWriteIf->writeSvlc( 0,                                          "PPS: pic_init_qs_minus26" ) );
  RNOK( pcWriteIf->writeSvlc( getChromaQpIndexOffset(),                   "PPS: chroma_qp_index_offset" ) );
  RNOK( pcWriteIf->writeFlag( getDeblockingFilterParametersPresentFlag(), "PPS: deblocking_filter_control_present_flag" ) ); //VB-JV 04/08
  RNOK( pcWriteIf->writeFlag( getConstrainedIntraPredFlag(),              "PPS: constrained_intra_pred_flag" ) );
  RNOK( pcWriteIf->writeFlag( getRedundantPicCntPresentFlag(),            "PPS: redundant_pic_cnt_present_flag" ) );  // JVT-Q054 Red. Picture

  if( getTransform8x8ModeFlag() || m_bPicScalingMatrixPresentFlag || m_iSecondChromaQpIndexOffset != m_iChromaQpIndexOffset )
  {
    RNOK( xWriteFrext( pcWriteIf ) );
  }

  return Err::m_nOK;
}
Exemplo n.º 26
0
void LineUIDrawObject::draw(const GraphicsWeakPtr Graphics, Real32 Opacity) const
{
	Graphics->drawLine(getTopLeft(), getBottomRight(), getWidth(), getColor(), getOpacity()*Opacity);
}
Exemplo n.º 27
0
void LineUIDrawObject::getBounds(Pnt2f& TopLeft, Pnt2f& BottomRight) const
{
	TopLeft = getTopLeft();
	BottomRight = getBottomRight();
}
Exemplo n.º 28
0
void Button::draw () const {
    UiElement::draw();

    Vector2f origin = getTopLeft();

    // draw Button
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    glBegin(GL_QUADS);
        // dark background
        if (isTopMost())   glColor4f(0.3*focusedFadeTime_,0.1*focusedFadeTime_,0.2*focusedFadeTime_,0.8);
        else               glColor4f(0.0,0.0,0.0,0.8);
        glVertex2f(origin.x_, origin.y_);
        glVertex2f(origin.x_, height_ + origin.y_);
        glColor4f(0.0,0.0,0.0,0.8);
        glVertex2f(width()*0.5f + origin.x_, height_ + origin.y_);
        glVertex2f(width()*0.5f + origin.x_, origin.y_);
        glVertex2f(width()*0.5f + origin.x_, height_ + origin.y_);
        glVertex2f(width()*0.5f + origin.x_, origin.y_);
        if (isTopMost())   glColor4f(0.3*focusedFadeTime_,0.1*focusedFadeTime_,0.2*focusedFadeTime_,0.8);
        else               glColor4f(0.0,0.0,0.0,0.8);
        glVertex2f(width() + origin.x_, origin.y_);
        glVertex2f(width() + origin.x_, height_ + origin.y_);

        // glossy bottom
        glColor4f(1.0,1.0,1.0,0.0);
        glVertex2f(origin.x_, height_*0.7f + origin.y_);
        glVertex2f(width() + origin.x_, height_*0.7f + origin.y_);
        glColor4f(1.0,1.0,1.0,0.06);
        glVertex2f(width() + origin.x_, height_ + origin.y_);
        glVertex2f(origin.x_, height_ + origin.y_);

    if (pressed_ && (hovered_ || focused_)) {
        // bottom glow
        glColor4f(0.5,0.25,0.4,0.0);
        glVertex2f(origin.x_,origin.y_);
        glVertex2f(origin.x_+width(),origin.y_);
        glColor4f(0.5,0.25,0.4,0.4);
        glVertex2f(origin.x_+width(),origin.y_+height_);
        glVertex2f(origin.x_,origin.y_+height_);
    }
    else if (hovered_) {
        glColor4f(0.5,0.25,0.4,0.0);
        glVertex2f(origin.x_,height_*0.5f + origin.y_);
        glVertex2f(origin.x_+width(),height_*0.5f + origin.y_);
        glColor4f(0.5,0.25,0.4,0.4);
        glVertex2f(origin.x_+width(),origin.y_+height_);
        glVertex2f(origin.x_,origin.y_+height_);

        // glossy top
        glColor4f(1.0,1.0,1.0,0.2);
        glVertex2f(origin.x_, origin.y_);
        glVertex2f(width() + origin.x_, origin.y_);
        glColor4f(1.0,1.0,1.0,0.05);
        glVertex2f(width() + origin.x_, height_*0.5f + origin.y_);
        glVertex2f(origin.x_, height_*0.5f + origin.y_);
    }
    else {
        // glossy top
        glColor4f(1.0,1.0,1.0,0.2);
        glVertex2f(origin.x_, origin.y_);
        glVertex2f(width() + origin.x_, origin.y_);
        glColor4f(1.0,1.0,1.0,0.05);
        glVertex2f(width() + origin.x_, height_*0.5f + origin.y_);
        glVertex2f(origin.x_, height_*0.5f + origin.y_);
    }
    glEnd();


    glBlendFunc(GL_SRC_ALPHA, GL_ONE);
    glLineWidth(1.f);

    glColor4f(1.0,0.4,0.8,0.3f+hoveredFadeTime_*0.7f);
    glBegin(GL_LINE_LOOP);
        glVertex2f(origin.x_,origin.y_+height_);
        glVertex2f(origin.x_,origin.y_);
        glVertex2f(origin.x_+width(),origin.y_);
        glVertex2f(origin.x_+width(),origin.y_+height_);
    glEnd();

    // draw Label
    label_->draw();
}
Exemplo n.º 29
0
	OrthogonalLine Rectangle::getTopLine() const
	{
		return OrthogonalLine(OrthogonalLine::X_AXIS, getTopLeft(), size.x);
	}
Exemplo n.º 30
0
void ShipPreview::draw() const {
    Vector2f origin = getTopLeft() + Vector2f(10.f, 10.f);

    glPushAttrib(GL_ALL_ATTRIB_BITS);
    glPushMatrix();
    glLoadIdentity();
    glTranslatef(origin.x_, origin.y_, 0.f);

    glEnable(GL_TEXTURE_2D);

    glBlendFunc(GL_SRC_ALPHA, GL_ONE);

    // draw glow
    glBindTexture(GL_TEXTURE_2D, texture::getTexture(texture::Weapons));
    teamColor_->brightened().gl4f(0.6f);
    glBegin(GL_QUADS);
        glTexCoord2f(0.75f, 0.75f); glVertex2f(-16.f*3.2f,-16.f*3.2f);
        glTexCoord2f(0.75f, 1.f); glVertex2f(-16.f*3.2f, 16.f*3.2f);
        glTexCoord2f(1.f, 1.f); glVertex2f( 16.f*3.2f, 16.f*3.2f);
        glTexCoord2f(1.f, 0.75f); glVertex2f( 16.f*3.2f,-16.f*3.2f);
    glEnd();

    // draw ship
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glRotatef(timer::totalTime()*100, 0.f, 0.f, 1.f);
    glBindTexture(GL_TEXTURE_2D, texture::getTexture(texture::Ships));

    float x, y;

    x = static_cast<float>(*graphic_%8)*0.125f;
    y = static_cast<float>(std::floor(*graphic_*0.125f))*0.375f;

    glColor3f(1.f, 1.f, 1.f);
    glBegin(GL_QUADS);
        glTexCoord2f(x, y+0.125f);          glVertex2f(-32.f, -32.f);
        glTexCoord2f(x+0.125f, y+0.125f);   glVertex2f(-32.f,  32.f);
        glTexCoord2f(x+0.125f, y);          glVertex2f( 32.f,  32.f);
        glTexCoord2f(x, y);                 glVertex2f( 32.f, -32.f);
    glEnd();

    y += 0.125f;

    teamColor_->gl3f();
    glBegin(GL_QUADS);
        glTexCoord2f(x, y+0.125f);          glVertex2f(-32.f, -32.f);
        glTexCoord2f(x+0.125f, y+0.125f);   glVertex2f(-32.f,  32.f);
        glTexCoord2f(x+0.125f, y);          glVertex2f( 32.f,  32.f);
        glTexCoord2f(x, y);                 glVertex2f( 32.f, -32.f);
    glEnd();

    y += 0.125f;

    color_->gl3f();
    glBegin(GL_QUADS);
        glTexCoord2f(x, y+0.125f);          glVertex2f(-32.f, -32.f);
        glTexCoord2f(x+0.125f, y+0.125f);   glVertex2f(-32.f,  32.f);
        glTexCoord2f(x+0.125f, y);          glVertex2f( 32.f,  32.f);
        glTexCoord2f(x, y);                 glVertex2f( 32.f, -32.f);
    glEnd();

    glDisable(GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, 0);

    glPopMatrix();
    glPopAttrib();
}