示例#1
0
文件: TitleView.cpp 项目: GMIS/GMIS
void CTitleView::NcLayout(){
	
	CWSTitleView::NcLayout();
	
	BorderItem* TitleSpace = (BorderItem*)m_NcBorderList[0];
    if(TitleSpace->m_ChildList.size()==0)return;

	IconItem*     Icon = (IconItem*)TitleSpace->m_ChildList[0];
	TextItem*     TextLabel = (TextItem*)TitleSpace->m_ChildList[1];
    CloseboxItem* Closebox  = (CloseboxItem*)TitleSpace->m_ChildList[2];
	
	int32 len = (TitleSpace->AreaHeight()-13)/2;
	
    Closebox->m_AreaTop = TitleSpace->m_AreaTop+len;
	Closebox->m_AreaBottom = TitleSpace->m_AreaBottom-len;
    Closebox->m_AreaRight = TitleSpace->m_AreaRight-len;
	Closebox->m_AreaLeft = Closebox->m_AreaRight-14;
  	
    if (Icon->m_hIcon != NULL)
    {
		Icon->SetArea(TitleSpace);
		Icon->m_AreaRight = TitleSpace->m_AreaLeft+TitleSpace->AreaHeight();
		
		TextLabel->SetArea(TitleSpace);
		TextLabel->m_AreaLeft = Icon->m_AreaRight+2;
		TextLabel->m_AreaRight = Closebox->m_AreaLeft-4;
    } 
    else
    {
		TextLabel->SetArea(TitleSpace);
		TextLabel->m_AreaLeft += 2;
		TextLabel->m_AreaRight = Closebox->m_AreaLeft-4;
    }

}
示例#2
0
AbstractVisualItem * TextBoxContent::syncToModelItem(AbstractVisualItem *model)
{
	DEBUG_TSTART();
	
	TextItem * textModel = dynamic_cast<TextItem*>(AbstractContent::syncToModelItem(model));

	setModelItemIsChanging(true);

	if(!textModel)
	{
		setModelItemIsChanging(false);
                //qDebug("TextBoxContent::syncToModelItem: textModel is null, cannot sync\n");
		return 0;
	}
        //qDebug("TextBoxContent:syncToModelItem: Syncing to model! Yay!");
	//textModel->setText(m_text->toHtml());
	textModel->setFontFamily(m_text->defaultFont().family());
	//textModel->setFontSize(m_text->defaultFont().pointSize());

	setModelItemIsChanging(false);

	//qDebug() << "TextBoxContent::syncToModelItem(): \t \t Elapsed:"<<(((double)total.elapsed())/1000.0)<<" sec";
	
	return model;
}
示例#3
0
void TextBoxConfig::slotOkClicked()
{
	TextItem * textModel = dynamic_cast<TextItem*>(m_textContent->modelItem());
	m_saving = true;
	textModel->setText(m_editor->text(Qt::RichText));
	m_saving = false;
}
示例#4
0
void CelSplashScreen::setPixmap( const QString &filename )
{
    QPixmap _pixmap(filename);
    resize( _pixmap.size() );

    //  Set default values for status and version fields
    status.getRect().setX(20);
    status.getRect().setY(height() - 40);
    status.getRect().setWidth(width() - 200);
    status.getRect().setHeight(20);
    status.setFlags(Qt::AlignLeft | Qt::AlignTop);

    version.getRect().setX(width() - 180);
    version.getRect().setY(height() - 40);
    version.getRect().setWidth(150);
    version.getRect().setHeight(20);
    version.setFlags(Qt::AlignRight | Qt::AlignTop);
    version.setContent(VERSION);

    KFileMetaInfo info(filename);
    KFileMetaInfoGroup comments = info.group("Comment");

    if (comments.isValid()) {
        status.set("status", comments);
        version.set("version", comments);
        int i = 0;
        char extraName[10];
        sprintf(extraName, "extra%02d", i);
        while (i< 100 && comments.item(QString(extraName) + "_insert_before").isValid()) {
            TextItem extra;
            extra.set(extraName, comments);
            extraText.push_back(extra);
            i++;
            sprintf(extraName, "extra%02d", i);
        }
    }

    QRect desk = KGlobalSettings::splashScreenDesktopGeometry();
    setGeometry( ( desk.width() / 2 ) - ( width() / 2 ) + desk.left(),
       ( desk.height() / 2 ) - ( height() / 2 ) + desk.top(),
         width(), height() );
    if (_pixmap.hasAlphaChannel()) {
        QPixmap bg = QPixmap::grabWindow( qt_xrootwin(), x(), y(), width(), height() );
        QPainter painter(&bg);
        painter.drawPixmap(0, 0, _pixmap);
        pixmap = bg;
    } else {
        pixmap = _pixmap;
    }
    
    QPainter painter( &pixmap, this );
    version.draw(&painter);
    for(std::vector<TextItem>::const_iterator i = extraText.begin(); i != extraText.end();  ++i)
        (*i).draw(&painter);

    repaint();
}
示例#5
0
/**
 * Reimplemented from UMLWidget::updateTextItemGroups to update
 * the texts displayed.
 */
