Ejemplo n.º 1
0
void PokemonBox::changeCurrentSpot(int newspot)
{
    if (newspot == currentPoke)
        return;

    /* You could test for -1s to optimize perfs */
    updateScene(QList<QRectF>() << QRectF(calculatePos(currentPoke, selBg.size()), selBg.size())
                                    << QRectF(calculatePos(newspot, selBg.size()), selBg.size()));

    currentPoke = newspot;
}
Ejemplo n.º 2
0
size_t PredicateIndexArray::load(unsigned char *ptr, unsigned char *ptrMax, ProgressListener *listener) {
    size_t count = 0;
    bitmap = new BitSequence375();
    count += bitmap->load(&ptr[count], ptrMax, listener);

    array = new LogSequence2();
    count += array->load(&ptr[count], ptrMax, listener);

#if 0
    cout << "Predicate index:                                                    " << endl;
//    for(size_t i=0;i<array->getNumberOfElements();i++) {
//    	cout << array->get(i) << " " << bitmap->access(i)<< endl;
//    }
    for(size_t i=1;i<=getNumPredicates();i++) {
    	cout << "Predicate "<<i<< " first pos: " << calculatePos(i) << " occurs "<< getNumAppearances(i) << " times. "<<endl;

    	for(size_t j=1; j<=getNumAppearances(i);j++) {
    		size_t pos = getAppearance(i, j);
    		cout << "\t Appearance "<< j<< " at " << pos << " => " << bitmapTriples->arrayY->get(pos) << endl;
    	}
    }
#endif

    return count;
}
Ejemplo n.º 3
0
void PokemonBox::addGraphicsItem(int spot)
{
    QPointF pos = calculatePos(spot);
    pokemons[spot]->setPos(pos);

    scene()->addItem(pokemons[spot]);
    pokemons[spot]->setBox(this);
}
Ejemplo n.º 4
0
void LegendGroup::updateModel() {
	QList<QGraphicsItem*> pool;
	for (auto l : legends) { removeFromGroup(l); pool.append(l); }
	for (auto t : texts) { removeFromGroup(t); pool.append(t); }
	for (auto l : pool) delete l;
	legends.clear();
	texts.clear();
	for (int i=0; i<model->rowCount(); i++) {
		auto marker = model->at(i);
		QString l = marker->label() + "\t:  " + QString::number(marker->count());
		QColor color1 = marker->color1();
		QColor color2 = marker->color2();
		int type = marker->activeType();
		if (0 == type) {
			QRectF r = MarkerItem::rectFromClick(origin + QPointF(0, (mySize*2 + myPenWidth + 10) * (i+1)), mySize);
			QLineF l(r.topLeft(), r.bottomRight());
			auto marker = new ArrowItem(l);
			marker->setArrowhead(ArrowHead::Start);
			marker->setColor1(color1);
			marker->setColor2(color2);
			marker->setPenWidth(myPenWidth);
			legends.append(marker);
			addToGroup(marker);
		}
		else if (1 == type) {
			auto marker = new RectItem(MarkerItem::rectFromClick(origin + QPointF(0, (mySize*2 + myPenWidth + 10) * (i+1)), mySize));
			marker->setColor1(color1);
			marker->setColor2(color2);
			marker->setPenWidth(myPenWidth);
			legends.append(marker);
			addToGroup(marker);
		}
		else {
			auto marker = new EllipseItem(MarkerItem::rectFromClick(origin + QPointF(0, (mySize*2 + myPenWidth + 10) * (i+1)), mySize));
			marker->setColor1(color1);
			marker->setColor2(color2);
			marker->setPenWidth(myPenWidth);
			legends.append(marker);
			addToGroup(marker);
		}
		auto label = new RichTextItem(l);
		label->setFont(myFont);
		label->setFontSize(myFontSize);
		label->setKeyPressFunc([this](QKeyEvent* event) { updateRect(); });
		label->setTextInteractionFlags(Qt::TextEditorInteraction);
		label->setFlag(QGraphicsItem::ItemIsFocusable);
		QPointF textPos = legends.at(i)->boundingRect().center() + 
			QPointF(legends.at(i)->boundingRect().width()/2+20, -label->boundingRect().height()*0.5);
		label->setPos(textPos);
		label->setZValue(1000);
		texts.append(label);
		addToGroup(label);
	}
	calculatePos();
}
Ejemplo n.º 5
0
size_t PredicateIndexArray::getAppearance(size_t predicate, size_t appearance) {
	// Warning: Not concurrency friendly
	//if(currpred!=predicate) {
	currpred = predicate;
	currpos=calculatePos(predicate);
	//}

	size_t val = array->get(currpos+appearance-1);
	//cout << "Appearance at pos: " << currpos << " => "<< val<< endl;
	return val;
}
Ejemplo n.º 6
0
void PokemonBox::drawBackground(QPainter *painter, const QRectF &rect)
{
    QGraphicsView::drawBackground(painter, rect);

    if (currentPoke != -1) {
        QPointF selBGPos = calculatePos(currentPoke, selBg.size());
        QRectF intersection = rect.intersect(QRectF(selBGPos, selBg.size()));
        QRectF srcRect = QRectF(std::max(qreal(0), intersection.x()-selBGPos.x()), std::max(qreal(0), intersection.y()-selBGPos.y()),
                                selBg.width(), selBg.height());
        painter->drawPixmap(intersection, selBg, srcRect);
    }
}
Ejemplo n.º 7
0
/*!
 * \brief Constructor.
 *
 * \param propName The name of property.
 * \param propMap The reference of property map. The property is fetched from here.
 * \param scene The schematic scene to which this item should belong.
 */
