Example #1
0
	bool Rectangle::overlapping(const Rectangle &rectangle)
	{
		return (rectangle.getLeft() < getRight()) &&
				(rectangle.getRight() > getLeft()) &&
				(rectangle.getTop() > getBottom()) &&
				(rectangle.getBottom() < getTop());
	}
Example #2
0
		//----------
		Title::Title(string caption, Level level) :
		level(level) {
			this->setCaption(caption);
			this->setBounds(ofRectangle(0, 0, 100, 30));
			
			//fix font size
			int fontSize = 14;
			switch (this->level) {
			case H1:
				fontSize = 24;
				break;
			case H2:
				fontSize = 18;
				break;
			case H3:
				fontSize = 14;
				break;
			}

			//check if we need to increase height
			auto & font = ofxAssets::font(ofxCvGui::getDefaultTypeface(), fontSize);
			if (!font.isLoaded()) {
				ofLogError("ofxCvGui") << "Check ofxCvGui is initialised";
				return;
			}
			auto textBounds = font.getStringBoundingBox(this->caption, 0, 30);
			const auto textBottom = textBounds.getBottom();
			if (textBottom + 10 > this->getHeight()) {
				this->setHeight(textBottom + 10);
			}
			this->onDraw += [this, fontSize] (ofxCvGui::DrawArguments & args) {
				auto & font = ofxAssets::font(ofxCvGui::getDefaultTypeface(), fontSize);
				font.drawString(this->caption, 0, 30);
			};
		}
Example #3
0
// Technically, this is incorrect. This is a intersect
bool Rect::contains(const Rect &rect) const
{
	return getLeft() < rect.getRight() &&
		getRight() > rect.getLeft() &&
		getTop() < rect.getBottom() &&
		getBottom() > rect.getTop();
}
Example #4
0
inline Box<float>::operator Box<int>() const
{
	Box<int> box;
	box.setCoords(static_cast<int>(roundf(getLeft())), static_cast<int>(roundf(getTop())), 
			static_cast<int>(roundf(getRight())), static_cast<int>(roundf(getBottom())));
	return box;
}
Example #5
0
		//----------
		Title::Title(string caption, Level level) :
		level(level) {
			this->setCaption(caption);
			this->setBounds(ofRectangle(5, 0, 100, 40));
			
			//fix font size
			int fontSize = 14;
			switch (this->level) {
			case H1:
				fontSize = 24;
				break;
			case H2:
				fontSize = 18;
				break;
			case H3:
				fontSize = 14;
				break;
			}

			//check if we need to increase height
			auto & font = ofxAssets::font(ofxCvGui::defaultTypeface, fontSize);
			auto textBounds = font.getStringBoundingBox(this->caption, 0, 30);
			const auto textBottom = textBounds.getBottom();
			if (textBottom + 10 > this->getHeight()) {
				this->setHeight(textBottom + 10);
			}
			this->onDraw += [this, fontSize] (ofxCvGui::DrawArguments & args) {
				auto & font = ofxAssets::font(ofxCvGui::defaultTypeface, fontSize);
				font.drawString(this->caption, 0, 30);
			};
		}
