Ejemplo n.º 1
0
  CostMapAccessor::CostMapAccessor(const CostMap2D& costMap, double maxSize, double poseX, double poseY)
    : ObstacleMapAccessor(computeWX(costMap, maxSize, poseX, poseY),
        computeWY(costMap, maxSize, poseX, poseY), 
        computeSize(maxSize, costMap.getResolution()), 
        computeSize(maxSize, costMap.getResolution()), 
        costMap.getResolution()), costMap_(costMap),
    maxSize_(maxSize){

      setCircumscribedCostLowerBound(costMap.getCircumscribedCostLowerBound());

      // Set robot position
      updateForRobotPosition(poseX, poseY);

      ROS_DEBUG_NAMED("costmap_2d", "Creating Local %d X %d Map\n", getWidth(), getHeight());
    }
Ejemplo n.º 2
0
void MSHashTable::resize(unsigned size_)
{
  MSHashEntry **oldBuckets=bucket();
  unsigned oldSize=size();
  
  _size=computeSize(size_);
  _bucket=new MSHashEntry*[size()];
  unsigned i=size();
  MSHashEntry **p=bucket();
  while(i--) *p++=0;

  if (oldBuckets!=0)
   {
     for (unsigned j=0;j<oldSize;j++)
      {
        // we want to add them in reverse order of the chains, i.e. add them in the order that they
        // were originally added - latest additions are at the top of the bucket chain
	MSHashEntry *entry=oldBuckets[j];
	MSHashEntry *prev;
	while (entry!=0&&entry->next()!=0) entry=entry->next(); 
	while (entry!=0)
	 {
	   prev=entry->prev();
           entry->prev(0),entry->next(0);
	   addEntry(entry); // rehash and add to the new table
	   entry=prev;
	 }
	oldBuckets[j]=0;
      }
     delete [] oldBuckets;  
   }
}
Ejemplo n.º 3
0
TCDynStr::TCDynStr(const TCString& str,uint pos,uint count)
/****************************************************************************
*
* Function:     TCDynStr::TCDynStr
* Parameters:   str     - TCString to copy from
*               pos     - Starting position in the string
*               count   - Number of characters to copy
*
* Description:  Constructs a string from another string, starting at the
*               position 'pos' and including 'count' characters.
*
****************************************************************************/
{
    CHECK(str.valid());
    if (pos > str.length())
        pos = str.length();
    if (count > str.length() - pos)
        count = str.length() - pos;
    len = count+1;
    size = computeSize(len);
    if ((text = new char[size]) != NULL) {
        memcpy(text,(const char *)str+pos,len);
        text[count] = '\0';             // Null terminate the string
        }
}
void ossimPlanetKmlScreenOverlayNode::update()
{
   if((!theIconGeom.valid())||(!theIconGeom->texture().valid())) return;
   if(theIconGeom->texture()->getImage())
   {
      ossim_uint32 w = theIconGeom->texture()->getImage()->s();
      ossim_uint32 h = theIconGeom->texture()->getImage()->t();
      if(w||h)
      {
         osg::Vec3d screenOrigin;
         osg::Vec3d overlayOrigin;
         osg::Vec3d size;
         computeScreenXY(screenOrigin);
         computeOverlayXY(overlayOrigin);
         computeSize(size);
//          std::cout << "oringx = " << origin[0] << std::endl;
//          std::cout << "oringy = " << origin[1] << std::endl;
         theIconGeom->setGeometry(screenOrigin-overlayOrigin,
                                  osg::Vec3d(size[0], 0.0, 0.0),
                                  osg::Vec3d(0.0, size[1], 0.0));
//       std::cout << "W = " << theIconGeom->texture()->getImage()->s() << std::endl;
         theNeedsUpdateFlag = false;
      }
      else
      {
         theNeedsUpdateFlag = true;
      }
   }
   else
   {
      theNeedsUpdateFlag = true;
//       std::cout << "NOT VALID!!!" << std::endl;
   }
}
Ejemplo n.º 5
0
TCDynStr& TCDynStr::operator = (const TCString& str)
/****************************************************************************
*
* Function:     TCDynStr::operator =
* Parameters:   str - TCString to assign from
* Returns:      Reference to the newly created string.
*
* Description:  Assignment operator given a string. We delete the old text
*               and then create a new string.
*
****************************************************************************/
{
    // If the amount of memory required for the new string is the same as
    // for the old string, we do not need to delete the memory allocated
    // to the text!

    CHECK(valid() && str.valid());
    uint newsize = computeSize(str.length()+1);
    char *temp = text;
    if (size != newsize)
        temp = new char[newsize];

    if (temp) {
        len = str.length()+1;
        memcpy(temp,str,len);
        if (size != newsize) {
            size = newsize;
            delete [] text;
            text = temp;
            }
        text[len-1] = '\0';                 // Null Terminate string
        }

    return *this;
}
Ejemplo n.º 6
0
void TCDynStr::shrink()
/****************************************************************************
*
* Function:     TCDynStr::shrink
*
* Description:  Shrinks the size of the allocated memory down to the
*               smallest possible amount.
*
****************************************************************************/
{
    char    *temp;

    CHECK(valid());
    if ((size - len) > granularity) {

        // Determine the smallest possible size (in increments of
        // granularity and allocate the new memory

        size = computeSize(len);
        temp = new char[size];

        // Copy the text and delete the old text

        if (temp)
            memcpy(temp,text,len);
        delete [] text;
        text = temp;
        }
}
Ejemplo n.º 7
0
void MSCheckPopupMenu::updateData(void)
{
  if (MSView::model()!=0)
   {
     freeze();
     const MSStringVector& aStringVector=stringVector();
     unsigned currentCount(itemCount());
     unsigned i;
     MSWidgetVector itemVector(children());
     MSCheckMenuItem *pMenuItem;
     for (i=0;i<aStringVector.length();i++)
      {
	if (i<itemVector.length())
	 {
           pMenuItem=(MSCheckMenuItem *)itemVector(i);
	   pMenuItem->label(aStringVector(i));
	   pMenuItem->state(MSFalse);
	 }
	else 
	  {
	    pMenuItem=new MSCheckMenuItem(this,aStringVector(i),0,i);
	    pMenuItem->selectColor(_selectColor);
	  }
	setItem(pMenuItem,i);
      }
     for (i=aStringVector.length();i<itemVector.length();i++)
      {
	pMenuItem=(MSCheckMenuItem *)itemVector(i);
	delete pMenuItem;
      }
     unfreeze();
     computeSize();
   }
  else removeAllItems();
}
Ejemplo n.º 8
0
 void Text::setFont(const std::string& f, float size)
 {
     m_font = f;
     m_pts = size;
     shrinkLines();
     computeSize();
 }