void SignalWidget::updateTextItemGroups()
{
    TextItemGroup *grp = textItemGroupAt(GroupIndex);
    grp->setTextItemCount(1); // Only name item

    TextItem *nameItem = grp->textItemAt(0);
    nameItem->setText(name());

    UMLWidget::updateTextItemGroups();
}
示例#6
0
/**
 * Reimplemented from UMLWidget::updateTextItemGroups() to
 * calculate the texts and also show/hide the texts based on current
 * state.
 */
void NodeWidget::updateTextItemGroups()
{
    TextItemGroup *grp = textItemGroupAt(GroupIndex);
    grp->setTextItemCount(NodeWidget::TextItemCount);

    if(umlObject()) {
        UMLNode *node = static_cast<UMLNode*>(umlObject());

        TextItem *stereo = grp->textItemAt(NodeWidget::StereoItemIndex);
        stereo->setText(node->stereotype(true));
        stereo->setBold(true);
        stereo->setExplicitVisibility(!node->stereotype(false).isEmpty());

        TextItem *nameItem = grp->textItemAt(NodeWidget::NameItemIndex);
        QString nameText = name();
        bool underline = false;
        if(isInstance()) {
            nameText.prepend(':');
            nameText.prepend(instanceName());
            underline = true;
        }
        nameItem->setBold(true);
        nameItem->setUnderline(underline);
        nameItem->setText(nameText);
    }

    UMLWidget::updateTextItemGroups();
}
示例#7
0
Plot::Plot( QWidget *parent, const QwtInterval &interval ):
    QwtPlot( parent )
{
    for ( int axis = 0; axis < QwtPlot::axisCnt; axis ++ )
        setAxisScale( axis, interval.minValue(), interval.maxValue() );

    setCanvasBackground( QColor( Qt::darkBlue ) );
    plotLayout()->setAlignCanvasToScales( true );

    // grid
    QwtPlotGrid *grid = new QwtPlotGrid;
    //grid->enableXMin(true);
    grid->setMajorPen( Qt::white, 0, Qt::DotLine );
    grid->setMinorPen( Qt::gray, 0 , Qt::DotLine );
    grid->attach( this );

    const int numEllipses = 10;

    for ( int i = 0; i < numEllipses; i++ )
    {
        const double x = interval.minValue() +
            qrand() % qRound( interval.width() );
        const double y = interval.minValue() +
            qrand() % qRound( interval.width() );
        const double r = interval.minValue() +
            qrand() % qRound( interval.width() / 6 );

        const QRectF area( x - r, y - r , 2 * r, 2 * r );

        RectItem *item = new RectItem( RectItem::Ellipse );
        item->setRenderHint( QwtPlotItem::RenderAntialiased, true );
        item->setRect( area );
        item->setPen( QPen( Qt::yellow ) );
        item->attach( this );
    }

    TextItem *textItem = new TextItem();
    textItem->setText( "Navigation Example" );
    textItem->attach( this );

    d_rectOfInterest = new RectItem( RectItem::Rect );
    d_rectOfInterest->setPen( Qt::NoPen );
    QColor c = Qt::gray;
    c.setAlpha( 100 );
    d_rectOfInterest->setBrush( QBrush( c ) );
    d_rectOfInterest->attach( this );
}
示例#8
0
void SimpleTextContent::syncFromModelItem(AbstractVisualItem *model)
{
        m_dontSyncToModel = true;
	setModelItem(model);
	
	QFont font;
	TextItem * textModel = dynamic_cast<TextItem*>(model);
	
	setText(textModel->text());
	
// 	font.setFamily(textModel->fontFamily());
// 	font.setPointSize((int)textModel->fontSize());
// 	setFont(font);
	
	AbstractContent::syncFromModelItem(model);
	
        m_dontSyncToModel = false;
}
HelpScreen::HelpScreen(void) : Level(LEVEL_MENU, UserInterface()) {
	int windowWidth = GameApp::getInstance()->getWindowWidth();
	int windowHeight = GameApp::getInstance()->getWindowHeight();
	setProjectionMatrix(Matrix4::Perspective(1.0f, -100.0f, 1280.0f / 720.0f, 45.0f));
	setCameraMatrix(Matrix4::Translation(Vector3(0, 0, 0)));
	Texture *bgTexture = Texture::getOrCreate("InstructionsBg", "resources/images/HeXcape Instructions.png");
	ImageItem *background = new ImageItem(Vector2(), 0, Vector2((float) (windowWidth), (float) (windowHeight)), bgTexture);
	userInterface->addItem(background, "BackgroundHelp");
	// Create the menu buttons
	ButtonItem *backButton = new ButtonItem(Vector2(900, 840), 0, Vector2(800, 120), "MenuButton", "resources/images/MenuButton.png", "resources/images/MenuButtonHov.png", "resources/images/MenuButtonPress.png", "resources/images/MenuButtonPress.png");
	// Draw some text over the buttons background
	TextItem *backText = new TextItem(Vector2(1020, 860), 0, "Back To Menu", 72);
	backText->setFont("resources/fonts/Neuropol.ttf");
	actionAfterFade = 0;
	// Set the ambience music
	Music *music = Music::getOrCreate("resources/audio/Doors.mp3", "MenuMusic");

	userInterface->addItem(backButton, "ZBackButton");
	userInterface->addItem(backText, "ZBackText");
}
示例#10
0
AbstractVisualItem * SimpleTextContent::syncToModelItem(AbstractVisualItem *model)
{
	setModelItemIsChanging(true);
	
	TextItem * textModel = dynamic_cast<TextItem*>(AbstractContent::syncToModelItem(model));
	
	if(!textModel)
	{
		setModelItemIsChanging(false);
                //qDebug("SimpleTextContent::syncToModelItem: textModel is null, cannot sync\n");
		return 0;
	}
        //qDebug("TextContent:syncToModelItem: Syncing to model! Yay!");
	textModel->setText(text());
// 	textModel->setFontFamily(font().family());
// 	textModel->setFontSize(font().pointSize());
	
	setModelItemIsChanging(false);
	
	return model;
}
示例#11
0
/**
 * Reimplemented from UMLWidget::updateGeometry to calculate
 * minimum size for this widget.
 */