Example #6
0
void CX3DCylinderNode::print(int indent)
{
	FILE *fp = CX3DParser::getDebugLogFp();

	char *nodeName = getNodeName();
	if (nodeName)
	{
		CX3DParser::printIndent(indent);
		fprintf(fp, "%s (%s)\n", nodeName, CX3DNode::getNodeTypeString(getNodeType()));

		CX3DParser::printIndent(indent+1);
		fprintf(fp, "solid : %s\n", getSolid()->getValue() ? "TRUE" : "FALSE");

		CX3DParser::printIndent(indent+1);
		fprintf(fp, "radius : (%f)\n", getRadius()->getValue());

		CX3DParser::printIndent(indent+1);
		fprintf(fp, "height : (%f)\n", getHeight()->getValue());

		CX3DParser::printIndent(indent+1);
		fprintf(fp, "bottom : %s\n", getBottom()->getValue() ? "TRUE" : "FALSE");

		CX3DParser::printIndent(indent+1);
		fprintf(fp, "side : %s\n", getSide()->getValue() ? "TRUE" : "FALSE");

		CX3DParser::printIndent(indent+1);
		fprintf(fp, "top : %s\n", getTop()->getValue() ? "TRUE" : "FALSE");
	}
}
Example #7
0
// returns false if the bitmap is empty or has wrong color space.
bool
BoundsCalculator::getValidRect(BBitmap *bitmap, RECT *rect)
{
	enum {
		kRectIsInvalid = false,
		kRectIsEmpty = false,
		kRectIsValid = true
	};
	
	switch (bitmap->ColorSpace()) {
		case B_RGB32:
		case B_RGB32_BIG:
			break;
		default:
			return kRectIsInvalid;
			break;
	};

	// initialize member variables
	fBits = (uchar*)bitmap->Bits();
	fBPR  = bitmap->BytesPerRow();
	
	fLeft   = rect->left;	
	fRight  = rect->right;
	fTop    = rect->top;
	fBottom = rect->bottom;
	
	fWidth = fRight - fLeft + 1;

	// get top bound
	fTop = getTop();
	if (fTop > fBottom) {
		return kRectIsEmpty;
	}
	
	// get bottom bound
	fBottom = getBottom();
	
	// calculate left and right bounds
	fLeftBound = fRight + 1;
	fRightBound = fLeft - 1;
	
	const uchar *row = getRow(fLeft, fTop);
	for (int y = fTop; y <= fBottom; y ++) {
		updateLeftBound((const rgb_color*)row);
		updateRightBound((const rgb_color*)row);
		if (fLeft == fLeftBound && fRight == fRightBound) {
			break;
		}
		row += fBPR;
	}
	
	// return bounds in rectangle
	rect->left = fLeftBound;
	rect->right = fRightBound; 
	rect->top = fTop;
	rect->bottom = fBottom;
		
	return kRectIsValid;
}
//Draws filter display path for Highpass response
void FilterResponseDisplay::drawHighpass()
{
    float freq = 0.0;
    float magnitudeDBValue = 0.0;
    
    //If HighPass start path on right hand side of component i.e at component width.
    magnitudeDBValue = filterToUse->getMagnitudeResponse(maxFrequency);
    magnitudeResponsePath.startNewSubPath(((float) getWidth() + (filterPathThickness/2)), (getBottom() - (filterPathThickness/2)));
    magnitudeResponsePath.lineTo(((float) getWidth() + (filterPathThickness/2)), dbToYAxis(magnitudeDBValue));
    
    for (float xPos = ((float) getWidth()); xPos > (filterPathThickness/2); xPos -= (filterPathThickness/2))
    {
        //Get the frequency value for the filter's magnitude response calculation
        freq = xAxisToFrequency(xPos);
        magnitudeDBValue = filterToUse->getMagnitudeResponse(freq);
        magnitudeResponsePath.lineTo(xPos, dbToYAxis(magnitudeDBValue));
    }
    
    magnitudeDBValue = filterToUse->getMagnitudeResponse(minFrequency);
    magnitudeResponsePath.lineTo ((0.0f - (filterPathThickness/2)), dbToYAxis(magnitudeDBValue));
    
    /* 
        Dirty trick again to close the path nicely when cutoff at min level for High Pass - try cmmenting this line out to se the visual
        effect on the reponse path closing without it
     */
    magnitudeResponsePath.lineTo ((0.0f - (filterPathThickness/2)), (getBottom() - (filterPathThickness/2)));
}
Example #9
0
bool Car::checkTrackCollision(std::list<TrackTile*> allTracks) {
  bool collided = false;
  int i = 0;

  std::list<TrackTile*>::const_iterator iterator;
  for (iterator = allTracks.begin(); iterator != allTracks.end(); ++iterator) {
    if ((*iterator)->getY() == (this->yPosition - yPosition)) {
      //cout << "Tile " << (*iterator)->getLeft() << " " << (*iterator)->getRight() << " " << (*iterator)->getBottom() << " " << (*iterator)->getFront() << "\n";
      //cout << "Car " << getLeft() << " " << getRight() << " " << getBottom() << " " << getFront() << "\n";
      if(getLeft() < (*iterator)->getRight()) {
        //cout << "1\n";
        if(getRight() > (*iterator)->getLeft()) {
          //cout << "2\n";
          if(getFront() > (*iterator)->getBottom()) {
            //cout << "3\n";
            if(getBottom() < (*iterator)->getFront()) {
              collided = true;
              lastTile = currentTile;
              currentTile = i;
              checkLap(*iterator, allTracks.size());
              //cout << "Atual " << currentTile << "\n";
            }
          }
        }
      }
    }
    i++;
  }
  return collided;
}
Example #10
0
bool Recti::contains(const Vector2i &pt) const
{
	return getLeft() < pt.x &&
		getTop() < pt.y &&
		getRight() > pt.x &&
		getBottom() > pt.y;
}
Example #11
0
inline void Box<T>::scale(T2 xScale, T2 yScale)
{
	T x = static_cast<T>(xScale * getLeft());
	T y = static_cast<T>(yScale * getTop());
	T x2 = static_cast<T>(xScale * getRight());
	T y2 = static_cast<T>(yScale * getBottom());
	setCoords(x, y, x2, y2);
}
Example #12
0
inline void Box<int>::scale(double xScale, double yScale)
{
	int x = static_cast<int>(round(xScale * getLeft()));
	int y = static_cast<int>(round(yScale * getTop()));
	int x2 = static_cast<int>(round(xScale * getRight()));
	int y2 = static_cast<int>(round(yScale * getBottom()));
	setCoords(x, y, x2, y2);
}
Example #13
0
inline void Box<long>::scale(double xScale, double yScale)
{
	long x = static_cast<long>(round(xScale * getLeft()));
	long y = static_cast<long>(round(yScale * getTop()));
	long x2 = static_cast<long>(round(xScale * getRight()));
	long y2 = static_cast<long>(round(yScale * getBottom()));
	setCoords(x, y, x2, y2);
}
Example #14
0
inline void Box<int>::scale(float xScale, float yScale)
{
	int x = static_cast<int>(roundf(xScale * getLeft()));
	int y = static_cast<int>(roundf(yScale * getTop()));
	int x2 = static_cast<int>(roundf(xScale * getRight()));
	int y2 = static_cast<int>(roundf(yScale * getBottom()));
	setCoords(x, y, x2, y2);
}
Example #15
0
void Warship::shootBullet()
{
    for(int i=0;i<5;i++)
    {
        float angle = (160+i*10)/180.f*PI;
        Game::enemyBullet.push_back(bullet->clone()->setPosition(sf::Vector2f(getX(),getBottom()))->rotate(angle));
    }
}
Example #16
0
void HrtfBiAuralAudioProcessorEditor::resized()
{
	mainDisplay_->setBounds(20, 20, 260, 260);
	elevationSlider_.setBounds(280, 30, 50, 260);
	crossoverKnob_.setBounds(10, topSectionY_ + 15, 75, 75);
	wetKnob_.setBounds(90, topSectionY_ + 15, 75, 75);
	gainKnob_.setBounds(170, topSectionY_ + 15, 75, 75);
	bypassButton_.setBounds(getWidth() - 90, getBottom() - 40, 80, 30);
}
Example #17
0
//==============================================================================
void ResizableWindow::activeWindowStatusChanged()
{
    auto border = getContentComponentBorder();
    auto area = getLocalBounds();

    repaint (area.removeFromTop (border.getTop()));
    repaint (area.removeFromLeft (border.getLeft()));
    repaint (area.removeFromRight (border.getRight()));
    repaint (area.removeFromBottom (border.getBottom()));
}
Example #18
0
void CylinderNode::recomputeDisplayList() {
	unsigned int nCurrentDisplayList = getDisplayList();
	if (0 < nCurrentDisplayList)
		glDeleteLists(nCurrentDisplayList, 1);

	unsigned int nNewDisplayList = glGenLists(1);
	glNewList(nNewDisplayList, GL_COMPILE);
		GLUquadricObj *quadObj;

		glFrontFace(GL_CCW);

	    glPushMatrix ();

		glMatrixMode(GL_TEXTURE);
		glLoadIdentity();
	    glRotatef (180.0, 0.0, 1.0, 0.0);

		glMatrixMode(GL_MODELVIEW);

	    glRotatef (180.0, 0.0, 1.0, 0.0);
	    glRotatef (90.0, 1.0, 0.0, 0.0);
	    glTranslatef (0.0, 0.0, -getHeight()/2.0f);

		if (getSide()) {
		    quadObj = gluNewQuadric ();
		    gluQuadricDrawStyle(quadObj, GLU_FILL);
		    gluQuadricNormals(quadObj, GLU_SMOOTH);
		    gluQuadricTexture(quadObj, GL_TRUE);
		    gluCylinder(quadObj, getRadius(), getRadius(), getHeight(), 12, 2);
			gluDeleteQuadric(quadObj);
		}

		if (getTop()) {
		    glPushMatrix ();
		    glRotatef (180.0, 1.0, 0.0, 0.0);
		    quadObj = gluNewQuadric ();
		    gluQuadricTexture(quadObj, GL_TRUE);
			gluDisk(quadObj, 0.0, getRadius(), 12, 2);
			gluDeleteQuadric(quadObj);
		    glPopMatrix ();
		}

		if (getBottom()) {
		    glTranslatef (0.0, 0.0, getHeight());
		    quadObj = gluNewQuadric ();
		    gluQuadricTexture(quadObj, GL_TRUE);
			gluDisk(quadObj, 0.0, getRadius(), 12, 2);
			gluDeleteQuadric(quadObj);
		}

	    glPopMatrix ();
	glEndList();

	setDisplayList(nNewDisplayList);
};
void ofxGenericFrameView::refresh()
{
    if ( _thickness > 0 )
    {
        ofRectangle frame = getFrame();
        ofRectangle resize( 0, 0, _thickness, frame.height );
        
        ofPtr< ofxGenericView > view = getLeft();
        if ( view )
        {
            view->setFrame( resize );
        }
        resize.width = frame.width;
        resize.height = _thickness;
        
        view = getTop();
        if ( view )
        {
            view->setFrame( resize );
        }
        
        resize.y = frame.height - _thickness;
        view = getBottom();
        if ( view )
        {
            view->setFrame( resize );
        }
        resize.x = frame.width - _thickness;
        resize.y = 0;
        resize.width = _thickness;
        resize.height = frame.height;
        view = getRight();
        if ( view )
        {
            view ->setFrame( resize );
        }
        for( std::vector< ofPtr< ofxGenericView > >::iterator show = _frame.begin(); show != _frame.end(); show ++ )
        {
            if ( *show )
            {
                ( *show )->setVisible( true );
            }
        }

    } else
    {
        for( std::vector< ofPtr< ofxGenericView > >::iterator hide = _frame.begin(); hide != _frame.end(); hide ++ )
        {
            if ( *hide )
            {
                ( *hide )->setVisible( false );
            }
        }
    }
}
bool ActiveXControlComponent::createControl (const void* controlIID)
{
    deleteControl();

    if (auto* peer = getPeer())
    {
        auto controlBounds = peer->getAreaCoveredBy (*this);
        auto hwnd = (HWND) peer->getNativeHandle();

        std::unique_ptr<Pimpl> newControl (new Pimpl (hwnd, *this));

        HRESULT hr = OleCreate (*(const IID*) controlIID, __uuidof (IOleObject), 1 /*OLERENDER_DRAW*/, 0,
                                newControl->clientSite, newControl->storage,
                                (void**) &(newControl->control));

        if (hr == S_OK)
        {
            newControl->control->SetHostNames (L"JUCE", 0);

            if (OleSetContainedObject (newControl->control, TRUE) == S_OK)
            {
                RECT rect;
                rect.left   = controlBounds.getX();
                rect.top    = controlBounds.getY();
                rect.right  = controlBounds.getRight();
                rect.bottom = controlBounds.getBottom();

                if (newControl->control->DoVerb (OLEIVERB_SHOW, 0, newControl->clientSite, 0, hwnd, &rect) == S_OK)
                {
                    control.reset (newControl.release());
                    control->controlHWND = ActiveXHelpers::getHWND (this);

                    if (control->controlHWND != 0)
                    {
                        control->setControlBounds (controlBounds);

                        control->originalWndProc = (WNDPROC) GetWindowLongPtr ((HWND) control->controlHWND, GWLP_WNDPROC);
                        SetWindowLongPtr ((HWND) control->controlHWND, GWLP_WNDPROC, (LONG_PTR) Pimpl::activeXHookWndProc);
                    }

                    return true;
                }
            }
        }
    }
    else
    {
        // the component must have already been added to a real window when you call this!
        jassertfalse;
    }

    return false;
}
Example #21
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;
}
Example #22
0
//==============================================================================
void FftapeDelayAudioProcessorEditor::paint (Graphics& g)
{
    g.fillAll (Colours::darkgoldenrod);

    g.setColour (Colours::silver);
    g.setFont   (24.0f);
    Rectangle<int> box (getX(), getBottom() - 40, getWidth() / 3, 40);
    g.drawFittedText (TRANS ("Gain"), box, Justification::centred, 1);
    box.setX (box.getRight());
    g.drawFittedText (TRANS ("Time"), box, Justification::centred, 1);
    box.setX (box.getRight());
    g.drawFittedText (TRANS ("Feedback"), box, Justification::centred, 1);
}
Example #23
0
		void Rect::Union(const Point point)
		{
			if (point.X < X)
			{
				int difference = (X - point.X);
				X -= difference;
				Width += difference;
			}
			if (point.X > getRight())
			{
				Width += (point.X - getRight());
			}
			if (point.Y < Y)
			{
				int difference = (Y - point.Y);
				Y -= difference;
				Height += difference;
			}
			if (point.Y > getBottom())
			{
				Height += (point.Y - getBottom());
			}
		}