Ejemplo n.º 9
0
QRectF QGraphicsItemComposite::boundingRect() const
{
	// variables
	qreal xmin, xmax, ymin, ymax;
	computeSize(xmin, xmax, ymin, ymax);
	return QRectF(QPointF(), QRectF(QPointF(xmin, ymin), QPointF(xmax, ymax)).size());
}
Ejemplo n.º 10
0
int Compressor::getBestRatio(unsigned dataLength)
{
    int bestBit = 0;
    int compressedLength = -1;

    for (int bits = 1; bits <= 7; bits++)
    {
        int compressed = 0;
        int neededBits;

        for (int i = 0; i < (1 << bits) - 1; i++)
        {
            if ((int)mFrequency.size() <= i)
                break;

            compressed += mFrequency[i].count;
        }

        neededBits = computeSize(bits, dataLength, compressed);
        if (neededBits < compressedLength || compressedLength == -1)
        {
            compressedLength = neededBits;
            bestBit = bits;
        }
    }

    return bestBit;
}
Ejemplo n.º 11
0
TCDynStr::TCDynStr(const char *cstr,uint pos,uint count)
/****************************************************************************
*
* Function:     TCDynStr::TCDynStr
* Parameters:   cstr    - C style string to copy from
*               pos     - Starting position in the string
*               count   - Number of characters to copy
*
* Description:  Constructs a string from a C string, starting at the
*               position 'pos' and including 'count' characters.
*
****************************************************************************/
{
    CHECK(cstr != NULL);
    len = strlen(cstr) + 1;
    if (pos >= len)
        pos = len-1;
    if (count >= len - pos)
        count = len-1 - pos;
    len = count+1;
    size = computeSize(len);
    if ((text = new char[size]) != NULL) {
        memcpy(text,cstr+pos,count);
        text[count] = '\0';             // Null terminate the string
        }
}
Ejemplo n.º 12
0
void MSOptionPopupMenu::update(const MSIndexVector& index_)
{
  if (MSView::model()!=0)
   {
     if (index_.length()==0)
      {
	if (optionsModel().length()==itemCount())
	 {
	   MSMenuItem *mi;
           int i,n=itemCount();
           for(i=0;i<n;i++)
	    {
	      mi=(MSMenuItem *)itemVector()(i);
	      mi->label(optionsModel()(i));
	    }
	   computeSize();
	   optionMenu()->setSelectedItem(0);
	   optionMenu()->computeSize();
	 }
	else rebuildMenu();
      }
     else 
      {
	MSIndexVector iv(index_);
	iv.sortUp();
	if (iv(0)==itemCount())
	 {
	   for (unsigned i=0,j=itemCount();i<iv.length();i++,j++)
	    {
	      MSMenuItem *pMenuItem=new MSMenuItem(this,optionsModel()(j),0,j);
	      setItem(pMenuItem,j);
	    }
	 }
	else
	 {
	   for (unsigned i=0;i<iv.length();i++)
	    {
	      unsigned index=iv(i);
	      MSMenuItem *mi=menuItem(index);
	      if (mi!=0) mi->label(optionsModel()(index));
	    }
	 }
      }
     computeSize();
     optionMenu()->computeSize();
   }
}
Ejemplo n.º 13
0
bool NetworkGraphics::positionBranch(raw_address root, QPointF topLeft){
	if(!cloudAddrMap.contains(root)){
		return false;
	}

	GraphicNetCloud* cloud = getCloudByAddress(root);

	qDebug() << "NetworkGraphics::positionBranch - Moving cloud:" << cloud->getAddress().toString().c_str();

	QSizeF size = computeSize(root);
	qreal centerX = topLeft.x() + (size.width()/2.0);

	cloud->setY(topLeft.y());
	cloud->setX(centerX - (cloud->boundingRect().width() / 2.0));

	//Update to start in next row
	topLeft.setY(topLeft.y() + cloud->boundingRect().height());

	QMultiMap<uint8_t, raw_address> branch = network->getBranchAddresses(root);

	QList<uint8_t> keys = branch.uniqueKeys();

	if(keys.size() > 1){
	//for(int i=1; i<keys.size(); i++){
		QPointF cloudPos = topLeft;
		QList<GraphicNetCloud*> clouds = getCloudsByAddress(branch.values(keys[1]));
		qreal maxHeight = 0.0;

		for(int j=0; j<clouds.size(); j++){
			GraphicNetCloud* cloud = clouds[j];

			//cloud->setPos(cloudPos);

			QSizeF size = computeSize(cloud->getAddress());

			positionBranch(cloud->getAddress(), cloudPos);

			cloudPos.setX(cloudPos.x() + size.width());

			maxHeight = fmax(cloud->boundingRect().height(), maxHeight);
		}

		//topLeft.setY(topLeft.y() + maxHeight);
	}

	return true;
}
Ejemplo n.º 14
0
void MSToggleButtonBase::toggleShadowThickness(int thickness_) 
{
  if (toggleShadowThickness()!=thickness_)
   {
     _toggleShadowThickness=thickness_;
     computeSize(); 
   }
}
Ejemplo n.º 15
0
void Button::removeEditor()
{
    m_editor->hide();
    m_editor->deleteLater();
    m_editor = 0;
    
    computeSize();
    repaint();
    emit needsUpdate();
}
Ejemplo n.º 16
0
void ILayoutBox::clearChildren()
{
    for (std::list<TLayoutItem>::const_iterator it = m_children.begin(); it != m_children.end(); ++it)
    {
        delete it->widget;
    }

    m_children.clear();
    computeSize();
}
Ejemplo n.º 17
0
void
TextPainter::setText(std::string text) {

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

		_text = text;

		computeSize(_lastRoi, _lastResolution);
	}
}
Ejemplo n.º 18
0
    void onDraw(SkCanvas* canvas) override {
        canvas->translate(10, 10);
        for (size_t i = 0; i < SK_ARRAY_COUNT(fMatrix); ++i) {
            SkSize size = computeSize(fBM, fMatrix[i]);
            size.fWidth += 20;
            size.fHeight += 20;

            draw_row(canvas, fBM, fMatrix[i], size.fWidth);
            canvas->translate(0, size.fHeight);
        }
    }
