Exemple #1
0
bool RGBImage::saveXML(QXmlStreamWriter *doc) const
{
    Q_ASSERT(doc != NULL);

    doc->writeStartElement(KXMLQLCRGBAlgorithm);
    doc->writeAttribute(KXMLQLCRGBAlgorithmType, KXMLQLCRGBImage);

    doc->writeTextElement(KXMLQLCRGBImageFilename, this->doc()->normalizeComponentPath(m_filename));

    doc->writeTextElement(KXMLQLCRGBImageAnimationStyle, animationStyleToString(animationStyle()));

    doc->writeStartElement(KXMLQLCRGBImageOffset);
    doc->writeAttribute(KXMLQLCRGBImageOffsetX, QString::number(xOffset()));
    doc->writeAttribute(KXMLQLCRGBImageOffsetY, QString::number(yOffset()));
    doc->writeEndElement();

    /* End the <Algorithm> tag */
    doc->writeEndElement();

    return true;
}
Exemple #2
0
/**
 * Save the function's contents to an XML document
 *
 * @param doc The QDomDocument to save to
 */
bool EFX::saveXML(QDomDocument* doc, QDomElement* wksp_root)
{
	QDomElement root;
	QDomElement tag;
	QDomElement subtag;
	QDomText text;
	QString str;

	Q_ASSERT(doc != NULL);
	Q_ASSERT(wksp_root != NULL);

	/* Function tag */
	root = doc->createElement(KXMLQLCFunction);
	wksp_root->appendChild(root);

	root.setAttribute(KXMLQLCFunctionID, id());
	root.setAttribute(KXMLQLCFunctionType, Function::typeToString(m_type));
	root.setAttribute(KXMLQLCFunctionName, name());

	/* Fixtures */
	QListIterator <EFXFixture*> it(m_fixtures);
	while (it.hasNext() == true)
		it.next()->saveXML(doc, &root);

	/* Propagation mode */
	tag = doc->createElement(KXMLQLCEFXPropagationMode);
	root.appendChild(tag);
	text = doc->createTextNode(propagationModeToString(m_propagationMode));
	tag.appendChild(text);

	/* Speed bus */
	tag = doc->createElement(KXMLQLCBus);
	root.appendChild(tag);
	tag.setAttribute(KXMLQLCBusRole, KXMLQLCBusFade);
	str.setNum(busID());
	text = doc->createTextNode(str);
	tag.appendChild(text);

	/* Direction */
	tag = doc->createElement(KXMLQLCFunctionDirection);
	root.appendChild(tag);
	text = doc->createTextNode(Function::directionToString(m_direction));
	tag.appendChild(text);

	/* Run order */
	tag = doc->createElement(KXMLQLCFunctionRunOrder);
	root.appendChild(tag);
	text = doc->createTextNode(Function::runOrderToString(m_runOrder));
	tag.appendChild(text);

	/* Algorithm */
	tag = doc->createElement(KXMLQLCEFXAlgorithm);
	root.appendChild(tag);
	text = doc->createTextNode(algorithm());
	tag.appendChild(text);

	/* Width */
	tag = doc->createElement(KXMLQLCEFXWidth);
	root.appendChild(tag);
	str.setNum(width());
	text = doc->createTextNode(str);
	tag.appendChild(text);

	/* Height */
	tag = doc->createElement(KXMLQLCEFXHeight);
	root.appendChild(tag);
	str.setNum(height());
	text = doc->createTextNode(str);
	tag.appendChild(text);

	/* Rotation */
	tag = doc->createElement(KXMLQLCEFXRotation);
	root.appendChild(tag);
	str.setNum(rotation());
	text = doc->createTextNode(str);
	tag.appendChild(text);

	/* Start function */
	tag = doc->createElement(KXMLQLCEFXStartScene);
	root.appendChild(tag);
	str.setNum(startScene());
	text = doc->createTextNode(str);
	tag.appendChild(text);
	if (startSceneEnabled() == true)
		tag.setAttribute(KXMLQLCFunctionEnabled, KXMLQLCTrue);
	else
		tag.setAttribute(KXMLQLCFunctionEnabled, KXMLQLCFalse);

	/* Stop function */
	tag = doc->createElement(KXMLQLCEFXStopScene);
	root.appendChild(tag);
	str.setNum(stopScene());
	text = doc->createTextNode(str);
	tag.appendChild(text);
	if (stopSceneEnabled() == true)
		tag.setAttribute(KXMLQLCFunctionEnabled, KXMLQLCTrue);
	else
		tag.setAttribute(KXMLQLCFunctionEnabled, KXMLQLCFalse);

	/********************************************
	 * X-Axis 
	 ********************************************/
	tag = doc->createElement(KXMLQLCEFXAxis);
	root.appendChild(tag);
	tag.setAttribute(KXMLQLCFunctionName, KXMLQLCEFXX);

	/* Offset */
	subtag = doc->createElement(KXMLQLCEFXOffset);
	tag.appendChild(subtag);
	str.setNum(xOffset());
	text = doc->createTextNode(str);
	subtag.appendChild(text);

        /* Frequency */
	subtag = doc->createElement(KXMLQLCEFXFrequency);
	tag.appendChild(subtag);
	str.setNum(xFrequency());
	text = doc->createTextNode(str);
	subtag.appendChild(text);

        /* Phase */
	subtag = doc->createElement(KXMLQLCEFXPhase);
	tag.appendChild(subtag);
	str.setNum(xPhase());
	text = doc->createTextNode(str);
	subtag.appendChild(text);

	/********************************************
	 * Y-Axis 
	 ********************************************/
	tag = doc->createElement(KXMLQLCEFXAxis);
	root.appendChild(tag);
	tag.setAttribute(KXMLQLCFunctionName, KXMLQLCEFXY);

	/* Offset */
	subtag = doc->createElement(KXMLQLCEFXOffset);
	tag.appendChild(subtag);
	str.setNum(yOffset());
	text = doc->createTextNode(str);
	subtag.appendChild(text);

	/* Frequency */
	subtag = doc->createElement(KXMLQLCEFXFrequency);
	tag.appendChild(subtag);
	str.setNum(yFrequency());
	text = doc->createTextNode(str);
	subtag.appendChild(text);

        /* Phase */
	subtag = doc->createElement(KXMLQLCEFXPhase);
	tag.appendChild(subtag);
	str.setNum(yPhase());
	text = doc->createTextNode(str);
	subtag.appendChild(text);

	return true;
}
Exemple #3
0
void KDGanttViewTaskLink::showMeType( bool visible )
{
    //qDebug("KDGanttViewTaskLink::showMeType %d",linkType());
    hide();
    isvisible = visible;
    int wid = 1;
    QPen p;
    QBrush b;
    p.setWidth(wid);
    b.setStyle(Qt::SolidPattern);
    if (ishighlighted) {
        b.setColor(myColorHL);
        p.setColor(myColorHL);

    } else {
        b.setColor(myColor);
        p.setColor(myColor);
    }
    QPoint start, end;
    QPtrListIterator<KDCanvasLine> horIt(*horLineList);
    QPtrListIterator<KDCanvasLine> verIt(*verLineList);
    QPtrListIterator<KDCanvasLine> horIt2(*horLineList2);
    QPtrListIterator<KDCanvasLine> verIt2(*verLineList2);
    QPtrListIterator<KDCanvasLine> horIt3(*horLineList3);
    QPtrListIterator<KDCanvasPolygon> topIt(*topList);
    QPtrListIterator<KDCanvasPolygon> topLeftIt(*topLeftList);
    QPtrListIterator<KDCanvasPolygon> topRightIt(*topRightList);
    QPtrListIterator<KDGanttViewItem> fromIt(fromList);
    QPtrListIterator<KDGanttViewItem> toIt(toList);
    for ( ; fromIt.current(); ++fromIt ) {
        (*fromIt)->setTextOffset(QPoint(30,0));
        (*fromIt)->moveTextCanvas();
        toIt.toFirst();
        for ( ; toIt.current(); ++toIt ) {
            if (isvisible && (*fromIt)->isVisibleInGanttView &&
               (*toIt)->isVisibleInGanttView && myTimeTable->taskLinksVisible) {
                (*horIt)->setPen(p);
                (*verIt)->setPen(p);
                (*horIt2)->setPen(p);
                (*verIt2)->setPen(p);
                (*horIt3)->setPen(p);
                (*topIt)->setBrush(b);
                (*topLeftIt)->setBrush(b);
                (*topRightIt)->setBrush(b);
                (*toIt)->setTextOffset(QPoint(30,0));
                (*toIt)->moveTextCanvas();
                switch (linkType()) {
                    case StartStart: {
                        start = (*fromIt)->middleLeft();
                        end = (*toIt)->middleLeft()-QPoint(12,0);
                        bool down = start.y() < end.y();
                        (*horIt)->setPoints(start.x()-xOffset(*fromIt),start.y(),
                                            start.x()-10, start.y());
                        (*verIt)->setPoints(
                            (*horIt)->endPoint().x(),
                            (*horIt)->endPoint().y(),
                            (*horIt)->endPoint().x(),
                            (down ? (*toIt)->itemPos()+1
                                  : (*toIt)->itemPos()+(*toIt)->height()-1));
                        (*horIt2)->setPoints((*verIt)->endPoint().x(),
                                            (*verIt)->endPoint().y(),
                                            end.x()-12,
                                            (*verIt)->endPoint().y());
                        (*verIt2)->setPoints((*horIt2)->endPoint().x(),
                                            (*horIt2)->endPoint().y(),
                                            (*horIt2)->endPoint().x(),
                                            end.y());
                        (*horIt3)->setPoints((*verIt2)->endPoint().x(),
                                            (*verIt2)->endPoint().y(),
                                            end.x(),
                                            end.y());
                        (*topRightIt)->move(end.x(),end.y());
                        (*topRightIt)->show();
                        break;
                    }
                    case FinishFinish: {
                        start = (*fromIt)->middleRight();
                        end = (*toIt)->middleRight()+QPoint(12,0);
                        bool down = start.y() < end.y();
                        (*horIt)->setPoints(start.x()+xOffset(*fromIt),start.y(),
                                            start.x()+10, start.y());
                        (*verIt)->setPoints(
                            (*horIt)->endPoint().x(),
                            (*horIt)->endPoint().y(),
                            (*horIt)->endPoint().x(),
                            (down ? (*toIt)->itemPos()+1
                                  : (*toIt)->itemPos()+(*toIt)->height()-1));
                        (*horIt2)->setPoints((*verIt)->endPoint().x(),
                                            (*verIt)->endPoint().y(),
                                            end.x()+12,
                                            (*verIt)->endPoint().y());
                        (*verIt2)->setPoints((*horIt2)->endPoint().x(),
                                            (*horIt2)->endPoint().y(),
                                            (*horIt2)->endPoint().x(),
                                            end.y());
                        (*horIt3)->setPoints((*verIt2)->endPoint().x(),
                                            (*verIt2)->endPoint().y(),
                                            end.x(),
                                            end.y());
                        (*topLeftIt)->move(end.x(),end.y());
                        (*topLeftIt)->show();
                        break;
                    }
                    case FinishStart: {
                        start = (*fromIt)->middleRight();
                        end = (*toIt)->middleLeft() - QPoint(12,0);
                        bool down = start.y() < end.y();                        
                        (*horIt)->setPoints(start.x()+xOffset(*fromIt),start.y(),
                                            start.x()+10,start.y());
                        (*verIt)->setPoints(
                            (*horIt)->endPoint().x(),
                            (*horIt)->endPoint().y(),
                            (*horIt)->endPoint().x(),
                            (down ? (*toIt)->itemPos()+1
                                  : (*toIt)->itemPos()+(*toIt)->height()-1));
                        (*horIt2)->setPoints((*verIt)->endPoint().x(),
                                            (*verIt)->endPoint().y(),
                                            end.x()-12,
                                            (*verIt)->endPoint().y());
                        (*verIt2)->setPoints((*horIt2)->endPoint().x(),
                                            (*horIt2)->endPoint().y(),
                                            (*horIt2)->endPoint().x(),
                                            end.y());
                        (*horIt3)->setPoints((*verIt2)->endPoint().x(),
                                            (*verIt2)->endPoint().y(),
                                            end.x(),
                                            end.y());
                        (*topRightIt)->move(end.x(),end.y());
                        
                        (*topRightIt)->show();
    
                        break;
                    }
                    case StartFinish: {
                        start = (*fromIt)->middleRight();
                        end = (*toIt)->middleRight()+QPoint(12,0);
                        bool down = start.y() < end.y();
                        (*horIt)->setPoints(start.x()+xOffset(*fromIt),start.y(),
                                            start.x()+10, start.y());
                        (*verIt)->setPoints(
                            (*horIt)->endPoint().x(),
                            (*horIt)->endPoint().y(),
                            (*horIt)->endPoint().x(),
                            (down ? (*toIt)->itemPos()+1
                                  : (*toIt)->itemPos()+(*toIt)->height()-1));
                        (*horIt2)->setPoints((*verIt)->endPoint().x(),
                                            (*verIt)->endPoint().y(),
                                            end.x()-12,
                                            (*verIt)->endPoint().y());
                        (*verIt2)->setPoints((*horIt2)->endPoint().x(),
                                            (*horIt2)->endPoint().y(),
                                            (*horIt2)->endPoint().x(),
                                            end.y());
                        (*horIt3)->setPoints((*verIt2)->endPoint().x(),
                                            (*verIt2)->endPoint().y(),
                                            end.x(),
                                            end.y());
                        (*topRightIt)->move(end.x(),end.y());
                        (*topRightIt)->show();
                        break;
                    }
                    default:
                        qWarning("KDGanttViewTaskLink: Unknown link type");
                        break;
                }
                (*horIt)->show();
                (*verIt)->show();
                (*horIt2)->show();
                (*verIt2)->show();
                (*horIt3)->show();
            }
            ++horIt;
            ++verIt;
            ++horIt2;
            ++verIt2;
            ++horIt3;
            ++topIt;
            ++topLeftIt;
            ++topRightIt;
        }
    }
}
Exemple #4
0
void KFinderWin::offsets( int &_xpos, int &_ypos )
{
    _ypos = yOffset();
    _xpos = xOffset();
}
Exemple #5
0
bool EFX::saveXML(QXmlStreamWriter *doc)
{
    Q_ASSERT(doc != NULL);

    /* Function tag */
    doc->writeStartElement(KXMLQLCFunction);

    /* Common attributes */
    saveXMLCommon(doc);

    /* Fixtures */
    QListIterator <EFXFixture*> it(m_fixtures);
    while (it.hasNext() == true)
        it.next()->saveXML(doc);

    /* Propagation mode */
    doc->writeTextElement(KXMLQLCEFXPropagationMode, propagationModeToString(m_propagationMode));

    /* Speeds */
    saveXMLSpeed(doc);
    /* Direction */
    saveXMLDirection(doc);
    /* Run order */
    saveXMLRunOrder(doc);

    /* Algorithm */
    doc->writeTextElement(KXMLQLCEFXAlgorithm, algorithmToString(algorithm()));
    /* Width */
    doc->writeTextElement(KXMLQLCEFXWidth, QString::number(width()));
    /* Height */
    doc->writeTextElement(KXMLQLCEFXHeight, QString::number(height()));
    /* Rotation */
    doc->writeTextElement(KXMLQLCEFXRotation, QString::number(rotation()));
    /* StartOffset */
    doc->writeTextElement(KXMLQLCEFXStartOffset, QString::number(startOffset()));
    /* IsRelative */
    doc->writeTextElement(KXMLQLCEFXIsRelative, QString::number(isRelative() ? 1 : 0));

    /********************************************
     * X-Axis
     ********************************************/
    doc->writeStartElement(KXMLQLCEFXAxis);
    doc->writeAttribute(KXMLQLCFunctionName, KXMLQLCEFXX);

    /* Offset */
    doc->writeTextElement(KXMLQLCEFXOffset, QString::number(xOffset()));
    /* Frequency */
    doc->writeTextElement(KXMLQLCEFXFrequency, QString::number(xFrequency()));
    /* Phase */
    doc->writeTextElement(KXMLQLCEFXPhase, QString::number(xPhase()));

    /* End the (X) <Axis> tag */
    doc->writeEndElement();

    /********************************************
     * Y-Axis
     ********************************************/
    doc->writeStartElement(KXMLQLCEFXAxis);
    doc->writeAttribute(KXMLQLCFunctionName, KXMLQLCEFXY);

    /* Offset */
    doc->writeTextElement(KXMLQLCEFXOffset, QString::number(yOffset()));
    /* Frequency */
    doc->writeTextElement(KXMLQLCEFXFrequency, QString::number(yFrequency()));
    /* Phase */
    doc->writeTextElement(KXMLQLCEFXPhase, QString::number(yPhase()));

    /* End the (Y) <Axis> tag */
    doc->writeEndElement();

    /* End the <Function> tag */
    doc->writeEndElement();

    return true;
}
Exemple #6
0
void Board::mousePressEvent(QMouseEvent *e)
{
	// Calculate field position
	int pos_x = (e->pos().x() - xOffset()) / tiles.tileWidth();
	int pos_y = (e->pos().y() - yOffset()) / tiles.tileHeight();

	if(e->pos().x() < xOffset() || e->pos().y() < yOffset() ||
		pos_x >= x_tiles() || pos_y >= y_tiles())
	{
		pos_x = -1;
		pos_y = -1;
	}

	// Mark tile
	if(e->button() == LeftButton)
	{
		clearHighlight();

		if(pos_x != -1)
			marked(pos_x, pos_y);
	}

	// Assist by highlighting all tiles of same type
	if(e->button() == RightButton)
	{
		int clicked_tile = getField(pos_x, pos_y);

		// Clear marked tile
		if(mark_x != -1 && getField(mark_x, mark_y) != clicked_tile)
		{
			// We need to set mark_x and mark_y to -1 before calling
			// updateField() to ensure the tile is redrawn as unmarked.
			int oldmarkx = mark_x;
			int oldmarky = mark_y;
			mark_x = -1;
			mark_y = -1;
			updateField(oldmarkx, oldmarky, false);
		}
		else
		{
			mark_x = -1;
			mark_y = -1;
		}

		// Perform highlighting
		if(clicked_tile != highlighted_tile)
		{
			int old_highlighted = highlighted_tile;
			highlighted_tile = clicked_tile;
			for(int i = 0; i < x_tiles(); i++)
			{
				for(int j = 0; j < y_tiles(); j++)
				{
					const int field_tile = getField(i, j);
					if(field_tile != EMPTY)
					{
						if(field_tile == old_highlighted)
							updateField(i, j, false);
						else if(field_tile == clicked_tile)
							updateField(i, j, false);
					}
				}
			}
		}
	}
}
Exemple #7
0
void SVGIcon::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
	Icon::paint(painter, option, widget);

	style()->paint(painter, xOffset(), yOffset() );
}
Exemple #8
0
void RWinColorPalette::OnPaint( )
{
	CPaintDC dc( this );
	RDcDrawingSurface ds;
	ds.Initialize( (HDC) dc ) ;

	CRect rcWindow;
	GetClientRect( rcWindow );
	RIntRect rcClient( rcWindow );

	RBitmapImage&	biPalette	= GetPaletteBitmapImage();
	biPalette.LockImage( );
	biPalette.Render( ds, rcClient );
	biPalette.UnlockImage( );
	ds.DetachDCs();

	CClientDC dcClient( this );
	ds.Initialize( (HDC) dcClient ) ;

	RColor crOldFill = ds.GetFillColor();
	RColor crOldPen  = ds.GetPenColor();

	if (m_ptSelected.m_x >= 0 && m_ptSelected.m_y >= 0)
	{
		//
		// Draw selected cell

		RIntRect rcSelected( 
			m_ptSelected.m_x + 1,
			m_ptSelected.m_y + 1,
			m_ptSelected.m_x + kCellSize.m_dx - 1,
			m_ptSelected.m_y + kCellSize.m_dy - 1 );

		RSolidColor crBlack( kBlack );
		RSolidColor crHilight( GetSysColor( COLOR_BTNHILIGHT ) );
		ds.Draw3dRect( rcSelected, crBlack, crHilight );

		RSolidColor crShadow( GetSysColor( COLOR_BTNSHADOW ) );
		rcSelected.m_Top -= 1; rcSelected.m_Left -= 1;
		ds.Draw3dRect( rcSelected, crShadow, crHilight );

		if (GetFocus() == this)
		{
			RSolidColor rSolid = GetSysColor( COLOR_HIGHLIGHT );
			RColor rSelected( rSolid );

			rcSelected.Inflate( RIntSize( 1, 1 ), RIntSize( 2, 2 ) );
			ds.SetPenColor( RColor( rSelected ) );
			ds.FrameRectangle( rcSelected );
		}
	}

	if (m_crHilited != (COLORREF) -1L)
	{
		// Draw color chip
		m_rcColorChip = RIntRect( 
			m_ptHilited.m_x,
			m_ptHilited.m_y,
			m_ptHilited.m_x + 2 * kCellSize.m_dx,
			m_ptHilited.m_y + 2 * kCellSize.m_dy );

		YIntDimension xOffset( 2 * kCellSize.m_dx );
		YIntDimension yOffset( 2 * kCellSize.m_dy );

		if (m_rcColorChip.m_Right + xOffset > rcWindow.right)
		{
			xOffset = -3 * kCellSize.m_dx;
		}

		if (m_rcColorChip.m_Bottom + yOffset > rcWindow.bottom)
		{
			yOffset = -3 * kCellSize.m_dy;
		}

		m_rcColorChip.Offset( RIntSize( xOffset, yOffset ) );

		RColor crFill = RSolidColor( m_crHilited );
		RColor crPen = RSolidColor( kWhite );

		ds.SetPenColor( crPen );
		ds.SetFillColor( crFill );
		ds.FillRectangle( m_rcColorChip );
		ds.FrameRectangle( m_rcColorChip );
	}
	else
	{
		m_rcColorChip = RIntRect( 0, 0, 1, 1 );
	}

	ds.SetPenColor( crOldPen );
	ds.SetFillColor( crOldFill );
	ds.DetachDCs();
}
void GameCritterObject::onMovementAnimationEnded(Event* event)
{
    auto hexagon = movementQueue()->back();
    movementQueue()->pop_back();
    Game::getInstance()->locationState()->moveObjectToHexagon(this, hexagon);
    auto animation = dynamic_cast<Animation*>(ui());

    if (movementQueue()->size() == 0)
    {
        _moving = false;
        animation->stop();
        setActionAnimation("aa");
        return;
    }

    auto newHexagon = movementQueue()->back();
    auto newOrientation = this->hexagon()->orientationTo(newHexagon);
    
    if (event->name() == "animationEnded" || (int)newOrientation != orientation())
    {
        _orientation = newOrientation;
        auto newAnimation = _generateMovementAnimation();
        if (event->name() == "actionFrame") 
        {
            newAnimation->setCurrentFrame(animation->currentFrame());
            newAnimation->setActionFrame(animation->actionFrame());
        }
        else
        {
            newAnimation->setActionFrame(_running ? 2 : 4);
        }
        newAnimation->addEventHandler("actionFrame",    std::bind(&GameCritterObject::onMovementAnimationEnded, this, std::placeholders::_1));
        newAnimation->addEventHandler("animationEnded", std::bind(&GameCritterObject::onMovementAnimationEnded, this, std::placeholders::_1));
        newAnimation->play();
        delete _ui;
        _ui = animation = newAnimation;
    }

    if (event->name() == "actionFrame")
    {
        // at each action frame critter switches to the next hex and frame positions are offset relative to the action frame offsets
        auto actionFrame = animation->frames()->at(animation->actionFrame());
        for (auto it = animation->frames()->rbegin(); it != animation->frames()->rend(); ++it)
        {
            auto frame = (*it);
            frame->setXOffset(frame->xOffset() - actionFrame->xOffset());
            frame->setYOffset(frame->yOffset() - actionFrame->yOffset());
            if (frame == actionFrame) break;
        }

        if (_running)
        {
            switch (animation->actionFrame())
            {
                // those frame numbers were guessed to make seamless running animation
                case 2:
                    animation->setActionFrame(4);
                    break;
                case 4:
                    animation->setActionFrame(6);
                    break;
                case 5:
                    animation->setActionFrame(7);
                    break;
            }
        }
    }
}
Exemple #10
0
void TableHead::mouseMoveEvent(QMouseEvent *e)
{
    //	printf("mouseMoveEvent()\n");
    int col = findCol(e->x());
    if (col < 0)
    {
        emit htable->outOfHCell();
        return;
    }
    //	if( !dragging) return;
    emit htable->flyOnHCell(col);

    int thold = abs(press.x() - e->pos().x());

    if (e->buttons() == Qt::LeftButton //  Button state
        and htable->options & HTBL_REORDER_COLS)
    {
        {

            if (!dragging and thold > 5)
            {
                dragging = true;
                drag_offset =
                    press.x() - htable->colOffset(click_col) + xOffset();
                floatHead->setTitle(htable->title(click_col),
                                    cellWidth(click_col), height());
                floatHead->show();
                // vp->show();
            }

            if (dragging)
            {
                //	htable->body->drawGhostCol(drag_pos -
                // drag_offset, w);
                floatHead->move(e->x() - drag_offset, 0);

                int vcol = findColNoMinus(e->x() - drag_offset);
                int vcol_offx = htable->colOffset(vcol);
                static int old_pos = -1;
                //	printf("vcol=%d\n",vcol);

                // virtual Pointer move!
                if (old_pos != vcol_offx)
                {
                    QWidget *p = parentWidget(); // htable
                    //	vp->setMovable(htable->columnMovable(htable->columnMovable(vcol)
                    // and htable->columnMovable(click_col)
                    // ));
                    //	vp->move(vcol_offx -
                    // p->geometry().x()
                    //,p->geometry().y() -
                    // 13);
                    // vp->move(e->x()	,10);
                    old_pos = vcol_offx;
                }
                drag_pos = e->x(); // save old pos

                return;
            }
        }
    }

    if (col != -1) // ToolTip
    {
        //	for(int i=0;i<1024*1024;i++)	htable->tipText(col);
        //// memory leak
        // test
        QString s = htable->tipText(col);

        if (!s.isEmpty())
            QToolTip::showText(e->globalPos(), s);
    }
}
Exemple #11
0
int Braces::contentLeft()
{
	return xOffset() + contentLeft_;
}
Exemple #12
0
    void ScreenText::set_text(const std::string* text,
		  const GLfloat* x,
		  const GLfloat* y,
		  GLfloat xAnchor,
		  GLfloat yAnchor,
		  size_t n)
    {
      screenAnchor_=x[0]<0?(y[0]<0?SCREEN_ANCHOR_TOP_RIGHT:SCREEN_ANCHOR_BOTTOM_RIGHT):
	(y[0]<0?SCREEN_ANCHOR_TOP_LEFT:SCREEN_ANCHOR_BOTTOM_LEFT);

      GLfloat height(font_.charHeight);
      const GLfloat* charWidth(font_.charWidth);
      
      std::vector<GLfloat> buffer(0);

      for(size_t i(0);i<n;++i)
	{
	  GLfloat width(font_.string_width(text[i]));
	  GLfloat xOffset(-width*(xAnchor+0.5f));
	  GLfloat yOffset(-height*(yAnchor+0.5f));
	  GLfloat xLeft,xRight((x[i]+xOffset));
	  GLfloat yBottom(y[i]+yOffset),yTop(yBottom+height);    
	  
	  for(size_t j(0);j<text[i].length();++j)
	    {
	      xLeft = xRight;
	      xRight = xLeft+charWidth[GLubyte(text[i].at(j))];
	      
	      buffer.push_back(xLeft);buffer.push_back(yTop);
	      buffer.push_back(xLeft);buffer.push_back(yBottom);
	      buffer.push_back(xRight);buffer.push_back(yTop);
	      buffer.push_back(xRight);buffer.push_back(yBottom);
	      buffer.push_back(xRight);buffer.push_back(yTop);
	      buffer.push_back(xLeft);buffer.push_back(yBottom);
	    }
	}
      
      unsigned char charOffset=font_.charOffset;
      const GLfloat* charTextureWidth(font_.charTextureWidth);
      GLfloat charTextureHeight(font_.charTextureHeight);
      GLfloat charsPerRow(font_.charsPerRow);
      GLfloat charsPerColumn(font_.charsPerColumn);
      
      for(unsigned int i=0;i<n;++i)
	{
	  for(unsigned int j=0;j<text[i].length();++j)
	    {
	      unsigned char c = GLubyte(text[i].at(j)-charOffset);
	      GLfloat uLeft = (c%GLubyte(charsPerRow))/charsPerRow;
	      GLfloat uRight = uLeft+charTextureWidth[c+charOffset];
	      GLfloat vTop = 1-(c/GLubyte(charsPerRow))/charsPerColumn;
	      GLfloat vBottom = vTop-charTextureHeight;
	      
	      buffer.push_back(uLeft);buffer.push_back(vTop);
	      buffer.push_back(uLeft);buffer.push_back(vBottom);
	      buffer.push_back(uRight);buffer.push_back(vTop);
	      buffer.push_back(uRight);buffer.push_back(vBottom);
	      buffer.push_back(uRight);buffer.push_back(vTop);
	      buffer.push_back(uLeft);buffer.push_back(vBottom);
	    }
	}

      usedSize_=buffer.size();

      if(!usedSize_)
	return;
      
      glBindBuffer(GL_ARRAY_BUFFER,glBuffer_);
      if(usedSize_>bufferSize_)
	{
	  bufferSize_=usedSize_;
	  glBufferData(GL_ARRAY_BUFFER,GLsizeiptr(bufferSize_*sizeof(GLfloat)),&buffer[0],GL_DYNAMIC_DRAW);
	  
	}
      else
	{
	  void* ptr(NULL);
	  while(!ptr)
	    ptr=glMapBuffer(GL_ARRAY_BUFFER,GL_READ_WRITE);
	  GLfloat* floatPtr=reinterpret_cast<GLfloat*>(ptr);
	  for(size_t i(0);i<usedSize_;++i)
	    floatPtr[i]=buffer[i];
	  if(!glUnmapBuffer(GL_ARRAY_BUFFER))
	    throw(std::string("could not unmap buffer for bitmap string"));
	}

      glBindBuffer(GL_ARRAY_BUFFER,0);

#ifdef SCIGMA_USE_OPENGL_3_2
      glBindVertexArray(vertexArray_);
      glBindBuffer(GL_ARRAY_BUFFER,glBuffer_);
      prepare_attributes();
      glBindBuffer(GL_ARRAY_BUFFER,0);
      glBindVertexArray(0);
#endif
      GLERR;
    }