void NoteWidget::updateGeometry()
{
    TextItemGroup *grp = textItemGroupAt(GroupIndex);
    qreal widthWithoutNote = 0;

    // Ignore if TextItems haven't been properly constructed
    // still. (happens during creation of object)
    if (grp->textItemCount() > NoteTextItemIndex) {
        TextItem *noteTextItem = grp->textItemAt(NoteTextItemIndex);
        noteTextItem->setExplicitVisibility(false);
        widthWithoutNote = grp->minimumSize().width();
        noteTextItem->setExplicitVisibility(true);
    }

    const qreal atleast6Chars = QFontMetricsF(grp->font()).width("w") * 6;
    if (widthWithoutNote > atleast6Chars) {
        grp->setLineBreakWidth(widthWithoutNote);
    }

    setMinimumSize(grp->minimumSize());
    UMLWidget::updateGeometry();
}
示例#12
0
/**
 * Reimplemented from UMLWidget::updateTextItemGroups to update
 * the text of TextItemGroups.
 */
void DatatypeWidget::updateTextItemGroups()
{
    if(umlObject()) {
        TextItemGroup *grp = textItemGroupAt(DatatypeWidget::GroupIndex);
        grp->setTextItemCount(DatatypeWidget::TextItemCount);

        TextItem *stereo = grp->textItemAt(DatatypeWidget::StereoTypeItemIndex);
        stereo->setText(umlObject()->stereotype(true));
        stereo->setBold(true);

        TextItem *nameItem = grp->textItemAt(DatatypeWidget::NameItemIndex);
        nameItem->setText(name());
        nameItem->setItalic(umlObject()->isAbstract());
    }

    UMLWidget::updateTextItemGroups();
}
示例#13
0
/**
 * Reimplemented from UMLWidget::updateTextItemGroups to
 * calculate the Text strings, their properties and also hide/show
 * them based on the current state.
 */
