Ejemplo n.º 1
0
QRectF GridLayoutItem::boundingRect() const
{
  int x = columns() * (cellSize().width() + spacing()) - spacing() + margin() * 2.0;
  int y = rows() * (cellSize().height() + spacing()) - spacing() + margin() * 2.0;

  return QRectF(0,0,x,y);
}
void lineRefinement::writeDict(Ostream& os, bool subDict) const
{
    if( subDict )
    {
        os << indent << token::BEGIN_BLOCK << incrIndent << nl;
    }

    if( additionalRefinementLevels() == 0 && cellSize() >= 0.0 )
    {
        os.writeKeyword("cellSize") << cellSize() << token::END_STATEMENT << nl;
    }
    else
    {
        os.writeKeyword("additionalRefinementLevels")
                << additionalRefinementLevels()
                << token::END_STATEMENT << nl;
    }

    // only write type for derived types
    if( type() != typeName_() )
    {
        os.writeKeyword("type") << type() << token::END_STATEMENT << nl;
    }

    os.writeKeyword("p0") << p0_ << token::END_STATEMENT << nl;
    os.writeKeyword("p1") << p1_ << token::END_STATEMENT << nl;

    if( subDict )
    {
        os << decrIndent << indent << token::END_BLOCK << endl;
    }
}
Ejemplo n.º 3
0
void TupColorPalette::setBaseColorsPanel()
{
#ifndef Q_OS_ANDROID
    QSize cellSize(50, 30);
#else
    QSize cellSize(70, 50);
#endif

    k->currentBaseColor = 0;
    QColor redColor(255, 0, 0);
    QBrush redBrush(redColor, k->brush.style());
    TupColorWidget *red = new TupColorWidget(0, redBrush, cellSize, false);
    red->selected();
    connect(red, SIGNAL(clicked(int)), this, SLOT(updateMatrix(int)));
    k->baseColors << red;

    QColor greenColor(0, 255, 0);
    QBrush greenBrush(greenColor, k->brush.style());
    TupColorWidget *green = new TupColorWidget(1, greenBrush, cellSize, false);
    connect(green, SIGNAL(clicked(int)), this, SLOT(updateMatrix(int)));
    k->baseColors << green;

    QColor blueColor(0, 0, 255);
    QBrush blueBrush(blueColor, k->brush.style());
    TupColorWidget *blue = new TupColorWidget(2, blueBrush, cellSize, false);
    connect(blue, SIGNAL(clicked(int)), this, SLOT(updateMatrix(int)));
    k->baseColors << blue;

    QColor whiteColor(255, 255, 255);
    QBrush whiteBrush(whiteColor, k->brush.style());
    TupColorWidget *white = new TupColorWidget(3, whiteBrush, cellSize, false);
    connect(white, SIGNAL(clicked(int)), this, SLOT(updateMatrix(int)));
    k->baseColors << white;

    QBoxLayout *bottomLayout = new QHBoxLayout;
    bottomLayout->setAlignment(Qt::AlignHCenter);
    bottomLayout->setContentsMargins(3, 3, 3, 3);

#ifndef Q_OS_ANDROID
    bottomLayout->setSpacing(10);
#else
    bottomLayout->setSpacing(25);
#endif

    bottomLayout->addWidget(red);
    bottomLayout->addWidget(green);
    bottomLayout->addWidget(blue);
    bottomLayout->addWidget(white);

    k->paletteGlobalLayout->addWidget(new TupSeparator(Qt::Horizontal));
    k->paletteGlobalLayout->addLayout(bottomLayout);
}
Ejemplo n.º 4
0
bool KIconEditGrid::zoomTo(int scale)
{
  QApplication::setOverrideCursor(waitCursor);
  emit scalingchanged(cellSize(), false);
  setUpdatesEnabled(false);
  setCellSize( scale );
  setUpdatesEnabled(true);
  emit needPainting();
  QApplication::restoreOverrideCursor();
  emit scalingchanged(cellSize(), true);
  if(scale == 1)
    return false;
  return true;
}
Ejemplo n.º 5
0
void QgsAlignRaster::RasterInfo::dump() const
{
  qDebug( "---RASTER INFO------------------" );
  qDebug( "wkt %s", mCrsWkt.toAscii().constData() );
  qDebug( "w/h %d,%d", mXSize, mYSize );
  qDebug( "cell x/y %f,%f", cellSize().width(), cellSize().width() );

  QgsRectangle r = extent();
  qDebug( "extent %s", r.toString().toAscii().constData() );

  qDebug( "transform" );
  qDebug( "%6.2f %6.2f %6.2f", mGeoTransform[0], mGeoTransform[1], mGeoTransform[2] );
  qDebug( "%6.2f %6.2f %6.2f", mGeoTransform[3], mGeoTransform[4], mGeoTransform[5] );
}
Ejemplo n.º 6
0
void GridLayoutItem::setItemViewGridPos(QGraphicsObject * item,std::pair<int,int> gridPos)
{
  if( item )
  {
    int x = gridPos.second * (cellSize().width() + spacing()) + margin();
    int y = gridPos.first * (cellSize().height() + spacing()) + margin();

    item->setPos(x,y);

    m_gridPosItemViewPairs[gridPos] = item;

    m_itemViewGridPosPairs[item] = gridPos;
  }
}
Ejemplo n.º 7
0
void KIconEditGrid::paintEvent(QPaintEvent *e)
{
//debug("KIconGrid::paintEvent");
  KColorGrid::paintEvent(e);

  if(hasGrid())
  {
    int x = e->rect().x() - ((e->rect().x() % cellSize()) + cellSize());
    if(x < 0) x = 0;
    int y = e->rect().y() - ((e->rect().y() % cellSize()) + cellSize());
    if(y < 0) y = 0;
    int cx = e->rect().right() + cellSize();
    int cy = e->rect().bottom() + cellSize();

    QPainter p;
    p.begin( this );

    for(int i = x; i < cx; i += cellSize())
      p.drawLine(i, y, i, cy);

    for(int i = y; i < cy; i += cellSize())
      p.drawLine(x, i, cx, i);

    p.end();
  }
//debug("KIconGrid::paintEvent - done");
}
void 
WallpaperCellCreator::updateCell (
        const QModelIndex &index, 
        MWidget           *cell) const
{
    GridImageWidget *imageWidget = qobject_cast<GridImageWidget *>(cell);
    QVariant         data = index.data(WallpaperModel::WallpaperDescriptorRole);
    WallpaperDescriptor desc = data.value<WallpaperDescriptor>();
  
    if (desc.hasThumbnail()) {
        QPixmap thumb = desc.thumbnail ();
        QSizeF  cSize = cellSize();
        
        imageWidget->setPixmap (
            thumb.scaled((int)cSize.width(), (int)cSize.height()));
        /*
         * It seems that this showAnimated() causes a flicker on the current
         * wallpaper when the applet list view is shown... well, we should
         * have a better solution to solve this, but this one works.
         */
        if (imageWidget->id() != desc.filePath() && !desc.selected())
            imageWidget->showAnimated();
        
        imageWidget->setID (desc.filePath());

        if (desc.thumbnailPending()) {
            desc.setThumbnailPending (false);
        }

    } else {
        /*
         * Resetting the cell thumbnail pixmap. We need this always, because 
         * the cells are re-used.
         */
        if (m_PlaceholderPixmap.size() != cellSize()) {
            QSizeF  cSize = cellSize();
            createPlaceholderPixmap ((int)cSize.width(), (int)cSize.height());
        }

        imageWidget->setPixmap (m_PlaceholderPixmap);
    }
    
    /*
     * The selection. 
     */
    imageWidget->setCurrent (desc.selected());
    imageWidget->setProgress (desc.progress());
}
Ejemplo n.º 9
0
/*----------PGTIOL-------------*/
bool pRPL::CellspaceGeoinfo::initByPGTIOL(PGTIOLDataset *pDataset,
                                          bool warning){
 if(pDataset == NULL) {
	if(warning) {
	  cerr << __FILE__ << " function:" << __FUNCTION__ \
		   << " Error: NULL dataset" << endl;
	}
	return false;
  }

  double aGeoTransform[6];
  pDataset->GetGeoTransform(aGeoTransform);
	if(aGeoTransform[2] != 0 || aGeoTransform[4] != 0) {
	  if(warning) {
		cerr << __FILE__ << " function:" << __FUNCTION__ \
			 << " Error: dataset is NOT north-up" << endl;
	  }
	  return false;
	}
	nwCorner(aGeoTransform[0], aGeoTransform[3]);
	cellSize(aGeoTransform[1], aGeoTransform[5]);
 
  if(pDataset->GetProjectionRef() != NULL) {
	_projection.assign(pDataset->GetProjectionRef());
  }
 
  return true;
}
Ejemplo n.º 10
0
void TupColorPalette::initColorsArray()
{
    int deltaX = 255/k->rows;
    int deltaY = 255/k->columns;
    int r = 255;
    int g = 0;
    int b = 0;
    int index = 0;

    for (int i=0; i < k->rows; i++) {
        for (int j=0; j < k->columns; j++) {
            g = (i*deltaY);
            b = (j*deltaX);

            if (g > 255)
                g = 255;
            if (b > 255)
                b = 255;

            QColor cellColor(r, g, b);
            QBrush brush(cellColor, k->brush.style());
            QSize cellSize(50, 30);
            TupColorWidget *button = new TupColorWidget(index, brush, cellSize, true);
            connect(button, SIGNAL(clicked(int)), this, SLOT(updateSelection(int)));
            index++;
            k->colors << button;
            k->colorMatrixLayout->addWidget(button, i, j);
        }
    }
}
Ejemplo n.º 11
0
bool KIconEditGrid::zoom(Direction d)
{
  int f = (d == In) ? (cellSize()+1) : (cellSize()-1);
  QApplication::setOverrideCursor(waitCursor);
  emit scalingchanged(cellSize(), false);
  setUpdatesEnabled(false);
  setCellSize( f );
  setUpdatesEnabled(true);
  //emit needPainting();
  QApplication::restoreOverrideCursor();

  emit scalingchanged(cellSize(), true);
  if(d == Out && cellSize() <= 1)
    return false;
  return true;
}
Ejemplo n.º 12
0
void	DrawSimulationGrid(const bbox_t& gbbox, const vec3i_t& dim, int slice)
{
	vec3i_t	gridDim = dim;

	vec3i_t	gridIdx;

	vec3_t	cellSize((gbbox.max.x-gbbox.min.x)/dim.x,(gbbox.max.y-gbbox.min.y)/dim.y,(gbbox.max.z-gbbox.min.z)/dim.z);

	bbox_t	bbox;

	vec3_t mn, mx;

	if(slice != -1)
	{
		gridIdx.z = slice;
		gridDim.z = slice+1;
	}

	for(; gridIdx.z < gridDim.z; gridIdx.z++)
		for(gridIdx.x = 0; gridIdx.x < gridDim.x; gridIdx.x++)
			for(gridIdx.y = 0; gridIdx.y < gridDim.y; gridIdx.y++)
			{
				mn.reset(gbbox.min.x + cellSize.x*gridIdx.x,gbbox.min.y + cellSize.y*gridIdx.y,gbbox.min.z + cellSize.z*gridIdx.z);
				mx.reset(mn.x + cellSize.x,mn.y + cellSize.y, mn.z + cellSize.z);

				bbox.reset(mn,mx);

				DrawBBox(bbox);
			}
}
Ejemplo n.º 13
0
MarkedBlock::FreeList MarkedBlock::specializedSweep()
{
    ASSERT(blockState != Allocated && blockState != FreeListed);
    ASSERT(destructorCallNeeded || sweepMode != SweepOnly);

    // This produces a free list that is ordered in reverse through the block.
    // This is fine, since the allocation code makes no assumptions about the
    // order of the free list.
    FreeCell* head = 0;
    size_t count = 0;
    for (size_t i = firstAtom(); i < m_endAtom; i += m_atomsPerCell) {
        if (blockState == Marked && m_marks.get(i))
            continue;

        JSCell* cell = reinterpret_cast_ptr<JSCell*>(&atoms()[i]);
        if (blockState == Zapped && !cell->isZapped())
            continue;

        if (destructorCallNeeded && blockState != New)
            callDestructor(cell);

        if (sweepMode == SweepToFreeList) {
            FreeCell* freeCell = reinterpret_cast<FreeCell*>(cell);
            freeCell->next = head;
            head = freeCell;
            ++count;
        }
    }

    m_state = ((sweepMode == SweepToFreeList) ? FreeListed : Zapped);
    return FreeList(head, count * cellSize());
}
Ejemplo n.º 14
0
void GameWidget::mousePressEvent(QMouseEvent *event)
{
    if (wygral > 0) return;
    int x = (event->pos().x() - fromLeft()) / cellSize();
    int y = (event->pos().y() - fromTop()) / cellSize();
    if (x >= 0 && x < board.size() && y >= 0 && y < board.size())
    {
        currentX = x;
        currentY = y;

        move();
        flashScreen = true;
        update();
        refreshScreen();
    }
}
MarkedBlock::FreeList MarkedBlock::specializedSweep()
{
    ASSERT(blockState != Allocated && blockState != FreeListed);
    ASSERT(!(dtorType == MarkedBlock::None && sweepMode == SweepOnly));

    // This produces a free list that is ordered in reverse through the block.
    // This is fine, since the allocation code makes no assumptions about the
    // order of the free list.
    FreeCell* head = 0;
    size_t count = 0;
    for (size_t i = firstAtom(); i < m_endAtom; i += m_atomsPerCell) {
        if (blockState == Marked && (m_marks.get(i) || (m_newlyAllocated && m_newlyAllocated->get(i))))
            continue;

        JSCell* cell = reinterpret_cast_ptr<JSCell*>(&atoms()[i]);

        if (dtorType != MarkedBlock::None && blockState != New)
            callDestructor(cell);

        if (sweepMode == SweepToFreeList) {
            FreeCell* freeCell = reinterpret_cast<FreeCell*>(cell);
            freeCell->next = head;
            head = freeCell;
            ++count;
        }
    }

    // We only want to discard the newlyAllocated bits if we're creating a FreeList,
    // otherwise we would lose information on what's currently alive.
    if (sweepMode == SweepToFreeList && m_newlyAllocated)
        m_newlyAllocated.clear();

    m_state = ((sweepMode == SweepToFreeList) ? FreeListed : Marked);
    return FreeList(head, count * cellSize());
}
Ejemplo n.º 16
0
void QHeader::mousePressEvent( QMouseEvent *m )
{
    if ( m->button() != LeftButton )
	return;
    handleIdx = 0;
    int c = orient == Horizontal ? m->pos().x() : m->pos().y();
    int i = 0;
    while ( i < (int) count() ) {
	if ( pPos(i+1) - MINSIZE/2 < c &&
	     c < pPos(i+1) + MINSIZE/2 ) {
		handleIdx = i+1;
		oldHIdxSize = cellSize( i );
	    if ( data->resize.testBit(i) )
		state = Sliding;
	    else
		state = Blocked;
	    break;
	} else if (  pPos(i)  < c && c < pPos( i+1 ) ) {
	    handleIdx = i;
	    moveToIdx = -1;
	    if ( data->clicks.testBit(i) )
		state = Pressed;
	    else
		state = Blocked;
	    clickPos = c;
	    repaint(sRect( handleIdx ));
	    break;
	}
	i++;
    }
}
Ejemplo n.º 17
0
void DrawCell( TMVA::PDEFoamCell *cell, TMVA::PDEFoam *foam,
	       Double_t x, Double_t y,
	       Double_t xscale,  Double_t yscale )
{
   // recursively draw cell and it's daughters

   Float_t xsize = xscale*1.5;
   Float_t ysize = yscale/3;
   if (xsize > 0.15) xsize=0.1; //xscale/2;
   if (cell->GetDau0() != NULL) {
      TLine *a1 = new TLine(x-xscale/4, y-ysize, x-xscale, y-ysize*2);
      a1->SetLineWidth(2);
      a1->Draw();
      DrawCell(cell->GetDau0(), foam, x-xscale, y-yscale, xscale/2, yscale);
   }
   if (cell->GetDau1() != NULL){
      TLine *a1 = new TLine(x+xscale/4, y-ysize, x+xscale, y-ysize*2);
      a1->SetLineWidth(2);
      a1->Draw();
      DrawCell(cell->GetDau1(), foam, x+xscale, y-yscale, xscale/2, yscale);
   }

   TPaveText *t = new TPaveText(x-xsize, y-ysize, x+xsize, y+ysize, "NDC");

   t->SetBorderSize(1);
   t->SetFillStyle(1);

   // draw all cell elements
   t->AddText( Form("Intg=%.5f", cell->GetIntg()) );
   t->AddText( Form("Var=%.5f", cell->GetDriv()) );
   TVectorD *vec = (TVectorD*) cell->GetElement();
   if (vec != NULL){
      for (Int_t i = 0; i < vec->GetNrows(); ++i) {
	 t->AddText( Form("E[%i]=%.5f", i, vec(i)) );
      }
   }

   if (cell->GetStat() != 1) {
      // cell is inactive --> draw split point
      t->SetFillColor( TColor::GetColor("#BBBBBB") );
      t->SetTextColor( TColor::GetColor("#000000") );

      // cell position and size
      TMVA::PDEFoamVect cellPosi(foam->GetTotDim()), cellSize(foam->GetTotDim());
      cell->GetHcub(cellPosi, cellSize);
      Int_t    kBest = cell->GetBest(); // best division variable
      Double_t xBest = cell->GetXdiv(); // best division point
      t->AddText( Form("dim=%i", kBest) );
      t->AddText( Form("cut=%.5g", foam->VarTransformInvers(kBest,cellPosi[kBest] + xBest*cellSize[kBest])) );
   } else {
      t->SetFillColor( TColor::GetColor("#DD0033") );
      t->SetTextColor( TColor::GetColor("#FFFFFF") );
   }

   t->Draw();

   return;
}
Ejemplo n.º 18
0
	const IBox View::computeCursor(const int2 &start, const int2 &end, const int3 &bbox, int height, int offset) const {
		float2 height_off = worldToScreen(float3(0, height, 0));
		int3 gbox(cellSize(), 1, cellSize());

		int3 start_pos = asXZ((int2)( screenToWorld(float2(start + pos()) - height_off) + float2(0.5f, 0.5f)));
		int3 end_pos   = asXZ((int2)( screenToWorld(float2(end   + pos()) - height_off) + float2(0.5f, 0.5f)));

		start_pos.y = end_pos.y = height + offset;
		
		{
			int apos1 = start_pos.x % gbox.x;
			int apos2 = apos1 - gbox.x + bbox.x;
			start_pos.x -= apos1 < gbox.x - apos1 || bbox.x >= gbox.x? apos1 : apos2;
		}
		{
			int apos1 = start_pos.z % gbox.z;
			int apos2 = apos1 - gbox.z + bbox.z;
			start_pos.z -= apos1 < gbox.z - apos1 || bbox.z >= gbox.z? apos1 : apos2;
		}
		if(end == start)
			end_pos = start_pos;
		
		int3 dir(end_pos.x >= start_pos.x? 1 : -1, 1, end_pos.z >= start_pos.z? 1 : -1);
		int3 size(::abs(end_pos.x - start_pos.x), 1, ::abs(end_pos.z - start_pos.z));
		size += bbox - int3(1, 1, 1);
		size.x -= size.x % bbox.x;
		size.z -= size.z % bbox.z;
		size = max(bbox, size);

		if(dir.x < 0)
			start_pos.x += bbox.x;
		if(dir.z < 0)
			start_pos.z += bbox.z;
		end_pos = start_pos + dir * size;

		if(start_pos.x > end_pos.x) swap(start_pos.x, end_pos.x);
		if(start_pos.z > end_pos.z) swap(start_pos.z, end_pos.z);
		
		int2 dims = m_tile_map.dimensions();
		start_pos = asXZY(clamp(start_pos.xz(), int2(0, 0), dims), start_pos.y);
		  end_pos = asXZY(clamp(  end_pos.xz(), int2(0, 0), dims),   end_pos.y);

		return IBox(start_pos, end_pos);

	}