PropertyItem::PropertyItem(const QString &propName , SchematicScene *scene) :
    m_propertyName(propName), m_staticText(m_propertyName), m_edited(false)
{
    m_staticText.append(" = ");
    if(m_staticText.startsWith("label", Qt::CaseInsensitive)) {
        m_staticText = "";
    }
    setTextInteractionFlags(Qt::TextEditorInteraction);
    setFlags(ItemIsMovable | ItemIsFocusable);

    //caculate the pos of static text initially.
    calculatePos();
    setAcceptsHoverEvents(false);
    if(scene) {
        scene->addItem(this);
    }
    m_edited = false;
}
Ejemplo n.º 8
0
void ofxSITextInput::update(){
    
    ofxSISwitch::update();

    
    // have to find how many units it is!
    
    //getBoundingBox();
    
    calculatePos();
    
   // wGridSize = (int)(boundingBox.width / this->mom->settings.grid.x);
    //hGridSize = (int)(boundingBox.height / this->mom->settings.grid.y);
    
    // don't update size here
    //ofxSIComponent::update(); 
    
    
}
Ejemplo n.º 9
0
void QxtToolTipPrivate::show(const QPoint& pos, QWidget* tooltip, QWidget* parent, const QRect& rect)
{
    Q_ASSERT(tooltip && parent);
    if (!isVisible())
    {
        int scr = 0;
        if (QApplication::desktop()->isVirtualDesktop())
            scr = QApplication::desktop()->screenNumber(pos);
        else
            scr = QApplication::desktop()->screenNumber(this);
        setParent(QApplication::desktop()->screen(scr));
        setWindowFlags(FLAGS);
        setToolTip(tooltip);
        currentParent = parent;
        currentRect = rect;
        move(calculatePos(scr, pos));
        QWidget::show();
    }
}
Ejemplo n.º 10
0
/*!
 * \brief Set font and calculate the static position again.
 * \note This hides the base implementation as base method isn't virtual!
 */
void PropertyItem::setFont(const QFont& f)
{
    QGraphicsTextItem::setFont(f);
    calculatePos();
}
Ejemplo n.º 11
0
/** Render a text
  *
  * The vRect parameter are top, bottom, left right coordonates in pixels
  * values.
  *
  * \param qr              The QuadµRenderer used to draw
  * \param vLineList       The LineInfoList used to cache
  * \param vColor          The color to renderer 
  * \param vRect           The rectangle wherer to draw the text
  * \param vVertAlign The vertical alignment flag
  * \param vHorzAlign The horizontal alignment flag
  * \param vSelection      Should we draw a selection
  * \param vSelectionStart The selection start
  * \param vSelectionEnd   The selection end
  *
  */
void RainbruRPG::OgreGui::Font::
renderAligned(Brush* qr, LineInfoList& vLineList, 
	      const ColourValue& vColor, const Ogre::Rectangle& vRect,
	      VerticalAlignType vVertAlign, HorizontalAlignType vHorzAlign,
	      bool vSelection, int vSelectionStart, int vSelectionEnd ){

  // Get the total height of the text (If we need it)
  float textHeight = 0.0f;
  if ( vVertAlign != VAT_TOP )
    textHeight = (float)(mLineList.size( ) * getMaxGlyphHeight( ));

  float currentY = 0.0f;
  size_t charIndex = 0;

  // Get screen space clip region and Brush position
  Ogre::Rectangle clip = qr->getClipRegion();
  Ogre::Vector2 pos;

  // Go through each character
  LineInfoList::const_iterator it=it = vLineList.begin( );

  /* Get the DrawingDevSettings value for Y and add it to scissor rectangle.
   *
   * Fix the 16+ bug.
   *
   */
  int dDevY = 0; // WAS qr->getDrawingDevYSum();
  clip.top += dDevY;
  clip.bottom += dDevY;

  for ( it = vLineList.begin(); it != vLineList.end( ); it++ ){
    const LineInfo& line = (*it);

    // Get the rendering position
    Ogre::Vector2 npos = calculatePos( vRect, line.getWidth(), textHeight, 
				       vHorzAlign, vVertAlign );
    npos.y += currentY;

    /* See if this line actually needs to be rendered
     *
     * v0.0.5-180 :
     * The following test is very important :
     *   if ( ( npos.y + getMaxGlyphHeight( ) + pos.y ) < clip.top )
     *
     * It is guilty in the 16+ bug of the MultiColumnList (The items
     * starting at index 17 are not drawn). But if I remove it, there is
     * a little black square clipping in the screen.
     *
     * The following test was removed :
     *   if ( !clip.isZero( ) ){
     *
     * The bug is fixed by adding Y drawingDev sum to clip.top and 
     * clip.bottom. Please see the code before this for statement.
     *
     */
    if ( ( npos.y + getMaxGlyphHeight( ) + pos.y ) < clip.top ){
      currentY += getMaxGlyphHeight( );
      charIndex += line.getText().size( );
      continue;
    }
    else if ( (npos.y + pos.y) > clip.bottom ){
      return;
    }
    int start = vSelectionStart - charIndex;
    int end = vSelectionEnd - charIndex;
    
    // Render the line of text
    render( qr, line.getText(), vColor, npos, vSelection, start, end ); 

    // Reset the current line
    currentY += getMaxGlyphHeight( );
    charIndex += line.getText().size( );
  }

}