Ejemplo n.º 19
0
ComputeSize MakeStencilComputeSize(const glm::ivec2& size, int radius)
{
  ComputeSize computeSize(ComputeSize::Default2D());

  auto localSize = ComputeSize::GetLocalSize2D();
  computeSize.DomainSize = size;
  computeSize.LocalSize = localSize;
  computeSize.WorkSize = glm::ceil(glm::vec2(size) / glm::vec2(localSize - glm::ivec2(2 * radius)));

  return computeSize;
}
Ejemplo n.º 20
0
void
TextPainter::setTextSize(double size) {

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

		_textSize = size;
		_padding  = size/2;

		computeSize(_lastRoi, _lastResolution);
	}
}
Ejemplo n.º 21
0
void MSTextRect::font(Font fid_)
{
  if (fid_!=0&&fid_!=font())
   {
     Font oldfid=_fid;
     _fid=fid_;
     textMSGC().font(fid_);
     _textFontStruct=(XFontStruct *)server()->fontStruct(font());
     computeSize();
     updateFont(oldfid);          
   }
}
Ejemplo n.º 22
0
void MSHashTable::init(unsigned size_)
{
  if (bucket()==0)
   {
     _size=computeSize(size_);
     _bucket=new MSHashEntry*[size()];
     unsigned i=size();
     MSHashEntry **p=bucket();
     while(i--) *p++=0;
   }
  else resize(size_);
}
Ejemplo n.º 23
0
FormDataIODevice::FormDataIODevice(FormData* data)
    : m_currentFile(0)
    , m_currentDelta(0)
    , m_fileSize(0)
    , m_dataSize(0)
{
    setOpenMode(FormDataIODevice::ReadOnly);

    prepareFormElements(data);
    prepareCurrentElement();
    computeSize();
}
Ejemplo n.º 24
0
        uint32_t ABCFile::size() 
        {
            AvmAssert(scriptCount != 0);
            AvmAssert(methodCount != 0);
            AvmAssert(methodbodyCount != 0);
            AvmAssert(classCount == instanceCount);
            
            uint32_t method_size = computeSize(methods.get());
            uint32_t metadata_size = computeSize(metadatas.get());
            uint32_t instance_size = computeSize(instances.get());
            uint32_t class_size = computeSize(classes.get());
            uint32_t script_size = computeSize(scripts.get());
            uint32_t body_size = computeSize(bodies.get());

            reported_size = (4 +
                             lenU30(intCount) + intBuf.size() + 
                             lenU30(uintCount) + uintBuf.size() + 
                             lenU30(doubleCount) + doubleBuf.size() + 
                             lenU30(stringCount) + stringBuf.size() +
                             lenU30(namespaceCount) + namespaceBuf.size() +
                             lenU30(nssetCount) + nssetBuf.size() +
                             lenU30(multinameCount) + multinameBuf.size() +
                             lenU30(methodCount) + method_size +
                             lenU30(metadataCount) + metadata_size +
                             lenU30(instanceCount) + instance_size + class_size +
                             lenU30(scriptCount) + script_size +
                             lenU30(methodbodyCount) + body_size);
            return reported_size;
        }