Example #24
0
  void onEntriesChange()
  {
    int left = getLeft();
    int top = getTop();

    m_rect = gfx::Rect(-left, -top,
                       m_editor->getSprite()->getWidth() + left + getRight(),
                       m_editor->getSprite()->getHeight() + top + getBottom());

    static_cast<SelectBoxState*>(m_selectBoxState.get())->setBoxBounds(m_rect);

    // Redraw new rulers position
    m_editor->invalidate();
  }
Example #25
0
void MainWindowList::avoidSuperimposedWindows (MainWindow* const mw)
{
    for (int i = windows.size(); --i >= 0;)
    {
        auto* other = windows.getUnchecked(i);

        auto b1 = mw->getBounds();
        auto b2 = other->getBounds();

        if (mw != other
             && std::abs (b1.getX() - b2.getX()) < 3
             && std::abs (b1.getY() - b2.getY()) < 3
             && std::abs (b1.getRight()  - b2.getRight()) < 3
             && std::abs (b1.getBottom() - b2.getBottom()) < 3)
        {
            int dx = 40, dy = 30;

            if (b1.getCentreX() >= mw->getScreenBounds().getCentreX())   dx = -dx;
            if (b1.getCentreY() >= mw->getScreenBounds().getCentreY())   dy = -dy;

            mw->setBounds (b1.translated (dx, dy));
        }
    }
}
//----------------------------------------------------------
float ofRectangle::getVertAnchor(ofAlignVert anchor) const {
    switch (anchor) {
    case OF_ALIGN_VERT_IGNORE:
        ofLogError("ofRectangle") << "getVertAnchor(): unable to get anchor for OF_ALIGN_VERT_IGNORE, returning 0.0";
        return 0.0f;
    case OF_ALIGN_VERT_TOP:
        return getTop();
    case OF_ALIGN_VERT_BOTTOM:
        return getBottom();
    case OF_ALIGN_VERT_CENTER:
        return getCenter().y;
    default:
        ofLogError("ofRectangle") << "getVertAnchor(): unknown ofAlignVert = " << anchor << ", returning 0.0";
        return 0.0f;
    }
}
void Graphics::fillCheckerBoard (Rectangle<float> area, float checkWidth, float checkHeight,
                                 Colour colour1, Colour colour2) const
{
    jassert (checkWidth > 0 && checkHeight > 0); // can't be zero or less!

    if (checkWidth > 0 && checkHeight > 0)
    {
        context.saveState();

        if (colour1 == colour2)
        {
            context.setFill (colour1);
            context.fillRect (area);
        }
        else
        {
            auto clipped = context.getClipBounds().getIntersection (area.getSmallestIntegerContainer());

            if (! clipped.isEmpty())
            {
                const int checkNumX = (int) ((clipped.getX() - area.getX()) / checkWidth);
                const int checkNumY = (int) ((clipped.getY() - area.getY()) / checkHeight);
                const float startX = area.getX() + checkNumX * checkWidth;
                const float startY = area.getY() + checkNumY * checkHeight;
                const float right  = (float) clipped.getRight();
                const float bottom = (float) clipped.getBottom();

                for (int i = 0; i < 2; ++i)
                {
                    int cy = i;
                    RectangleList<float> checks;

                    for (float y = startY; y < bottom; y += checkHeight)
                        for (float x = startX + (cy++ & 1) * checkWidth; x < right; x += checkWidth * 2.0f)
                            checks.addWithoutMerging ({ x, y, checkWidth, checkHeight });

                    checks.clipTo (area);
                    context.setFill (i == ((checkNumX ^ checkNumY) & 1) ? colour1 : colour2);
                    context.fillRectList (checks);
                }
            }
        }

        context.restoreState();
    }
}
Example #28
0
/*
*	Rotates the cube left by changing the sides, and rotating them as needed.
*/
void Cube::rotateLeft() {

	//invert y axis of the back
	getBack()->yAxisFlip();

	Map temp = sides[0];
	sides[0] = sides[3];
	sides[3] = sides[5];
	sides[5] = sides[2];
	sides[2] = temp;

	getTop()->rotateClockwise();
	getBottom()->rotateCounterClockwise();

	//invert y axis of the back
	getBack()->yAxisFlip();
}
Example #29
0
void MainComponent::resized()
{
    int rightMostWithoutConsole = jmax(pdEditor.getWidth(),(pulpConfigUI.isVisible()?pulpConfigUI.getWidth():0));
    int width = rightMostWithoutConsole + (pulpConsole.isVisible()?pulpConsole.getWidth():0);
    
    
    
    pdEditor.setTopLeftPosition(0,    pulpConfigUI.isVisible()?pulpConfigUI.getBottom() + 10:10);
    
    
    
    pulpConsole.setBounds(rightMostWithoutConsole, 10, pulpConsole.getWidth(), getBottom());
    
    setSize(width, pdEditor.getBottom());
    //                       editButton->getRight() + 10,300);
    
    
}
Example #30
0
bool Rect::intersects(const Rect& other, Rect& intersection) const
{
    float left = std::max(getLeft(), other.getLeft());
    float top = std::max(getTop(), other.getTop());
    float right = std::min(getRight(), other.getRight());
    float bottom = std::min(getBottom(), other.getBottom());

    if(left < right && top < bottom)
    {
        intersection.x = left;
        intersection.y = top;
        intersection.width = right - left;
        intersection.height = bottom - top;

        return true;
    }

    intersection = Rect();
    return false;
}