Ejemplo n.º 19
0
void KIconEditGrid::drawPointArray(QPointArray a, DrawAction action)
{
  QRect rect = a.boundingRect();
  bool update = false;

  int s = a.size(); //((rect.size().width()) * (rect.size().height()));
  for(int i = 0; i < s; i++)
  {
    int x = a[i].x();
    int y = a[i].y();
    //if(img->valid(x, y) && !QSize(x, y).isNull() && rect.contains(QPoint(x, y)))
    if(img->valid(x, y) && rect.contains(QPoint(x, y)))
    {
      //debug("x: %d - y: %d", x, y);
      switch( action )
      {
        case Draw:
        {
          *((uint*)img->scanLine(y) + x) = currentcolor; //colors[cell]|OPAQUE;
          int cell = y * numCols() + x;
          setColor( cell, currentcolor, false );
          modified = true;
          update = true;
          //updateCell( y, x, FALSE );
          break;
        }
        case Mark:
        case UnMark:
          repaint(x*cellsize,y*cellsize, cellsize, cellsize, false);
          //updateCell( y, x, true );
          break;
        default:
          break;
      }
    }
  }
  if(update)
  {
    updateColors();
    repaint(rect.x()*cellSize()-1, rect.y()*cellSize()-1,
        rect.width()*cellSize()+1, rect.height()*cellSize()+1, false);
    pntarray.resize(0);
  }

}
Ejemplo n.º 20
0
QImage *KIconEditGrid::getSelection(bool cut)
{
  const QRect rect = pntarray.boundingRect();
  int nx = 0, ny = 0, nw = 0, nh = 0;
  rect.rect(&nx, &ny, &nw, &nh);

  QImage *tmp = new QImage(nw, nh, 32);
  tmp->fill(TRANSPARENT);

  int s = pntarray.size(); //((rect.size().width()) * (rect.size().height()));
  for(int i = 0; i < s; i++)
  {
    int x = pntarray[i].x();
    int y = pntarray[i].y();
    if(img->valid(x, y) && rect.contains(QPoint(x, y)))
    {
      *((uint*)tmp->scanLine(y-ny) + (x-nx)) = *((uint*)img->scanLine(y) + x);
      if(cut)
      {
        *((uint*)img->scanLine(y) + x) = TRANSPARENT;
        setColor( (y*numCols()) + x, TRANSPARENT, false );
      }
    }
  }

  QPointArray a(pntarray.copy());
  pntarray.resize(0);
  drawPointArray(a, Mark);
  emit selecteddata(false);
  if(cut)
  {
    updateColors();
    repaint(rect.x()*cellSize(), rect.y()*cellSize(),
            rect.width()*cellSize(), rect.height()*cellSize(), false);
    p = *img;
    emit changed(p);
    emit colorschanged(numColors(), data());
    emit newmessage(i18n("Selected area cutted"));
  }
  else
    emit newmessage(i18n("Selected area copied"));

  return tmp;
}
dictionary sphereRefinement::dict(bool ignoreType) const
{
    dictionary dict;

    if( additionalRefinementLevels() == 0 && cellSize() >= 0.0 )
    {
        dict.add("cellSize", cellSize());
    }
    else
    {
        dict.add("additionalRefinementLevels", additionalRefinementLevels());
    }

    dict.add("type", type());

    dict.add("centre", centre_);
    dict.add("radius", radius_);

    return dict;
}
Ejemplo n.º 22
0
Foam::scalarField Foam::cellShapeControl::cellSize
(
    const pointField& pts
) const
{
    scalarField cellSizes(pts.size());

    forAll(pts, i)
    {
        cellSizes[i] = cellSize(pts[i]);
    }
dictionary lineRefinement::dict(bool ignoreType) const
{
    dictionary dict;

    if( additionalRefinementLevels() == 0 && cellSize() >= 0.0 )
    {
        dict.add("cellSize", cellSize());
    }
    else
    {
        dict.add("additionalRefinementLevels", additionalRefinementLevels());
    }

    dict.add("type", type());

    dict.add("p0", p0_);
    dict.add("p1", p1_);

    return dict;
}
Ejemplo n.º 24
0
		int paintVerticalCell
			(QPainter *painter,
			 const QHeaderView* hv,
			 const QModelIndex& cellIndex,
			 const QModelIndex& leafIndex,
			 int logicalLeafIndex,
			 const QStyleOptionHeader& styleOptions,
			 const QRect& sectionRect,
			 int left) const
		{
			QStyleOptionHeader uniopt(styleOptions);
			setForegroundBrush(uniopt, cellIndex);
			setBackgroundBrush(uniopt, cellIndex);

			int width=cellSize(cellIndex, hv, uniopt).width();
			if(cellIndex==leafIndex)
				width=sectionRect.width()-left;
			int top=currentCellLeft(cellIndex, leafIndex, logicalLeafIndex, sectionRect.top(), hv);
			int height=currentCellWidth(cellIndex, leafIndex, logicalLeafIndex, hv);

			QRect r(left, top, width, height);

			uniopt.text = cellIndex.data(Qt::DisplayRole).toString();

			if(cellIndex.data(Qt::UserRole).isValid())
			{
				QRect new_r(0, 0,  r.width(), r.height());
				uniopt.rect = new_r;
				QPixmap original_button(r.width(), r.height());
				QPainter original_button_painter(&original_button);
				hv->style()->drawControl(QStyle::CE_HeaderSection, &uniopt, &original_button_painter, hv);

				new_r.setWidth(r.height());
				new_r.setHeight(r.width());
				QMatrix m;
				m.translate(0, r.height());
				m.rotate(-90);
				original_button_painter.setWorldMatrix(m, true);
				uniopt.rect = new_r;
				hv->style()->drawControl(QStyle::CE_HeaderLabel, &uniopt, &original_button_painter, hv);

				painter->drawPixmap(r, original_button);
			}
			else
			{
				bool clipping=painter->hasClipping();
				uniopt.rect = r;
				hv->style()->drawControl(QStyle::CE_Header, &uniopt, painter, hv);
				painter->setClipping(clipping);
			}
			return left+width;
		}
    int paintHorizontalCell
        (QPainter *painter,
         const QHeaderView* hv,
         const QModelIndex& cellIndex,
         const QModelIndex& leafIndex,
         int logicalLeafIndex,
         const QStyleOptionHeader& styleOptions,
         const QRect& sectionRect,
         int top) const
    {
        QStyleOptionHeader uniopt(styleOptions);
        setForegroundBrush(uniopt, cellIndex);
        setBackgroundBrush(uniopt, cellIndex);

        int height=cellSize(cellIndex, hv, uniopt).height();
        if(cellIndex==leafIndex)
            height=sectionRect.height()-top;
        int left=currentCellLeft(cellIndex, leafIndex, logicalLeafIndex, sectionRect.left(), hv);
        int width=currentCellWidth(cellIndex, leafIndex, logicalLeafIndex, hv);

        QRect r(left, top, width, height);

        uniopt.text = cellIndex.data(Qt::DisplayRole).toString();

        painter->save();
        uniopt.rect = r;
        if(cellIndex.data(Qt::UserRole).isValid())
        {
            hv->style()->drawControl(QStyle::CE_HeaderSection, &uniopt, painter, hv);
            QMatrix m;
            m.rotate(-90);
            painter->setWorldMatrix(m, true);
            QRect new_r(0, 0,  r.height(), r.width());
            new_r.moveCenter(QPoint(-r.center().y(), r.center().x()));
            uniopt.rect = new_r;
            hv->style()->drawControl(QStyle::CE_HeaderLabel, &uniopt, painter, hv);
        }
        else
        {
            hv->style()->drawControl(QStyle::CE_Header, &uniopt, painter, hv);
        }
        painter->restore();
        hv->childAt(QPoint(uniopt.rect.left()+5, uniopt.rect.top()+3))->setToolTip(uniopt.text);
        return top+height;
    }
Ejemplo n.º 26
0
/*-------------GDAL-----*/
bool pRPL::CellspaceGeoinfo::
initByGDAL(GDALDataset *pDataset,
           bool warning) {
  if(pDataset == NULL) {
    if(warning) {
      cerr << __FILE__ << " function:" << __FUNCTION__ \
           << " Error: NULL GDAL dataset" << endl;
    }
    return false;
  }

  double aGeoTransform[6];
  if(pDataset->GetGeoTransform(aGeoTransform) == CE_None) {
    if(aGeoTransform[2] != 0 || aGeoTransform[4] != 0) {
      if(warning) {
        cerr << __FILE__ << " function:" << __FUNCTION__ \
             << " Error: GDAL dataset is NOT north-up" << endl;
      }
      return false;
    }
    
    nwCorner(aGeoTransform[0], aGeoTransform[3]);
    cellSize(aGeoTransform[1], aGeoTransform[5]);
  }

  if(pDataset->GetProjectionRef() != NULL) {
    _projection.assign(pDataset->GetProjectionRef());
  }

  /*
  for(int i = 0; i < 6; i++) {
    cout << aGeoTransform[i] << "\t";
  }
  cout << endl;
  cout << _projection << endl;
  */

  return true;
}
Ejemplo n.º 27
0
void InventoryPanel::_build()
{
    cocos2d::Size cellSize(54, 48);

    setContentSize(cocos2d::Size(cellSize.width * 8 + 8, cellSize.height + 16));

    _background = cocos2d::ui::Scale9Sprite::createWithSpriteFrameName("ui-panel-transparent.png");
    _background->setContentSize(getContentSize());
    _background->setAnchorPoint(cocos2d::Vec2::ZERO);
    addChild(_background);

    float x = 8;
    for (size_t i = 0; i < 8; i++)
    {
        auto cell = cocos2d::Sprite::createWithSpriteFrameName("ui-inventory-cell.png");
        cell->setAnchorPoint(cocos2d::Vec2::ZERO);
        cell->setPosition(cocos2d::Vec2(x, 8));
        _background->addChild(cell);

        x += cellSize.width;
    }
}
Ejemplo n.º 28
0
QRect GridDefinition::cellRect(QRect rect, int row, int column, int rowSpan, int columnSpan)
{
    return QRect(cellPoint(rect, row, column), cellSize(rect, row, column, rowSpan, columnSpan));
}
void mitk::ReduceContourSetFilter::GenerateData()
{
  unsigned int numberOfInputs = this->GetNumberOfIndexedInputs();
  unsigned int numberOfOutputs(0);

  vtkSmartPointer<vtkPolyData> newPolyData;
  vtkSmartPointer<vtkCellArray> newPolygons;
  vtkSmartPointer<vtkPoints> newPoints;

  // For the purpose of evaluation
  //  unsigned int numberOfPointsBefore (0);
  m_NumberOfPointsAfterReduction = 0;

  for (unsigned int i = 0; i < numberOfInputs; i++)
  {
    mitk::Surface *currentSurface = const_cast<mitk::Surface *>(this->GetInput(i));
    vtkSmartPointer<vtkPolyData> polyData = currentSurface->GetVtkPolyData();

    newPolyData = vtkSmartPointer<vtkPolyData>::New();
    newPolygons = vtkSmartPointer<vtkCellArray>::New();
    newPoints = vtkSmartPointer<vtkPoints>::New();

    vtkSmartPointer<vtkCellArray> existingPolys = polyData->GetPolys();

    vtkSmartPointer<vtkPoints> existingPoints = polyData->GetPoints();

    existingPolys->InitTraversal();

    vtkIdType *cell(nullptr);
    vtkIdType cellSize(0);

    for (existingPolys->InitTraversal(); existingPolys->GetNextCell(cellSize, cell);)
    {
      bool incorporatePolygon =
        this->CheckForIntersection(cell, cellSize, existingPoints, /*numberOfIntersections, intersectionPoints, */ i);
      if (!incorporatePolygon)
        continue;

      vtkSmartPointer<vtkPolygon> newPolygon = vtkSmartPointer<vtkPolygon>::New();

      if (m_ReductionType == NTH_POINT)
      {
        this->ReduceNumberOfPointsByNthPoint(cellSize, cell, existingPoints, newPolygon, newPoints);
        if (newPolygon->GetPointIds()->GetNumberOfIds() != 0)
        {
          newPolygons->InsertNextCell(newPolygon);
        }
      }
      else if (m_ReductionType == DOUGLAS_PEUCKER)
      {
        this->ReduceNumberOfPointsByDouglasPeucker(cellSize, cell, existingPoints, newPolygon, newPoints);
        if (newPolygon->GetPointIds()->GetNumberOfIds() > 3)
        {
          newPolygons->InsertNextCell(newPolygon);
        }
      }

      // Again for evaluation
      //      numberOfPointsBefore += cellSize;
      m_NumberOfPointsAfterReduction += newPolygon->GetPointIds()->GetNumberOfIds();
    }

    if (newPolygons->GetNumberOfCells() != 0)
    {
      newPolyData->SetPolys(newPolygons);
      newPolyData->SetPoints(newPoints);
      newPolyData->BuildLinks();

      this->SetNumberOfIndexedOutputs(numberOfOutputs + 1);
      mitk::Surface::Pointer surface = mitk::Surface::New();
      this->SetNthOutput(numberOfOutputs, surface.GetPointer());
      surface->SetVtkPolyData(newPolyData);
      numberOfOutputs++;
    }
  }

  //  MITK_INFO<<"Points before: "<<numberOfPointsBefore<<" ##### Points after: "<<numberOfPointsAfter;
  this->SetNumberOfIndexedOutputs(numberOfOutputs);

  if (numberOfOutputs == 0)
  {
    mitk::Surface::Pointer tmp_output = mitk::Surface::New();
    tmp_output->SetVtkPolyData(vtkPolyData::New());
    this->SetNthOutput(0, tmp_output.GetPointer());
  }
  // Setting progressbar
  if (this->m_UseProgressBar)
    mitk::ProgressBar::GetInstance()->Progress(this->m_ProgressStepSize);
}
Ejemplo n.º 30
0
Vec2 Grid::ArrangeChildren()
{
	// Count fixed space
	Vec2 allFixedSpace(0, 0);
	for (GridColumn& column : columns)
		if (column.GetSizingPolicy() == eGridLineSizing::FIXED)
			allFixedSpace.x += column.GetWidth();

	for (GridRow& row : rows)
		if (row.GetSizingPolicy() == eGridLineSizing::FIXED)
			allFixedSpace.y += row.GetHeight();

	// Count FIT_TO_CONTENT space
	// Search for max width per column
	std::vector<float> maxWidths(columns.size());
	for (GridColumn& column : columns)
	{
		if (column.GetSizingPolicy() == eGridLineSizing::FIT_TO_CONTENT)
		{
			float maxWidth = 0;

			for (Gui* cell : column.GetCells())
				maxWidth = std::max(maxWidth, cell->ArrangeChildren().x);

			maxWidths[column.GetIndex()] = maxWidth;
		}
	}

	std::vector<float> maxHeights(rows.size());
	for (GridRow& row : rows)
	{
		if (row.GetSizingPolicy() == eGridLineSizing::FIT_TO_CONTENT)
		{
			float maxHeight = 0;

			for (Gui* cell : row.GetCells())
				maxHeight = std::max(maxHeight, cell->ArrangeChildren().y);

			maxHeights[row.GetIndex()] = maxHeight;
		}
	}

	// Sum remaining space multipliers
	Vec2 spaceMultiplierSum(0, 0);
	for (GridColumn& column : columns)
		if (column.GetSizingPolicy() == eGridLineSizing::FILL_SPACE)
			spaceMultiplierSum.x += column.GetSpaceMultiplier();

	for (GridRow& row : rows)
		if (row.GetSizingPolicy() == eGridLineSizing::FILL_SPACE)
			spaceMultiplierSum.y += row.GetSpaceMultiplier();

	Vec2 baseSpaceForFlexibleItem = Vec2::Max(Vec2(0, 0), (GetContentSize() - allFixedSpace)) / spaceMultiplierSum;

	Vec2 newSize(0, 0);

	// Grid cell arrangement
	Vec2 pos = GetContentPos();
	//float gridHeight = 0;
	for (uint32_t i = 0; i < dimension.y; ++i)
	{
		GridRow* row = GetRow(i);

		pos.x = GetContentPos().x;

		// Reset grid width
		newSize.x = 0;

		// Cell size
		Vec2 cellSize(0, 0);

		for (uint32_t j = 0; j < dimension.x; ++j)
		{
			Gui* cell = GetCell(j, i);
			GridColumn* column = GetColumn(j);

			// Determine the size of the cell
			if (column->GetSizingPolicy() == eGridLineSizing::FIXED)
				cellSize.x = column->GetWidth();
			else if (column->GetSizingPolicy() == eGridLineSizing::FILL_SPACE)
				cellSize.x = baseSpaceForFlexibleItem.x * column->GetSpaceMultiplier();
			else if (column->GetSizingPolicy() == eGridLineSizing::FIT_TO_CONTENT)
				cellSize.x = maxWidths[j];
			else
				assert(0);

			if (row->GetSizingPolicy() == eGridLineSizing::FIXED)
				cellSize.y = row->GetHeight();
			else if (row->GetSizingPolicy() == eGridLineSizing::FILL_SPACE)
				cellSize.y = baseSpaceForFlexibleItem.y * row->GetSpaceMultiplier();
			else if (row->GetSizingPolicy() == eGridLineSizing::FIT_TO_CONTENT)
				cellSize.y = maxHeights[i];
			else
				assert(0);

			cell->Arrange(pos, cellSize);

			pos.x += cellSize.x;
			newSize.x += cellSize.x;
		}

		newSize.y += cellSize.y;
		pos.y += cellSize.y;
	}

	return newSize;
}