Ejemplo n.º 25
0
// Take a deep copy of the FormDataElement
FormDataIODevice::FormDataIODevice(FormData* data)
    : m_formElements(data ? data->elements() : Vector<FormDataElement>())
    , m_currentFile(0)
    , m_currentDelta(0)
    , m_fileSize(0)
    , m_dataSize(0)
{
    setOpenMode(FormDataIODevice::ReadOnly);

    if (!m_formElements.isEmpty() && m_formElements[0].m_type == FormDataElement::encodedFile)
        openFileForCurrentElement();
    computeSize();
}
Ejemplo n.º 26
0
size_type computeSize(const Teuchos::Array< DIM_TYPE > & dimensions)
{
  // In the MDArray<T>(const MDArrayView<T> &) constructor, I try to
  // pass the MDArrayView dimensions to computeSize(), but they come
  // in as ArrayView<const T> (for reasons I can't determine) and
  // cause all sorts of const-correctness problems.  So I copy them
  // into a new Array<T> and pass its view to the main computeSize()
  // function.  Fortunately, the array of dimensions is small.
  Teuchos::Array< DIM_TYPE > nonConstDims(0);
  nonConstDims.insert(nonConstDims.begin(),
                      dimensions.begin(),
                      dimensions.end());
  return computeSize(nonConstDims());
}
Ejemplo n.º 27
0
ComputeSize MakeCheckerboardComputeSize(const glm::ivec2& size)
{
  auto localSize = ComputeSize::GetLocalSize2D();
  localSize.x /= 2;
  localSize.y *= 2;

  ComputeSize computeSize(ComputeSize::Default2D());
  computeSize.DomainSize = size;
  computeSize.LocalSize = localSize;
  computeSize.WorkSize =
      glm::ceil(glm::vec2(size) / (glm::vec2(localSize) * glm::vec2(2.0f, 1.0f)));

  return computeSize;
}
void ossimPlanetKmlScreenOverlayNode::computeOverlayXY(osg::Vec3d& position)
{
   osg::Vec3d size;
   computeSize(size);
   switch(theOverlayXUnits)
   {
      case ossimPlanetKmlUnits_FRACTION:
      {
         position[0] = theOverlayOrigin[0]*size[0];
         break;
      }
      case ossimPlanetKmlUnits_PIXELS:
      {
         position[0] = theOverlayOrigin[0];
         break;
      }
      case ossimPlanetKmlUnits_INSET_PIXELS:
      {
         break;
      }
      default:
      {
         break;
      }
   }
   switch(theScreenYUnits)
   {
      case ossimPlanetKmlUnits_FRACTION:
      {
         position[1] = theOverlayOrigin[1]*size[1];
         
         break;
      }
      case ossimPlanetKmlUnits_PIXELS:
      {
         position[1] = theOverlayOrigin[1];
         break;
      }
      case ossimPlanetKmlUnits_INSET_PIXELS:
      {
         break;
      }
      default:
      {
         break;
      }
   }   
}
Ejemplo n.º 29
0
void ToolTipWidget::run(const QPoint &point, QAbstractItemModel *model,
    const QModelIndex &index, const QString & /* msg */)
{
    move(point);
    setModel(model);
    setRootIndex(index.parent());
    computeSize();
    setRootIsDecorated(model->hasChildren(index));
    // FIXME: use something more sensible
    QPalette pal = palette();
    QColor bg = pal.color(QPalette::Base);
    bg.setAlpha(20);
    pal.setColor(QPalette::Base, bg);
    setPalette(pal);
    //viewport()->setPalette(pal);
}
Ejemplo n.º 30
0
Button::Button(WelcomeScreen* parent, const QIcon& icon, 
               const QFont& font, const QString& text)
: QObject(parent)
, KGameCanvasPixmap(parent)
, m_icon(icon)
, m_font(font)
, m_text(text)
, m_fixed_width(false)
, m_down(false)
, m_hover(false)
, m_brightness(BRIGHTNESS_NORMAL)
, m_editor(0)
{
    computeSize();
    repaint();
}