void ClassifierWidget::updateTextItemGroups()
{
    // Invalidate stuff and recalculate them.
    invalidateDummies();

    TextItemGroup *headerGroup = textItemGroupAt(HeaderGroupIndex);
    TextItemGroup *attribOpGroup = textItemGroupAt(AttribOpGroupIndex);
    TextItemGroup *templateGroup = textItemGroupAt(TemplateGroupIndex);

    attribOpGroup->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
    templateGroup->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);

    UMLClassifier *umlC = classifier();
    UMLClassifierListItemList attribList = umlC->getFilteredList(UMLObject::ot_Attribute);
    UMLClassifierListItemList opList = umlC->getFilteredList(UMLObject::ot_Operation);

    // Set up template group and template text items.
    UMLTemplateList tlist = umlC->getTemplateList();
    templateGroup->setTextItemCount(tlist.size());
    bool templateHide = shouldDrawAsCircle(); // Hide if draw as circle.
    for(int i = 0; i < tlist.size(); ++i) {
        UMLTemplate *t = tlist[i];
        templateGroup->textItemAt(i)->setText(t->toString());
        templateGroup->textItemAt(i)->setExplicitVisibility(!templateHide);
    }

    // Stereo type and name.
    const int headerItemCount = 2;
    headerGroup->setTextItemCount(headerItemCount);

    const int cnt = attribList.count() + opList.count();
    attribOpGroup->setTextItemCount(cnt);

    // Setup Stereo text item.
    TextItem *stereoItem = headerGroup->textItemAt(StereotypeItemIndex);
    stereoItem->setBold(true);
    stereoItem->setText(umlC->stereotype(true));

    bool v = !shouldDrawAsCircle()
        && visualProperty(ShowStereotype)
        && !(umlC->stereotype(false).isEmpty());
    stereoItem->setExplicitVisibility(v);

    // name item is always visible.
    TextItem *nameItem = headerGroup->textItemAt(NameItemIndex);
    nameItem->setBold(true);
    nameItem->setItalic(umlC->isAbstract());
    nameItem->setUnderline(shouldDrawAsCircle());
    QString nameText = name();
    if (visualProperty(ShowPackage) == true) {
        nameText = umlC->fullyQualifiedName();
    }

    bool showNameOnly = (!visualProperty(ShowAttributes) && !visualProperty(ShowOperations)
                         && !visualProperty(ShowStereotype) && !shouldDrawAsCircle());
    nameItem->setText(nameText);

    int attribStartIndex = 0;
    int opStartIndex = attribStartIndex + attribList.size();

    // Now setup attribute texts.
    int visibleAttributes = 0;
    for (int i=0; i < attribList.size(); ++i) {
        UMLClassifierListItem *obj = attribList[i];

        TextItem *item = attribOpGroup->textItemAt(attribStartIndex + i);
        item->setItalic(obj->isAbstract());
        item->setUnderline(obj->isStatic());
        item->setText(obj->toString(m_attributeSignature));

        bool v = !shouldDrawAsCircle()
            && ( !visualProperty(ShowPublicOnly)
                 || obj->visibility() == Uml::Visibility::Public)
            && visualProperty(ShowAttributes) == true;

        item->setExplicitVisibility(v);
        if (v) {
            ++visibleAttributes;
        }
    }

    // Update expander box to reflect current state and also visibility
    m_attributeExpanderBox->setExpanded(visualProperty(ShowAttributes));

    const QString dummyText;
    // Setup line and dummies.
    if (!showNameOnly) {
        // Stuff in a dummy item as spacer if there are no attributes,
        if (!shouldDrawAsCircle() && (visibleAttributes == 0 || !visualProperty(ShowAttributes))) {
            m_dummyAttributeItem = new TextItem(dummyText);
            int index = attribStartIndex;
            if (visibleAttributes == 0 && !attribList.isEmpty()) {
                index = opStartIndex;
            }
            attribOpGroup->insertTextItemAt(index, m_dummyAttributeItem);
            m_lineItem2Index = index;
            ++opStartIndex;
        }
        else {
            // Now set the second index.
            m_lineItem2Index = opStartIndex - 1;
        }
    }

    int visibleOperations = 0;
    for (int i=0; i < opList.size(); ++i) {
        UMLClassifierListItem *obj = opList[i];

        TextItem *item = attribOpGroup->textItemAt(opStartIndex + i);
        item->setItalic(obj->isAbstract());
        item->setUnderline(obj->isStatic());
        item->setText(obj->toString(m_operationSignature));

        bool v = !shouldDrawAsCircle()
            && ( !visualProperty(ShowPublicOnly)
                 || obj->visibility() == Uml::Visibility::Public)
            && visualProperty(ShowOperations);

        item->setExplicitVisibility(v);
        if (v) {
            ++visibleOperations;
        }
    }
    m_operationExpanderBox->setExpanded(visualProperty(ShowOperations));

    if (!showNameOnly) {
        if (!shouldDrawAsCircle() && (visibleOperations == 0 || !visualProperty(ShowOperations))) {
            m_dummyOperationItem = new TextItem(dummyText);
            attribOpGroup->insertTextItemAt(opStartIndex+opList.size(), m_dummyOperationItem);
        }
    }

    UMLWidget::updateTextItemGroups();
}
示例#14
0
/**
 * Calculates the classifier box dimensions and the position of text
 * items inside it based on the current size.
 *
 * @note Assumes calculateTemplateDrawing is called before calling
 *       this method.
 */
