Exemplo n.º 1
0
void BlockBase::updateOpenClose(float dt) {
    float minLength = 1;
    if(mStatus == CLOSING) {
        if(mDownDirDoor) {
            float upperbound = mRestorePosition.y + mRestoreSize.height / 2;
            float curHeight = getThickness();
            curHeight += dt * mOpenCloseSpeed;
            if(curHeight >= mRestoreSize.height) {
                curHeight = mRestoreSize.height;
                mStatus = CLOSED;
            }
            setHeight(curHeight);
            mMovementToRestore.y += upperbound - curHeight / 2 - mRestorePosition.y;
        } else {
            float lowerbound = mRestorePosition.y - mRestoreSize.height / 2;
            float curHeight = getThickness();
            curHeight += dt * mOpenCloseSpeed;
            if(curHeight >= mRestoreSize.height) {
                curHeight = mRestoreSize.height;
                mStatus = CLOSED;
            }
            setHeight(curHeight);
            mMovementToRestore.y += lowerbound + curHeight / 2 - mRestorePosition.y;
        }
    } else if(mStatus == OPENING) {
        if(mDownDirDoor) {
            float upperbound = mRestorePosition.y + mRestoreSize.height / 2;
            float curHeight = getThickness();
            curHeight -= dt * mOpenCloseSpeed;
            if(curHeight <= minLength) {
                curHeight = minLength;
                mStatus = OPENED;
            }
            setHeight(curHeight);
            mMovementToRestore.y += upperbound - curHeight / 2 - mRestorePosition.y;
        } else {
            float lowerbound = mRestorePosition.y - mRestoreSize.height / 2;
            float curHeight = getThickness();
            curHeight -= dt * mOpenCloseSpeed;
            if(curHeight <= minLength) {
                curHeight = minLength;
                mStatus = OPENED;
            }
            setHeight(curHeight);
            mMovementToRestore.y += lowerbound + curHeight / 2 - mRestorePosition.y;
        }
    } else if(mStatus == OPENED) {
        setHeight(minLength);
        float upperbound = mRestorePosition.y + mRestoreSize.height / 2;
        float lowerbound = mRestorePosition.y - mRestoreSize.height / 2;
        if(mDownDirDoor) {
            mMovementToRestore.y += upperbound - minLength / 2 - mRestorePosition.y;
        } else {
            mMovementToRestore.y += lowerbound + minLength / 2 - mRestorePosition.y;
        }
    }
}
Exemplo n.º 2
0
dimeEntity::GeometryType 
dimeFaceEntity::extractGeometry(dimeArray <dimeVec3f> &verts,
			       dimeArray <int> &indices,
			       dimeVec3f &extrusionDir,
			       dxfdouble &thickness)
{
  verts.setCount(0);
  indices.setCount(0);
  
  verts.append(this->coords[0]);
  verts.append(this->coords[1]);
  if (this->isQuad()) {
    if (this->swapQuadCoords()) {
      verts.append(this->coords[3]);
      verts.append(this->coords[2]);
    }
    else {
      verts.append(this->coords[2]);
      verts.append(this->coords[3]);
    }
  }
  else {
    verts.append(this->coords[2]);
  }
  
  thickness = getThickness();
  getExtrusionDir(extrusionDir);

  return dimeEntity::POLYGONS;
}  
Exemplo n.º 3
0
void Arrow::adaptLine() const
{
	// Use circle to represent zero vector (every vector shorter than zeroVectorTolerance
	// is considered a zero vector)
	if (mLength <= zeroVectorTolerance)
	{
		mLine = Shapes::toConvexShape(sf::CircleShape(mThickness));
		mLine.setFillColor(mColor);
		mLine.move(-mThickness, -mThickness);
	}
	
	// If the line length is shorter than the triangle height, don't draw the line
	else if (mLength <= getTriangleHeight())
	{
		mLine = sf::ConvexShape();
	}
	
	// Normal arrow
	else
	{
		sf::Vector2f arrowDirection = (mLength - getTriangleHeight()) * unitVector(mDirection);
		
		mLine = Shapes::line(arrowDirection, mColor, getThickness());
	}
}
Exemplo n.º 4
0
//==============================================================================
void Toolbar::buttonClicked (Button*)
{
    jassert (missingItemsButton->isShowing());

    if (missingItemsButton->isShowing())
    {
        PopupMenu m;
        m.addCustomItem (1, new MissingItemsComponent (*this, getThickness()));
        m.showMenuAsync (PopupMenu::Options().withTargetComponent (missingItemsButton), nullptr);
    }
}
Exemplo n.º 5
0
void BlockBase::rotate() {
    auto w = getWidth();
    auto h = getThickness();
    setWidth(h);
    setHeight(w);
    
    mRestoreSize = Size(h,w);
    mRestorePosition = getPosition();
    
    normalizeUV();
}
/** \brief Draw widget face.
 * 
 * 	Draw image/diagram representing the widget's face.
 */
 void MicroViewProgressBarBase::drawFace() {
  uint8_t offsetX, offsetY, endOffset;
  offsetX=getWidgetX();
  offsetY=getWidgetY();

  switch(style){
    // HORIZONTAL
    case WIDGETSTYLE0:
    case WIDGETSTYLE1:
    endOffset = offsetX + totalTicks + 1;
      // Draw sides
    uView.lineV(offsetX, offsetY, getThickness());
    uView.lineV(offsetX+endOffset, offsetY, getThickness());
      // Draw top/bottom
    for (uint8_t i=offsetX; i<=endOffset; i++) {
      uView.pixel(i, offsetY+getThickness());
      uView.pixel(i, offsetY);
    }
    break;
    // VERTICAL 
    case WIDGETSTYLE2:
    case WIDGETSTYLE3:

    endOffset = offsetY + totalTicks + 2;
    uView.lineH(offsetX, offsetY, getThickness());
    uView.lineH(offsetX, offsetY+endOffset, getThickness());

    for (uint8_t i=offsetY; i<=endOffset; i++) {
      uView.pixel(offsetX+getThickness(), i);
      uView.pixel(offsetX, i);
    }
    break;
  }

}
Exemplo n.º 7
0
void BlockBase::subThickness(int val) {
    auto t = getThickness();
    t -= val;
    t = std::max<int>(t, 5);
    
    if(mKind == KIND_DEATH_CIRCLE || mKind == KIND_FORCEFIELD)
        mSprite->setScale(t / mImageSize);
    else
        mSprite->setScale(mSprite->getScaleX(), t / mImageSize);
    
    mRestoreSize = Size(mSprite->getScaleX() * mImageSize,
                        mSprite->getScaleY() * mImageSize);
    
    normalizeUV();
}
Exemplo n.º 8
0
void BlockBase::addThickness(int val) {
    auto t = getThickness();
    t += val;
    t = std::min<int>(t, VisibleRect::top().y * 1.3);
    
    if(mKind == KIND_DEATH_CIRCLE || mKind == KIND_FORCEFIELD)
        mSprite->setScale(t / mImageSize);
    else
        mSprite->setScale(mSprite->getScaleX(), t / mImageSize);
    
    mRestoreSize = Size(mSprite->getScaleX() * mImageSize,
                        mSprite->getScaleY() * mImageSize);
    
    normalizeUV();
}
Exemplo n.º 9
0
void BlockBase::normalizeUV() {
    
    if (mTextureName != "images/saw.png" && mTextureName != "images/saw_r.png") {
        mSprite->resetUV();
        return;
    }
    
    //change uv
    auto w = getWidth();
    auto h = getThickness();
    mSprite->resetUV();
    if(w >= h) {
        if (mTextureName != "images/saw.png") {
            mTextureName = "images/saw.png";
            Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(mTextureName);
            mSprite->setTexture(texture);
        }
        
        Texture2D::TexParams params = { GL_LINEAR, GL_LINEAR, GL_REPEAT, GL_CLAMP_TO_EDGE };
        mSprite->getTexture()->setTexParameters(params);
        
        float l = w / h;
        mSprite->setUVWidth(l);
        if(mUVFlipped) {
            mSprite->flipUVY();
        }
        
    } else {
        if (mTextureName != "images/saw_r.png") {
            mTextureName = "images/saw_r.png";
            Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(mTextureName);
            mSprite->setTexture(texture);
        }
        
        Texture2D::TexParams params = { GL_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE, GL_REPEAT };
        mSprite->getTexture()->setTexParameters(params);
        
        float l = h / w;
        mSprite->setUVHeight(l);

        if(mUVFlipped) {
            mSprite->flipUVX();
        }
    }
}
Exemplo n.º 10
0
bool
BlurredSegment::addPoint(Point2D p, Direction d){
  Node *bot, *top, *pbot, *ptop, *ptrStart;
  AntiPodalH preAPH;
  AntiPodalV preAPV;
  NodePtr preConvexHull;
  
  
  preConvexHull=convexhull->getFrontAndBack();
  preAPH=convexhull->getAPH();
  preAPV=convexhull->getAPV();
  
  convexhull->addPoint(p, d, ptrStart, bot, top, pbot, ptop);
  
  if(getThickness()>getMaxThickness()){
    // traitement particulier pour le retour en arrière 
    if(nbPoint==3){
      delete convexhull;
      this->convexhull = new ConvexHull(point1, point2, point3);
      return false;
    }else{
      //cerr<< "avant jol" << endl;
      convexhull->jolSetPreviousConvexHull(bot, top, pbot, ptop); 
      //cerr << " après retour arrière"<< endl;
      convexhull->setAPH(preAPH);
      convexhull->setAPV(preAPV);
      
      return false;
    }
  }else{
    nbPoint++;
  }
  
  if(d==RIGHT){
    lastRightPointAdded = p;
  }else{
    lastLeftPointAdded = p;
  }
  vectorPixel.push_back(p);
  //  cerr << " après retour arrière"<< endl;
  return true;

}
Exemplo n.º 11
0
void Toolbar::updateAllItemPositions (const bool animate)
{
    if (getWidth() > 0 && getHeight() > 0)
    {
        StretchableObjectResizer resizer;

        int i;
        for (i = 0; i < items.size(); ++i)
        {
            ToolbarItemComponent* const tc = items.getUnchecked(i);

            tc->setEditingMode (isEditingActive ? ToolbarItemComponent::editableOnToolbar
                                                : ToolbarItemComponent::normalMode);

            tc->setStyle (toolbarStyle);

            ToolbarSpacerComp* const spacer = dynamic_cast <ToolbarSpacerComp*> (tc);

            int preferredSize = 1, minSize = 1, maxSize = 1;

            if (tc->getToolbarItemSizes (getThickness(), isVertical(),
                                         preferredSize, minSize, maxSize))
            {
                tc->isActive = true;
                resizer.addItem (preferredSize, minSize, maxSize,
                                 spacer != nullptr ? spacer->getResizeOrder() : 2);
            }
            else
            {
                tc->isActive = false;
                tc->setVisible (false);
            }
        }

        resizer.resizeToFit (getLength());

        int totalLength = 0;

        for (i = 0; i < resizer.getNumItems(); ++i)
            totalLength += (int) resizer.getItemSize (i);

        const bool itemsOffTheEnd = totalLength > getLength();

        const int extrasButtonSize = getThickness() / 2;
        missingItemsButton->setSize (extrasButtonSize, extrasButtonSize);
        missingItemsButton->setVisible (itemsOffTheEnd);
        missingItemsButton->setEnabled (! isEditingActive);

        if (vertical)
            missingItemsButton->setCentrePosition (getWidth() / 2,
                                                   getHeight() - 4 - extrasButtonSize / 2);
        else
            missingItemsButton->setCentrePosition (getWidth() - 4 - extrasButtonSize / 2,
                                                   getHeight() / 2);

        const int maxLength = itemsOffTheEnd ? (vertical ? missingItemsButton->getY()
                                                         : missingItemsButton->getX()) - 4
                                             : getLength();

        int pos = 0, activeIndex = 0;
        for (i = 0; i < items.size(); ++i)
        {
            ToolbarItemComponent* const tc = items.getUnchecked(i);

            if (tc->isActive)
            {
                const int size = (int) resizer.getItemSize (activeIndex++);

                Rectangle<int> newBounds;
                if (vertical)
                    newBounds.setBounds (0, pos, getWidth(), size);
                else
                    newBounds.setBounds (pos, 0, size, getHeight());

                if (animate)
                {
                    Desktop::getInstance().getAnimator().animateComponent (tc, newBounds, 1.0f, 200, false, 3.0, 0.0);
                }
                else
                {
                    Desktop::getInstance().getAnimator().cancelAnimation (tc, false);
                    tc->setBounds (newBounds);
                }

                pos += size;
                tc->setVisible (pos <= maxLength
                                 && ((! tc->isBeingDragged)
                                      || tc->getEditingMode() == ToolbarItemComponent::editableOnPalette));
            }
        }
    }
}
 openstudio::Quantity RefractionExtinctionGlazing_Impl::thickness_IP() const {
   return getThickness(true);
 }