Exemple #13
0
bool EFX::saveXML(QDomDocument* doc, QDomElement* wksp_root)
{
    QDomElement root;
    QDomElement tag;
    QDomElement subtag;
    QDomText text;
    QString str;

    Q_ASSERT(doc != NULL);
    Q_ASSERT(wksp_root != NULL);

    /* Function tag */
    root = doc->createElement(KXMLQLCFunction);
    wksp_root->appendChild(root);

    /* Common attributes */
    saveXMLCommon(&root);

    /* Fixtures */
    QListIterator <EFXFixture*> it(m_fixtures);
    while (it.hasNext() == true)
        it.next()->saveXML(doc, &root);

    /* Propagation mode */
    tag = doc->createElement(KXMLQLCEFXPropagationMode);
    root.appendChild(tag);
    text = doc->createTextNode(propagationModeToString(m_propagationMode));
    tag.appendChild(text);

    /* Speeds */
    saveXMLSpeed(doc, &root);

    /* Direction */
    saveXMLDirection(doc, &root);

    /* Run order */
    saveXMLRunOrder(doc, &root);

    /* Algorithm */
    tag = doc->createElement(KXMLQLCEFXAlgorithm);
    root.appendChild(tag);
    text = doc->createTextNode(algorithmToString(algorithm()));
    tag.appendChild(text);

    /* Width */
    tag = doc->createElement(KXMLQLCEFXWidth);
    root.appendChild(tag);
    str.setNum(width());
    text = doc->createTextNode(str);
    tag.appendChild(text);

    /* Height */
    tag = doc->createElement(KXMLQLCEFXHeight);
    root.appendChild(tag);
    str.setNum(height());
    text = doc->createTextNode(str);
    tag.appendChild(text);

    /* Rotation */
    tag = doc->createElement(KXMLQLCEFXRotation);
    root.appendChild(tag);
    str.setNum(rotation());
    text = doc->createTextNode(str);
    tag.appendChild(text);

    /* StartOffset */
    tag = doc->createElement(KXMLQLCEFXStartOffset);
    root.appendChild(tag);
    str.setNum(startOffset());
    text = doc->createTextNode(str);
    tag.appendChild(text);

    /* IsRelative */
    tag = doc->createElement(KXMLQLCEFXIsRelative);
    root.appendChild(tag);
    str.setNum(isRelative() ? 1 : 0);
    text = doc->createTextNode(str);
    tag.appendChild(text);

    /********************************************
     * X-Axis
     ********************************************/
    tag = doc->createElement(KXMLQLCEFXAxis);
    root.appendChild(tag);
    tag.setAttribute(KXMLQLCFunctionName, KXMLQLCEFXX);

    /* Offset */
    subtag = doc->createElement(KXMLQLCEFXOffset);
    tag.appendChild(subtag);
    str.setNum(xOffset());
    text = doc->createTextNode(str);
    subtag.appendChild(text);

    /* Frequency */
    subtag = doc->createElement(KXMLQLCEFXFrequency);
    tag.appendChild(subtag);
    str.setNum(xFrequency());
    text = doc->createTextNode(str);
    subtag.appendChild(text);

    /* Phase */
    subtag = doc->createElement(KXMLQLCEFXPhase);
    tag.appendChild(subtag);
    str.setNum(xPhase());
    text = doc->createTextNode(str);
    subtag.appendChild(text);

    /********************************************
     * Y-Axis
     ********************************************/
    tag = doc->createElement(KXMLQLCEFXAxis);
    root.appendChild(tag);
    tag.setAttribute(KXMLQLCFunctionName, KXMLQLCEFXY);

    /* Offset */
    subtag = doc->createElement(KXMLQLCEFXOffset);
    tag.appendChild(subtag);
    str.setNum(yOffset());
    text = doc->createTextNode(str);
    subtag.appendChild(text);

    /* Frequency */
    subtag = doc->createElement(KXMLQLCEFXFrequency);
    tag.appendChild(subtag);
    str.setNum(yFrequency());
    text = doc->createTextNode(str);
    subtag.appendChild(text);

    /* Phase */
    subtag = doc->createElement(KXMLQLCEFXPhase);
    tag.appendChild(subtag);
    str.setNum(yPhase());
    text = doc->createTextNode(str);
    subtag.appendChild(text);

    return true;
}
Exemple #14
0
// -----------------------------------------------------------------------------
// Writes the texture list in TEXTUREX format to [texturex], using [patch_table]
// for patch information.
// Returns true on success, false otherwise
// -----------------------------------------------------------------------------
bool TextureXList::writeTEXTUREXData(ArchiveEntry* texturex, const PatchTable& patch_table)
{
	// Check entry was given
	if (!texturex)
		return false;

	if (texturex->isLocked())
		return false;

	Log::info("Writing " + textureXFormatString() + " format TEXTUREx entry");

	/* Total size of a TEXTUREx lump, in bytes:
		Header: 4 + (4 * numtextures)
		Textures:
			22 * numtextures (normal format)
			14 * numtextures (nameless format)
			18 * numtextures (Strife 1.1 format)
		Patches:
			10 * sum of patchcounts (normal and nameless formats)
			 6 * sum of patchcounts (Strife 1.1 format)
	*/
	size_t numpatchrefs = 0;
	size_t numtextures  = textures_.size();
	for (size_t i = 0; i < numtextures; ++i)
	{
		numpatchrefs += textures_[i]->nPatches();
	}
	Log::info("{} patch references in {} textures", numpatchrefs, numtextures);

	size_t datasize   = 0;
	size_t headersize = 4 + (4 * numtextures);
	switch (txformat_)
	{
	case Format::Normal: datasize = 4 + (26 * numtextures) + (10 * numpatchrefs); break;
	case Format::Nameless: datasize = 4 + (18 * numtextures) + (10 * numpatchrefs); break;
	case Format::Strife11:
		datasize = 4 + (22 * numtextures) + (6 * numpatchrefs);
		break;
		// Some compilers insist on having default cases.
	default: return false;
	}

	MemChunk        txdata(datasize);
	vector<int32_t> offsets(numtextures);
	int32_t         foo = wxINT32_SWAP_ON_BE((signed)numtextures);

	// Write header
	txdata.seek(0, SEEK_SET);
	SAFEFUNC(txdata.write(&foo, 4));

	// Go to beginning of texture definitions
	SAFEFUNC(txdata.seek(4 + (numtextures * 4), SEEK_SET));

	// Write texture entries
	for (size_t i = 0; i < numtextures; ++i)
	{
		// Get texture to write
		auto tex = textures_[i].get();

		// Set offset
		offsets[i] = (signed)txdata.currentPos();

		// Write texture entry
		switch (txformat_)
		{
		case Format::Normal:
		{
			// Create 'normal' doom format texture definition
			FullTexDef txdef;
			memset(txdef.name, 0, 8); // Set texture name to all 0's (to ensure compatibility with XWE)
			strncpy(txdef.name, tex->name().data(), tex->name().size());
			for (auto& c : txdef.name)
				c = toupper(c);
			txdef.flags        = 0;
			txdef.scale[0]     = (tex->scaleX() * 8);
			txdef.scale[1]     = (tex->scaleY() * 8);
			txdef.width        = tex->width();
			txdef.height       = tex->height();
			txdef.columndir[0] = 0;
			txdef.columndir[1] = 0;
			txdef.patchcount   = tex->nPatches();

			// Check for WorldPanning flag
			if (tex->world_panning_)
				txdef.flags |= Flags::WorldPanning;

			// Write texture definition
			SAFEFUNC(txdata.write(&txdef, 22));

			break;
		}
		case Format::Nameless:
		{
			// Create nameless texture definition
			NamelessTexDef txdef;
			txdef.flags        = 0;
			txdef.scale[0]     = (tex->scaleX() * 8);
			txdef.scale[1]     = (tex->scaleY() * 8);
			txdef.width        = tex->width();
			txdef.height       = tex->height();
			txdef.columndir[0] = 0;
			txdef.columndir[1] = 0;
			txdef.patchcount   = tex->nPatches();

			// Write texture definition
			SAFEFUNC(txdata.write(&txdef, 8));

			break;
		}
		case Format::Strife11:
		{
			// Create strife format texture definition
			StrifeTexDef txdef;
			memset(txdef.name, 0, 8); // Set texture name to all 0's (to ensure compatibility with XWE)
			strncpy(txdef.name, tex->name().data(), tex->name().size());
			for (auto& c : txdef.name)
				c = toupper(c);
			txdef.flags      = 0;
			txdef.scale[0]   = (tex->scaleX() * 8);
			txdef.scale[1]   = (tex->scaleY() * 8);
			txdef.width      = tex->width();
			txdef.height     = tex->height();
			txdef.patchcount = tex->nPatches();

			// Check for WorldPanning flag
			if (tex->world_panning_)
				txdef.flags |= Flags::WorldPanning;

			// Write texture definition
			SAFEFUNC(txdata.write(&txdef, 18));

			break;
		}
		default: return false;
		}

		// Write patch references
		for (size_t k = 0; k < tex->nPatches(); ++k)
		{
			// Get patch to write
			auto patch = tex->patch(k);

			// Create patch definition
			Patch pdef;
			pdef.left = patch->xOffset();
			pdef.top  = patch->yOffset();

			// Check for 'invalid' patch
			if (StrUtil::startsWith(patch->name(), "INVPATCH"))
			{
				// Get raw patch index from name
				std::string_view number = patch->name();
				number.remove_prefix(8);
				pdef.patch = StrUtil::asInt(number);
			}
			else
				pdef.patch = patch_table.patchIndex(
					patch->name()); // Note this will be -1 if the patch doesn't exist in the patch table. This
									// should never happen with the texture editor, though.

			// Write common data
			SAFEFUNC(txdata.write(&pdef, 6));

			// In non-Strife formats, there's some added rubbish
			if (txformat_ != Format::Strife11)
			{
				foo = 0;
				SAFEFUNC(txdata.write(&foo, 4));
			}
		}
	}

	// Write offsets
	SAFEFUNC(txdata.seek(4, SEEK_SET));
	SAFEFUNC(txdata.write(offsets.data(), 4 * numtextures));

	// Write data to the TEXTUREx entry
	texturex->importMemChunk(txdata);

	// Update entry type
	EntryType::detectEntryType(texturex);

	return true;
}