void ClassifierWidget::calculateClassifierDrawing()
{
    const qreal w = width();
    const qreal h = height();

    TextItemGroup *headerGroup = textItemGroupAt(HeaderGroupIndex);
    TextItemGroup *attribOpGroup = textItemGroupAt(AttribOpGroupIndex);

    if (shouldDrawAsCircle()) {
        // Allocates circle space algined at top and "minimum space"
        // for the text which is aligned bottom.
        qreal fontHeight = headerGroup->minimumSize().height();
        qreal diameter = qMin(w, h - fontHeight);
        m_classifierRect.setRect(0, 0, diameter, diameter);
        m_classifierRect.moveCenter(QPointF(.5 * w, m_classifierRect.center().y()));

        QRectF groupRect(0, diameter, w, h - diameter);
        headerGroup->setGroupGeometry(groupRect);
        // classifierGroup->setGroupGeometry(groupRect);
        m_classifierLines[0] = m_classifierLines[1] = QLineF();
    }
    else {
        // Utilize entire space if template box is empty.
        if (textItemGroupAt(TemplateGroupIndex)->textItemCount() == 0) {
            m_classifierRect = rect();
        }
        else {
            m_classifierRect.setTop(m_templateRect.bottom() - margin());
            m_classifierRect.setLeft(0);
            m_classifierRect.setBottomRight(QPointF(m_templateRect.center().x(), h));
        }

        QRectF headerGeometry(m_classifierRect);
        headerGeometry.setHeight(headerGroup->minimumSize().height());
        headerGroup->setGroupGeometry(headerGeometry);

        QRectF attribOpGeometry(m_classifierRect);
        attribOpGeometry.setTop(headerGeometry.bottom());
        attribOpGroup->setGroupGeometry(attribOpGeometry);

        const int cnt = attribOpGroup->textItemCount();
        qreal expanderDistance = -11;
        bool showNameOnly = (!visualProperty(ShowAttributes) && !visualProperty(ShowOperations)
                && !visualProperty(ShowStereotype) && !shouldDrawAsCircle());
        if (!showNameOnly && !shouldDrawAsCircle()) {
            qreal y = textItemGroupAt(HeaderGroupIndex)->groupGeometry().bottom();
            m_classifierLines[0].setLine(m_classifierRect.left(), y, m_classifierRect.right(), y);
            qreal expanderX = rect().left() -
                m_attributeExpanderBox->rect().width() - expanderDistance;
            m_attributeExpanderBox->setPos(expanderX, y);
        }
        if (cnt > m_lineItem2Index) {
            TextItem *item = attribOpGroup->textItemAt(m_lineItem2Index);
            qreal y = item->mapToParent(item->boundingRect().bottomLeft()).y();
            m_classifierLines[1].setLine(m_classifierRect.left(), y, m_classifierRect.right(), y);
            qreal expanderX = rect().left() -
                m_operationExpanderBox->rect().width() - expanderDistance;
            m_operationExpanderBox->setPos(expanderX, y);
        }
        if (InvalidIndex == m_lineItem2Index) {  // attributes and operations invisible
            QPointF pos = m_attributeExpanderBox->pos();
            m_operationExpanderBox->setPos(pos.x(), pos.y() + 12);
        }
    }
}
示例#15
0
void Draw_v1::printTotText(int16 id) {
	byte *dataPtr;
	byte *ptr, *ptrEnd;
	byte cmd;
	int16 destX, destY;
	int16 val;
	int16 savedFlags;
	int16 destSpriteX;
	int16 spriteRight, spriteBottom;
	char buf[20];

	_vm->_sound->cdPlayMultMusic();

	TextItem *textItem = _vm->_game->_resources->getTextItem(id);
	if (!textItem)
		return;

	dataPtr = textItem->getData();
	ptr     = dataPtr;

	destX = READ_LE_UINT16(ptr) & 0x7FFF;
	destY = READ_LE_UINT16(ptr + 2);
	spriteRight = READ_LE_UINT16(ptr + 4);
	spriteBottom = READ_LE_UINT16(ptr + 6);
	ptr += 8;

	if (_renderFlags & RENDERFLAG_CAPTUREPUSH) {
		_vm->_game->capturePush(destX, destY,
				spriteRight - destX + 1, spriteBottom - destY + 1);
		(*_vm->_scenery->_pCaptureCounter)++;
	}

	_destSpriteX = destX;
	_destSpriteY = destY;
	_spriteRight = spriteRight;
	_spriteBottom = spriteBottom;
	_destSurface = kBackSurface;

	_backColor = *ptr++;
	_transparency = 1;
	spriteOperation(DRAW_CLEARRECT);

	_backColor = 0;
	savedFlags = _renderFlags;
	_renderFlags &= ~RENDERFLAG_NOINVALIDATE;

	while ((_destSpriteX = READ_LE_UINT16(ptr)) != -1) {
		_destSpriteX += destX;
		_destSpriteY = READ_LE_UINT16(ptr + 2) + destY;
		_spriteRight = READ_LE_UINT16(ptr + 4) + destX;
		_spriteBottom = READ_LE_UINT16(ptr + 6) + destY;
		ptr += 8;

		cmd = *ptr++;
		switch ((cmd & 0xF0) >> 4) {
		case 0:
			_frontColor = cmd & 0xF;
			spriteOperation(DRAW_DRAWLINE);
			break;
		case 1:
			_frontColor = cmd & 0xF;
			spriteOperation(DRAW_DRAWBAR);
			break;
		case 2:
			_backColor = cmd & 0xF;
			spriteOperation(DRAW_FILLRECTABS);
			break;
		}
	}
	ptr += 2;

	for (ptrEnd = ptr; *ptrEnd != 1; ptrEnd++) {
		if (*ptrEnd == 3)
			ptrEnd++;

		if (*ptrEnd == 2)
			ptrEnd += 4;
	}
	ptrEnd++;

	while (*ptr != 1) {
		cmd = *ptr;
		if (cmd == 3) {
			ptr++;
			_fontIndex = (*ptr & 0xF0) >> 4;
			_frontColor = *ptr & 0xF;
			ptr++;
			continue;
		} else if (cmd == 2) {
示例#16
0
QString TextBoxContent::toHtml()
{
	TextItem * textModel = dynamic_cast<TextItem*>(modelItem());
	return textModel ? textModel->text() : "";
}
示例#17
0
void ExecutorInterface::sayOrEnqueue(const TextItem& textItem)
{
  const std::string& outputName = textItem.getOutputName();
  if (trim(outputName).empty())
    {
      logMsg(LOG_WARNING, "Received text item to play, but output name is empty, ignoring...");
      return;
    }
  if (!m_outputSet.hasOutput(outputName))
    {
      logMsg(LOG_ERR, "Received text item, but output name is unknown (\'%s\'), ignoring...", outputName.c_str());
      return;
    }
  if (m_pid == 0)//executor is not started;
    {
      logMsg(LOG_DEBUG, "Having text to say, but executor is not running, Launching it...");
      runExecutor();
      if (m_pid == 0)
	{
	  logMsg(LOG_ERR, "Executor launch failed, probably there are problems! Text block will be ignored");
	  return;
	}
    }
  if (m_pipe == 0)
    {
      logMsg(LOG_ERR, "We are sure the executor is running, but pipe to it is not valid, stopping executor and waiting next text block.");
      stopExecutor();
      return;
    }
  const std::string synthCommand = m_outputSet.prepareSynthCommand(outputName, textItem);
  const std::string playerCommand = m_outputSet.preparePlayerCommand(outputName, m_playerType, textItem);
  const std::string text = m_outputSet.prepareText(outputName, textItem);
  if (trim(synthCommand).empty())
    {
      logMsg(LOG_WARNING, "Prepared synth command to be sent to executor is empty");
      return;
    }
  if (trim(playerCommand).empty())
    {
      logMsg(LOG_WARNING, "Prepared player command to be sent to executor is empty");
      return;
    }
  logMsg(LOG_DEBUG, "Text and command line prepared to be sent to executor:");
  logMsg(LOG_DEBUG, "Synth command line: %s;", synthCommand.c_str());
  logMsg(LOG_DEBUG, "Player command line: %s;", playerCommand.c_str());
  logMsg(LOG_DEBUG, "Text: %s.", text.c_str());
  CommandHeader header;
  header.code = COMMAND_SAY;
  header.param1 = synthCommand.length() + 1;//+1 to reflect ending zero;
  header.param2 = playerCommand.length() + 1;//+1 to reflect ending zero;
  header.param3 = text.length() + 1;//+1 to reflect ending zero;
  if (!sendBlockToExecutor(&header, sizeof(CommandHeader), "\'SAY\' command header"))
    return;
  if (!sendBlockToExecutor(synthCommand.c_str(), synthCommand.length() + 1, "synth command"))
    return;
  if (!sendBlockToExecutor(playerCommand.c_str(), playerCommand.length() + 1, "player command"))
    return;
  if (!sendBlockToExecutor(text.c_str(), text.length() + 1, "text"))
    return;
  logMsg(LOG_DEBUG, "Command was successfully sent to executor!");
}
示例#18
0
/**
 * Reimplemented from UMLWidget::updateTextItemGroups to update
 * texts and their properties.
 */
void NoteWidget::updateTextItemGroups()
{
    TextItemGroup *grp = textItemGroupAt(GroupIndex);
    grp->setTextItemCount(TextItemCount);

    TextItem *diagramLinkItem = grp->textItemAt(DiagramLinkItemIndex);
    diagramLinkItem->setExplicitVisibility(false);
    //FIXME: Fixe diagram link drawing

    TextItem *noteTypeItem = grp->textItemAt(NoteTypeItemIndex);
    if (m_noteType == NoteWidget::PreCondition) {
        noteTypeItem->setText(i18n("<< precondition >>"));
        noteTypeItem->setExplicitVisibility(true);
    }
    else if (m_noteType == NoteWidget::PostCondition) {
        noteTypeItem->setText(i18n("<< postcondition >>"));
        noteTypeItem->setExplicitVisibility(true);
    }
    else if (m_noteType == NoteWidget::Transformation) {
        noteTypeItem->setText(i18n("<< transformation >>"));
        noteTypeItem->setExplicitVisibility(true);
    }
    else { // = NoteWidget::Normal
        noteTypeItem->setExplicitVisibility(false);
    }

    TextItem *noteTextItem = grp->textItemAt(NoteTextItemIndex);
    noteTextItem->setText(documentation());

    UMLWidget::updateTextItemGroups();
}
示例#19
0
void TextBoxContent::syncFromModelItem(AbstractVisualItem *model)
{
        DEBUG_TSTART();
	m_dontSyncToModel = true;
	if(!modelItem())
	{
		setModelItem(model);
		
		// Start out the last remembered model rev at the rev of the model
		// so we dont force a redraw of the cache just because we're a fresh
		// object.
		if(QPixmapCache::find(cacheKey()))
			m_lastModelRev = modelItem()->revision();
	}

	static int x = 0;
	x++;
	//qDebug() << x<<": TextBoxContent::syncFromModelItem() mark";
	QFont font;
	TextItem * textModel = dynamic_cast<TextItem*>(model);

	font.setFamily(textModel->fontFamily());
	font.setPointSize((int)textModel->fontSize());
	m_text->setDefaultFont(font);
	
	

	if (!Qt::mightBeRichText(textModel->text()))
	{
		qDebug() << "TextBoxContent:: converting plain text from model item to html";
		m_text->setPlainText(textModel->text());
		textModel->setText(m_text->toHtml());
	}
	
	//qDebug() << "TextBoxContent:: Original HTML:"<<textModel->text();
	setHtml(textModel->text());
	//qDebug() << "TextBoxContent::      New HTML:"<<m_text->toHtml();
	

	AbstractContent::syncFromModelItem(model);
	
	if(modelItem()->revision() != m_lastModelRev)
	{
		//qDebug()<<"modelItem():"<<modelItem()->itemName()<<": last revision:"<<m_lastModelRev<<", this revision:"<<m_lastModelRev<<", cache dirty!";
		
		m_lastModelRev = modelItem()->revision();
		
		// DONT dirty cache here since we changed the cacheKey algorithm - cache key is now based on visual description, not on item identity
		//dirtyCache();
	}
	
	if(   model->zoomEffectEnabled() 
 	   && model->zoomSpeed() > 0 
 	   && sceneContextHint() == MyGraphicsScene::Live)
	{
		m_zoomEnabled = true;
		
		m_zoomAnimationTimer->start(1000 / 20); // / model->zoomSpeed());
		
		QSize size = contentsRect().size();
			
		double width  = size.width();
		double height = size.height();
		
		double aspectRatio = height == 0 ? 1 : width/height;
			
// 		if(!m_zoomInit)
// 		{
			//qDebug() << "aspectRatio: "<<aspectRatio;
			
			QPointF delta;
			
			m_zoomStartSize.setX(width);
			m_zoomStartSize.setY(height);
			 
			m_zoomEndSize.setX(width  * model->zoomFactor());
			m_zoomEndSize.setY(height * model->zoomFactor());
			
			bool zoomIn = true;
			if(model->zoomDirection() == AbstractVisualItem::ZoomIn)
				zoomIn = true;
			else
			if(model->zoomDirection() == AbstractVisualItem::ZoomOut)
				zoomIn = false;
			else
			if(model->zoomDirection() == AbstractVisualItem::ZoomRandom)
				zoomIn = qrand() < RAND_MAX/2;
			
			m_zoomCurSize = zoomIn ? m_zoomStartSize : m_zoomEndSize;
			m_zoomDir     = zoomIn ? 1 : -1;
			
			delta.setX(m_zoomEndSize.x() - m_zoomCurSize.x());
			delta.setY(m_zoomEndSize.y() - m_zoomCurSize.y());
			//step.setX(delta.x()/ZOOM_STEPS);
			//step.setY(delta.y()/ZOOM_STEPS);
// 			m_zoomInit = true;
// 		}
		
		// allow it to go below 1.0 for step size by using 75.0 when the max of the zoomSpeed slider in config is 100
		m_zoomStep.setX(8.0 / (100.01 - ((double)model->zoomSpeed())) * aspectRatio);
		m_zoomStep.setY(8.0 / (100.01 - ((double)model->zoomSpeed())));
		
		
		if(model->zoomAnchorPoint() == AbstractVisualItem::ZoomAnchorRandom)
		{
			// pick a third intersection
			double x = qrand() < RAND_MAX/2 ? .33 : .66;
			double y = qrand() < RAND_MAX/2 ? .33 : .66;
			
			// apply a fudge factor
// 			x += 0.15 - ((double)qrand()) / ((double)RAND_MAX) * 0.075;
// 			y += 0.15 - ((double)qrand()) / ((double)RAND_MAX) * 0.075;
			
			m_zoomDestPoint = QPointF(x,y);
			//qDebug() << "ZoomRandom:	"<<x<<","<<y;
			
			//qDebug() << model->itemName() << "Random zoom anchor: "<<m_zoomDestPoint;
		}
		else
		{
			double x = .0, y = .0;
			switch(model->zoomAnchorPoint())
			{
				case AbstractVisualItem::ZoomTopLeft:		x = .33; y = .33; break;
				case AbstractVisualItem::ZoomTopMid:		x = .50; y = .25; break;
				case AbstractVisualItem::ZoomTopRight:		x = .66; y = .33; break;
				case AbstractVisualItem::ZoomRightMid:		x = .75; y = .50; break;
				case AbstractVisualItem::ZoomBottomRight:	x = .66; y = .66; break;
				case AbstractVisualItem::ZoomBottomMid:		x = .50; y = .75; break;
				case AbstractVisualItem::ZoomBottomLeft:	x = .33; y = .66; break;
				case AbstractVisualItem::ZoomLeftMid:		x = .25; y = .50; break;
				case AbstractVisualItem::ZoomCenter:
				default:					x = .50; y = .50; break;
			};
			
			m_zoomDestPoint = QPointF(x,y);
		}

	}
	else
	{
		m_zoomEnabled = false;
		if(m_zoomAnimationTimer->isActive())
			m_zoomAnimationTimer->stop();
	}

        m_dontSyncToModel = false;
}