/** \brief Draw widget value.
 * 
 * 	Convert the current value of the widget and draw the ticker representing the value.
 */
 void MicroViewProgressBarBase::draw() {
  uint8_t offsetX, offsetY, endOffset;
  uint8_t tickPosition=0;
  char strBuffer[7];
  char formatStr[] = "%1d";

  formatStr[1] = '0' + getMaxValLen();	// Set the field width for the value range

  offsetX=getWidgetX();
  offsetY=getWidgetY();

  // Draw previous pointer in XOR mode to erase it
  switch(style){
    // HORIZONTAL
    case WIDGETSTYLE0:
    case WIDGETSTYLE1:
    tickPosition = (((float)(uint16_t)(prevValue-getMinValue())/(float)(uint16_t)(getMaxValue()-getMinValue())) * totalTicks) ;
    endOffset = offsetX + totalTicks + 2;

    for(uint8_t i =offsetX+1; i <= tickPosition; i++){
      uView.lineV(i,offsetY+1, getThickness()-1, WHITE, XOR);
    }
    break;
     // VERTICAL 
    case WIDGETSTYLE2:
    case WIDGETSTYLE3:
    tickPosition = ((float)(uint16_t)(getMaxValue()-prevValue)/(float)(uint16_t)(getMaxValue()-getMinValue()))*totalTicks + 1;
    endOffset = offsetY + totalTicks + 2;

    for(uint8_t i = endOffset-1; i >= tickPosition; i--){
      uView.lineH(offsetX+1,i,getThickness()-1, WHITE, XOR);
    }
    break;
  }


  if (needFirstDraw) {
    sprintf(strBuffer, formatStr, prevValue);	// print with fixed width so that blank space will cover larger value
    needFirstDraw=false;
  }
  else {
    // Draw previous pointer in XOR mode to erase it
    switch(style){
    // HORIZONTAL
      case WIDGETSTYLE0:
      case WIDGETSTYLE1:  
      tickPosition = (((float)(uint16_t)(getValue()-getMinValue())/(float)(uint16_t)(getMaxValue()-getMinValue()))*totalTicks);

      for(uint8_t i =offsetX+1; i <= tickPosition; i++){
        //uView.lineV(i, offsetY+1, getThickness()-2, WHITE, XOR);
        uView.lineV(i,offsetY+1, getThickness()-1,WHITE,XOR);
      }
      break;

      // VERTICAL 
      case WIDGETSTYLE2:
      case WIDGETSTYLE3:
      tickPosition = ((float)(uint16_t)(getMaxValue()-getValue())/(float)(uint16_t)(getMaxValue()-getMinValue()))*totalTicks + 1;
      for(uint8_t i = endOffset-1; i >= tickPosition; i--){
        uView.lineH(offsetX+1,i,getThickness()-1, WHITE, XOR);
      }
      break;
    }

    sprintf(strBuffer, formatStr, getValue());	// print with fixed width so that blank space will cover larger value
    prevValue=getValue();
  }

  // Draw value
  switch(style){
    case 0:
      //uView.setCursor(getLabelX()+totalTicks+4, offsetY+1);
    uView.setCursor(getLabelX()+totalTicks+4, getLabelY() + 1);
    break;
    case 1:
    uView.setCursor(getLabelX(), offsetY+10);
    break;
    case 2:
    uView.setCursor(getLabelX()+1, offsetY+totalTicks+4);
    break;  
    default:
    uView.setCursor(getLabelX()+getThickness() + 4, offsetY);
    break;
  }

  if (isPrintLabel()){
    uView.print(strBuffer);
  }
}
Exemplo n.º 14
0
 openstudio::Quantity GasMixture_Impl::thickness_IP() const {
   return getThickness(true);
 }
Exemplo n.º 15
0
 openstudio::Quantity GasMixture_Impl::thickness_SI() const {
   return getThickness(false);
 }
Exemplo n.º 16
0
Component ServoWheel::build()
{
  return get() // Get the SimpleWheel we inherit from
    - Cylinder(_servoRadius, _servoThickness + PART_MARGIN,50,false)
	 .translate(0, 0, getThickness() - (_servoThickness - PART_MARGIN));
}