当前位置: 首页>>代码示例>>C++>>正文


C++ PageItem类代码示例

本文整理汇总了C++中PageItem的典型用法代码示例。如果您正苦于以下问题:C++ PageItem类的具体用法?C++ PageItem怎么用?C++ PageItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了PageItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: result

Selection Serializer::importCollection()
{
	Collection* coll = lookup<Collection>("<collection>");
	Selection result( &m_Doc, false);
//	qDebug() << QString("deserialize: collection %1 doc %2").arg((ulong)coll).arg((ulong)&m_Doc);
	if (coll == NULL)
		qDebug() << "deserialize: no objects collected";
	else
	{
		QMap<QString,QString> newNames;

		//TODO: fonts

		do {
			newNames.clear();
			for (int i = 0; i < coll->cstyles.count(); ++i)
			{
				QString oldName = coll->cstyles[i].name();
				int oldIndex = m_Doc.charStyles().find(oldName);
				if (oldIndex >= 0 && m_Doc.charStyle(oldName) == coll->cstyles[i])
					continue;
				QString newName = oldName;
				if (oldIndex >= 0 && !newNames.contains(oldName))
				{
					int counter = 0;
					while (m_Doc.charStyles().find(newName) >= 0)
						newName = (QObject::tr("Copy of %1 (%2)")).arg(oldName).arg(++counter);
					newNames[oldName] = newName;
				}
			}
			
			coll->cstyles.rename(newNames);
		}
		while (newNames.count() > 0);
		m_Doc.redefineCharStyles(coll->cstyles, false);		

		do {
			newNames.clear();
			for (int i = 0; i < coll->pstyles.count(); ++i)  // FIXME:  QValueList<QString> StyleSet::names()
			{
				QString oldName = coll->pstyles[i].name();
				int oldIndex = m_Doc.paragraphStyles().find(oldName);
//				qDebug() << QString("comparing %1 (old %2 new %3): parent '%4'='%5' cstyle %6 equiv %7").arg(oldName).arg(oldIndex).arg(i)
//					   .arg(oldIndex>=0? m_Doc.paragraphStyle(oldName).parent() : "?").arg(coll->pstyles[i].parent())
//					   .arg(oldIndex>=0? m_Doc.paragraphStyle(oldName).charStyle() == coll->pstyles[i].charStyle() : false)
//					   .arg(oldIndex>=0? m_Doc.paragraphStyle(oldName).equiv(coll->pstyles[i]) : false);
			
				if (oldIndex >= 0 && coll->pstyles[i] == m_Doc.paragraphStyle(oldName) )
					continue;
				QString newName = oldName;
				if (oldIndex >= 0 && !newNames.contains(oldName))
				{
					int counter = 0;
					while (m_Doc.paragraphStyles().find(newName) >= 0)
						newName = (QObject::tr("Copy of %1 (%2)")).arg(oldName).arg(++counter);
					newNames[oldName] = newName;
				}
			}
			coll->pstyles.rename(newNames);
		}
		while(newNames.count() > 0);
		
		m_Doc.redefineStyles(coll->pstyles, false);		

		//TODO: linestyles : this is temporary code until MultiLine is replaced by LineStyle
		QMap<QString,multiLine>::Iterator mlit;
		for (mlit = coll->lstyles.begin(); mlit != coll->lstyles.end(); ++mlit)
		{
			multiLine& ml = mlit.value();
			QString    oldName = mlit.key();
			QString    newName = mlit.key();
			QMap<QString,multiLine>::ConstIterator mlitd = m_Doc.MLineStyles.find(oldName);
			if (mlitd != m_Doc.MLineStyles.end() && ml != mlitd.value())
			{
				int counter = 0;
				while (m_Doc.MLineStyles.contains(newName))
					newName = (QObject::tr("Copy of %1 (%2)")).arg(oldName).arg(++counter);
			}
			m_Doc.MLineStyles.insert(newName, ml);
		}

		//TODO: patterns
		
		QList<PageItem*>* objects = &(coll->items);
		m_Doc.PageColors = backUpColors;
		m_Doc.PageColors.addColors(coll->colors, false);
		int maxG = m_Doc.GroupCounter;
		for (int i=0; i < objects->count(); ++i)
		{
			PageItem* currItem = objects->at(i);
			currItem->Clip = FlattenPath(currItem->PoLine, currItem->Segments);
			currItem->setFillQColor();
			currItem->setLineQColor();
			result.addItem(currItem);
			if (currItem->Groups.count() != 0)
			{
				QStack<int> groups;
				for (int i=0; i < currItem->groups().count(); ++i)
				{
					int newGroup = m_Doc.GroupCounter + currItem->groups()[i] - 1;
//.........这里部分代码省略.........
开发者ID:moceap,项目名称:scribus,代码行数:101,代码来源:serializer.cpp

示例2: write

void gtAction::write(const QString& text, gtStyle *style)
{
	if (isFirstWrite)
	{
		if (!doAppend)
		{
			if (it->nextInChain() != 0)
			{
				PageItem *nextItem = it->nextInChain();
				while (nextItem != 0)
				{
					nextItem->itemText.clear();
					nextItem = nextItem->nextInChain();
				}
			}
			it->itemText.clear();
		}
	}
	int paragraphStyle = -1;
	if (style->target() == "paragraph")
	{
		gtParagraphStyle* pstyle = dynamic_cast<gtParagraphStyle*>(style);
		assert(pstyle != NULL);
		paragraphStyle = applyParagraphStyle(pstyle);
		if (isFirstWrite)
			inPara = true;
	}
	else if (style->target() == "frame")
	{
		gtFrameStyle* fstyle = dynamic_cast<gtFrameStyle*>(style);
		assert(fstyle != NULL);
		applyFrameStyle(fstyle);
	}

	if ((inPara) && (!lastCharWasLineChange) && (text.left(1) != "\n") && (lastParagraphStyle != -1))
		paragraphStyle = lastParagraphStyle;

	if (paragraphStyle == -1)
		paragraphStyle = 0; //::findParagraphStyle(textFrame->doc(), textFrame->doc()->currentStyle);

	const ParagraphStyle& paraStyle = textFrame->doc()->paragraphStyles()[paragraphStyle];

	gtFont* font = style->getFont();
	QString fontName = validateFont(font).scName();
	CharStyle lastStyle, newStyle;
	int lastStyleStart = 0;
	
	if ((inPara) && (!overridePStyleFont))
	{
		if (paraStyle.charStyle().font().isNone())
		{
			gtFont font2(*font);
			font2.setName(paraStyle.charStyle().font().scName());
			QString fontName2 = validateFont(&font2).scName();
			newStyle.setFont((*textFrame->doc()->AllFonts)[fontName2]);
		}
	}
	else
	{
		setCharStyleAttributes(font, newStyle);
	}
	/*newStyle.eraseCharStyle(paraStyle.charStyle());*/

	lastStyle = newStyle;
	lastStyleStart = it->itemText.length();

	QChar ch0(0), ch5(5), ch10(10), ch13(13);
	for (int a = 0; a < text.length(); ++a)
	{
		if ((text.at(a) == ch0) || (text.at(a) == ch13))
			continue;
		QChar ch = text.at(a);
		if ((ch == ch10) || (ch == ch5))
			ch = ch13;
		else if (ch.unicode() == 0x2028)
			ch = SpecialChars::LINEBREAK;
		else if (ch.unicode() == 0x2029)
			ch = SpecialChars::PARSEP;
		
		int pos = it->itemText.length();
		it->itemText.insertChars(pos, QString(ch));
		if (ch == SpecialChars::PARSEP) 
		{
			if (paraStyle.hasName())
			{
				ParagraphStyle pstyle;
				pstyle.setParent(paraStyle.name());
				it->itemText.applyStyle(pos, pstyle);
			}
			else
				it->itemText.applyStyle(pos, paraStyle);
		}
	}
	it->itemText.applyCharStyle(lastStyleStart, it->itemText.length()-lastStyleStart, lastStyle);
	if (paraStyle.hasName())
	{
		ParagraphStyle pStyle;
		pStyle.setParent(paraStyle.name());
		it->itemText.applyStyle(qMax(0,it->itemText.length()-1), pStyle);
	}
//.........这里部分代码省略.........
开发者ID:OpenDTP,项目名称:ScribusServer,代码行数:101,代码来源:gtaction.cpp

示例3: mouseReleaseEvent

void CalligraphicMode::mouseReleaseEvent(QMouseEvent *m)
{
	undoManager->setUndoEnabled(true);
	PageItem *currItem;
	m_MouseButtonPressed = false;
	m_canvas->resetRenderMode();
	m->accept();
	
	if (m_doc->appMode == modeDrawCalligraphicLine)
	{
		if (RecordP.size() > 1)
		{
			UndoTransaction createTransaction;
			if (UndoManager::undoEnabled())
				createTransaction = UndoManager::instance()->beginTransaction();
			uint z = m_doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, Mxp, Myp, 1, 1, m_doc->itemToolPrefs().calligraphicPenLineWidth, m_doc->itemToolPrefs().calligraphicPenFillColor, m_doc->itemToolPrefs().calligraphicPenLineColor);
			currItem = m_doc->Items->at(z);
			currItem->PoLine.resize(0);
			QList<QPointF> clipU;
			QList<QPointF> clipL;
			double mx = sin(m_doc->itemToolPrefs().calligraphicPenAngle / 180.0 * M_PI) * (m_doc->itemToolPrefs().calligraphicPenWidth / 2.0);
			double my = cos(m_doc->itemToolPrefs().calligraphicPenAngle / 180.0 * M_PI) * (m_doc->itemToolPrefs().calligraphicPenWidth / 2.0);
			for (int px = 0; px < RecordP.size()-1; ++px)
			{
				FPoint clp = RecordP.point(px);
				clipU.append(QPointF(clp.x() - mx, clp.y() - my));
				clipL.prepend(QPointF(clp.x() + mx, clp.y() + my));
			}
			QPainterPath ppU = bezierFit(clipU, 5.0);
			QPainterPath ppL = bezierFit(clipL, 5.0);
			QPainterPath pp;
			pp.addPath(ppU);
			pp.connectPath(ppL);
			pp.closeSubpath();
			currItem->PoLine.fromQPainterPath(pp);
			FPoint tp2(getMinClipF(&currItem->PoLine));
			currItem->setXYPos(tp2.x(), tp2.y(), true);
			currItem->PoLine.translate(-tp2.x(), -tp2.y());
			FPoint tp(getMaxClipF(&currItem->PoLine));
			m_doc->sizeItem(tp.x(), tp.y(), currItem, false, false, false);
			m_doc->adjustItemSize(currItem);
			m_doc->m_Selection->clear();
			m_doc->m_Selection->addItem(currItem);
			currItem->ClipEdited = true;
			currItem->FrameType = 3;
			currItem->OwnPage = m_doc->OnPage(currItem);
			currItem->PLineArt = Qt::PenStyle(m_doc->itemToolPrefs().calligraphicPenStyle);
			currItem->setFillShade(m_doc->itemToolPrefs().calligraphicPenFillColorShade);
			currItem->setLineShade(m_doc->itemToolPrefs().calligraphicPenLineColorShade);
			currItem->setFillEvenOdd(true);
			m_view->resetMousePressed();
			currItem->checkChanges();
			QString targetName = Um::ScratchSpace;
			if (currItem->OwnPage > -1)
				targetName = m_doc->Pages->at(currItem->OwnPage)->getUName();
			if (createTransaction)
				createTransaction.commit(targetName, currItem->getUPixmap(), Um::Create + " " + currItem->getUName(),  "", Um::ICreate);
			//FIXME	
			m_canvas->m_viewMode.operItemResizing = false;
			m_doc->changed();
		}
		if (!PrefsManager::instance()->appPrefs.uiPrefs.stickyTools)
		{
			m_view->requestMode(modeNormal);
		}
		else
			m_view->requestMode(m_doc->appMode);
		return;
	}

	m_canvas->setRenderModeUseBuffer(false);
	
	m_doc->DragP = false;
	m_doc->leaveDrag = false;
	m_view->MidButt = false;
	if (m_view->groupTransactionStarted())
	{
		for (int i = 0; i < m_doc->m_Selection->count(); ++i)
			m_doc->m_Selection->itemAt(i)->checkChanges(true);
		m_view->endGroupTransaction();
	}

	for (int i = 0; i < m_doc->m_Selection->count(); ++i)
		m_doc->m_Selection->itemAt(i)->checkChanges(true);

	//Commit drag created items to undo manager.
	if (m_doc->m_Selection->itemAt(0)!=NULL)
	{
		m_doc->itemAddCommit(m_doc->m_Selection->itemAt(0));
	}
	//Make sure the Zoom spinbox and page selector don't have focus if we click on the canvas
	m_view->m_ScMW->zoomSpinBox->clearFocus();
	m_view->m_ScMW->pageSelector->clearFocus();
	if (m_doc->m_Selection->itemAt(0) != 0) // is there the old clip stored for the undo action
	{
		currItem = m_doc->m_Selection->itemAt(0);
		m_doc->nodeEdit.finishTransaction(currItem);
	}
}
开发者ID:Fahad-Alsaidi,项目名称:scribus-svn,代码行数:99,代码来源:canvasmode_drawcalligraphic.cpp

示例4: run

bool SubdividePlugin::run(ScribusDoc* doc, QString)
{
	ScribusDoc* currDoc = doc;
	if (currDoc == 0)
		currDoc = ScCore->primaryMainWindow()->doc;
	double nearT = 0.5;
	uint docSelectionCount = currDoc->m_Selection->count();
	if (docSelectionCount != 0)
	{
		for (uint aa = 0; aa < docSelectionCount; ++aa)
		{
			FPointArray points;
			PageItem *currItem = currDoc->m_Selection->itemAt(aa);
			if (currDoc->nodeEdit.isContourLine)
			{
				uint psize = currItem->ContourLine.size();
				for (uint a = 0; a < psize-3; a += 4)
				{
					if (currItem->ContourLine.point(a).x() > 900000)
					{
						points.setMarker();
						continue;
					}
					FPoint base = currItem->ContourLine.point(a);
					FPoint c1 = currItem->ContourLine.point(a+1);
					FPoint base2 =  currItem->ContourLine.point(a+2);
					FPoint c2 = currItem->ContourLine.point(a+3);
					FPoint cn1 = (1.0 - nearT) * base + nearT * c1;
					FPoint cn2 = (1.0 - nearT) * cn1 + nearT * ((1.0 - nearT) * c1 + nearT * c2);
					FPoint cn3 = (1.0 - nearT) * ((1.0 - nearT) * c1 + nearT * c2) + nearT * ((1.0 - nearT) * c2 + nearT * base2);
					FPoint cn4 = (1.0 - nearT) * c2 + nearT * base2;
					FPoint bp1 = (1.0 - nearT) * cn2 + nearT * cn3;
					if ((base == c1) && (base2 == c2))
					{
						points.addPoint(base);
						points.addPoint(c1);
						points.addPoint(bp1);
						points.addPoint(bp1);
						points.addPoint(bp1);
						points.addPoint(bp1);
						points.addPoint(base2);
						points.addPoint(c2);
					}
					else
					{
						points.addPoint(base);
						points.addPoint(cn1);
						points.addPoint(bp1);
						points.addPoint(cn2);
						points.addPoint(bp1);
						points.addPoint(cn3);
						points.addPoint(base2);
						points.addPoint(cn4);
					}
				}
				currItem->ContourLine = points;
			}
			else
			{
				uint psize = currItem->PoLine.size();
				for (uint a = 0; a < psize-3; a += 4)
				{
					if (currItem->PoLine.point(a).x() > 900000)
					{
						points.setMarker();
						continue;
					}
					FPoint base = currItem->PoLine.point(a);
					FPoint c1 = currItem->PoLine.point(a+1);
					FPoint base2 =  currItem->PoLine.point(a+2);
					FPoint c2 = currItem->PoLine.point(a+3);
					FPoint cn1 = (1.0 - nearT) * base + nearT * c1;
					FPoint cn2 = (1.0 - nearT) * cn1 + nearT * ((1.0 - nearT) * c1 + nearT * c2);
					FPoint cn3 = (1.0 - nearT) * ((1.0 - nearT) * c1 + nearT * c2) + nearT * ((1.0 - nearT) * c2 + nearT * base2);
					FPoint cn4 = (1.0 - nearT) * c2 + nearT * base2;
					FPoint bp1 = (1.0 - nearT) * cn2 + nearT * cn3;
					if ((base == c1) && (base2 == c2))
					{
						points.addPoint(base);
						points.addPoint(c1);
						points.addPoint(bp1);
						points.addPoint(bp1);
						points.addPoint(bp1);
						points.addPoint(bp1);
						points.addPoint(base2);
						points.addPoint(c2);
					}
					else
					{
						points.addPoint(base);
						points.addPoint(cn1);
						points.addPoint(bp1);
						points.addPoint(cn2);
						points.addPoint(bp1);
						points.addPoint(cn3);
						points.addPoint(base2);
						points.addPoint(cn4);
					}
				}
				currItem->PoLine = points;
//.........这里部分代码省略.........
开发者ID:piksels-and-lines-orchestra,项目名称:scribus,代码行数:101,代码来源:subdivide.cpp

示例5: UndoTransaction

bool PathFinderPlugin::run(ScribusDoc* doc, QString)
{
	ScribusDoc* currDoc = doc;
	if (currDoc == 0)
		currDoc = ScCore->primaryMainWindow()->doc;
	if (currDoc->m_Selection->count() <= 1)
		return true;
	
	//<<#9046
	UndoTransaction* activeTransaction = NULL;
	UndoManager* undoManager = UndoManager::instance();
	if (UndoManager::undoEnabled())
		activeTransaction = new UndoTransaction(undoManager->beginTransaction(Um::SelectionGroup, Um::IDocument, Um::PathOperation, "", Um::IPolygon));
	//>>#9046
	
	PageItem *Item1 = currDoc->m_Selection->itemAt(0);
	PageItem *Item2 = currDoc->m_Selection->itemAt(1);
	PathFinderDialog *dia = new PathFinderDialog(currDoc->scMW(), currDoc, Item1, Item2);
	if (dia->exec())
	{
		int opMode=dia->opMode;
		if (dia->keepItem1)
		{
			PageItem *newItem;
			if (dia->swapped)
			{
				newItem = new PageItem_Polygon(*Item2);
				newItem->setSelected(false);
				currDoc->Items->insert(currDoc->Items->indexOf(Item2), newItem);
			}
			else
			{
				newItem = new PageItem_Polygon(*Item1);
				newItem->setSelected(false);
				currDoc->Items->insert(currDoc->Items->indexOf(Item1), newItem);
			}
			if (UndoManager::undoEnabled())
			{
				ScItemState<PageItem*> *is = new ScItemState<PageItem*>("Create PageItem");
				is->set("CREATE_ITEM", "create_item");
				is->setItem(newItem);
				UndoObject *target = currDoc->Pages->at(Item1->OwnPage);
				undoManager->action(target, is);
			}
		}
		if (dia->keepItem2)
		{
			PageItem *newItem;
			if (dia->swapped)
			{
				newItem = new PageItem_Polygon(*Item1);
				newItem->setSelected(false);
				currDoc->Items->insert(currDoc->Items->indexOf(Item1), newItem);
			}
			else
			{
				newItem = new PageItem_Polygon(*Item2);
				newItem->setSelected(false);
				currDoc->Items->insert(currDoc->Items->indexOf(Item2), newItem);
			}
			if (UndoManager::undoEnabled())
			{
				ScItemState<PageItem*> *is = new ScItemState<PageItem*>("Create PageItem");
				is->set("CREATE_ITEM", "create_item");
				is->setItem(newItem);
				UndoObject *target = currDoc->Pages->at(Item1->OwnPage);
				undoManager->action(target, is);
			}
		}
		if (opMode != 4)
		{
			PageItem *currItem;
			QPainterPath path;
			FPointArray points;
			if (dia->targetColor == 0)
			{
				currItem = Item1;
				if (dia->swapped)
				{
					currItem = Item2;
					currItem->setXYPos(Item1->xPos(), Item1->yPos());
					currItem->setRotation(0.0);
				}
			}
			else
			{
				if (dia->swapped)
					currItem = Item1;
				else
				{
					currItem = Item2;
					currItem->setXYPos(Item1->xPos(), Item1->yPos());
					currItem->setRotation(0.0);
				}
			}
			path = dia->result;
			points.fromQPainterPath(path);
			
			//<<#9046
			FPointArray oldPOLine=currItem->PoLine;
//.........这里部分代码省略.........
开发者ID:piksels-and-lines-orchestra,项目名称:scribus,代码行数:101,代码来源:pathfinder.cpp

示例6: WordAndPara

void WordAndPara(PageItem* currItem, int *w, int *p, int *c, int *wN, int *pN, int *cN)
{
    QChar Dat = QChar(32);
    int para = 0;
    int ww = 0;
    int cc = 0;
    int paraN = 0;
    int wwN = 0;
    int ccN = 0;
    bool first = true;
    PageItem *nextItem = currItem;
    PageItem *nbl = currItem;
    while (nextItem != 0)
    {
        if (nextItem->prevInChain() != 0)
            nextItem = nextItem->prevInChain();
        else
            break;
    }
    while (nextItem != 0)
    {
        for (int a = qMax(nextItem->firstInFrame(),0); a <= nextItem->lastInFrame() && a < nextItem->itemText.length(); ++a)
        {
            QChar b = nextItem->itemText.text(a);
            if (b == SpecialChars::PARSEP)
            {
                para++;
            }
            if ((!b.isLetterOrNumber()) && (Dat.isLetterOrNumber()) && (!first))
            {
                ww++;
            }
            cc++;
            Dat = b;
            first = false;
        }
        nbl = nextItem;
        nextItem = nextItem->nextInChain();
    }
    if (nbl->frameOverflows()) {
        paraN++;
        for (int a = nbl->lastInFrame()+1; a < nbl->itemText.length(); ++a)
        {
            QChar b = nbl->itemText.text(a);
            if (b == SpecialChars::PARSEP)
            {
                paraN++;
            }
            if ((!b.isLetterOrNumber()) && (Dat.isLetterOrNumber()) && (!first))
            {
                wwN++;
            }
            ccN++;
            Dat = b;
            first = false;
        }
    }
    else {
        para++;
    }
    if (Dat.isLetterOrNumber())
    {
        if (nbl->frameOverflows())
            wwN++;
        else
            ww++;
    }
    *w = ww;
    *p = para;
    *c = cc;
    *wN = wwN;
    *pN = paraN;
    *cN = ccN;
}
开发者ID:hasenj,项目名称:scribus,代码行数:74,代码来源:util.cpp

示例7: mousePressEvent

void CanvasMode_EditMeshGradient::mousePressEvent(QMouseEvent *m)
{
    const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPos());

    m_canvas->PaintSizeRect(QRect());
    m_canvas->m_viewMode.m_MouseButtonPressed = true;
    m_canvas->m_viewMode.operItemMoving = false;
    m_view->HaveSelRect = false;
    m_doc->DragP = false;
    m_doc->leaveDrag = false;
    m->accept();
    m_view->registerMousePress(m->globalPos());
    m_Mxp = mousePointDoc.x(); //m->x();
    m_Myp = mousePointDoc.y(); //m->y();
    if (m->button() == Qt::MidButton)
    {
        m_view->MidButt = true;
        if (m->modifiers() & Qt::ControlModifier)
            m_view->DrawNew();
        return;
    }
    PageItem *currItem = m_doc->m_Selection->itemAt(0);
    QTransform itemMatrix = currItem->getTransform();
    bool found = false;
    QPair<int, int> selPoint;
    if (m_view->editStrokeGradient == 5)
    {
        m_gradientPoint = noPointDefined;
        for (int grow = 0; grow < currItem->meshGradientArray.count(); grow++)
        {
            for (int gcol = 0; gcol < currItem->meshGradientArray[grow].count(); gcol++)
            {
                meshPoint mp = currItem->meshGradientArray[grow][gcol];
                QPointF gradientPoint = QPointF(mp.gridPoint.x(), mp.gridPoint.y());
                gradientPoint = itemMatrix.map(gradientPoint);
                if (m_canvas->hitsCanvasPoint(mousePointDoc, gradientPoint))
                {
                    selPoint.first = grow;
                    selPoint.second = gcol;
                    found = true;
                    *m_old_mesh = mp;
                    break;
                }
            }
            if (found)
                break;
        }
    }
    else if (m_view->editStrokeGradient == 6)
    {
        m_gradientPoint = noPointDefined;
        m_selectedMeshPoints.clear();
        for (int grow = 0; grow < currItem->meshGradientArray.count(); grow++)
        {
            for (int gcol = 0; gcol < currItem->meshGradientArray[grow].count(); gcol++)
            {
                meshPoint mp = currItem->meshGradientArray[grow][gcol];
                QPointF gradientPoint = QPointF(mp.gridPoint.x(), mp.gridPoint.y());
                gradientPoint = itemMatrix.map(gradientPoint);
                QPointF gradientColorPoint = QPointF(mp.controlColor.x(), mp.controlColor.y());
                gradientColorPoint = itemMatrix.map(gradientColorPoint);
                if (m_canvas->hitsCanvasPoint(mousePointDoc, gradientPoint) || m_canvas->hitsCanvasPoint(mousePointDoc, gradientColorPoint))
                {
                    selPoint.first = grow;
                    selPoint.second = gcol;
                    currItem->selectedMeshPointX = grow;
                    currItem->selectedMeshPointY = gcol;
                    *m_old_mesh = mp;
                    found = true;
                    break;
                }
            }
            if (found)
                break;
        }
    }
    else if (m_view->editStrokeGradient == 7)
    {
        for (int grow = 0; grow < currItem->meshGradientArray.count(); grow++)
        {
            for (int gcol = 0; gcol < currItem->meshGradientArray[grow].count(); gcol++)
            {
                meshPoint mp1 = currItem->meshGradientArray[grow][gcol];
                QPointF gradientPoint;
                if (grow == 0)
                {
                    if (gcol == 0)
                    {
                        gradientPoint = QPointF(mp1.controlRight.x(), mp1.controlRight.y());
                        if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
                        {
                            m_gradientPoint = useControlR;
                            found = true;
                        }
                        gradientPoint = QPointF(mp1.controlBottom.x(), mp1.controlBottom.y());
                        if (m_canvas->hitsCanvasPoint(mousePointDoc, itemMatrix.map(gradientPoint)))
                        {
                            m_gradientPoint = useControlB;
                            found = true;
                        }
//.........这里部分代码省略.........
开发者ID:aoloe,项目名称:scribus,代码行数:101,代码来源:canvasmode_editmeshgradient.cpp

示例8: FPoint

void PageItem_Group::DrawObj_Item(ScPainter *p, QRectF /*e*/)
{
	if (m_Doc->RePos)
		return;

	if (groupItemList.isEmpty())
	{
		if (m_Doc->guidesPrefs().framesShown)
		{
			p->save();
			p->setPen(Qt::black, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
			p->drawLine(FPoint(0, 0), FPoint(Width, Height));
			p->drawLine(FPoint(0, Height), FPoint(Width, 0));
			p->setFont(QApplication::font());
			p->drawLine(FPoint(0, 0), FPoint(Width, 0));
			p->drawLine(FPoint(Width, 0), FPoint(Width, Height));
			p->drawLine(FPoint(Width, Height), FPoint(0, Height));
			p->drawLine(FPoint(0, Height), FPoint(0, 0));
			p->setBrush(QColor(255, 255, 255));
			p->setBrushOpacity(0.0);
			p->drawText(QRectF(0.0, 0.0, Width, Height), "Empty Group");
			p->restore();
		}
		return;
	}

	p->save();
	if (imageFlippedH())
	{
		p->translate(Width, 0);
		p->scale(-1, 1);
	}
	if (imageFlippedV())
	{
		p->translate(0, Height);
		p->scale(1, -1);
	}
	if ((maskType() == 1) || (maskType() == 2) || (maskType() == 4) || (maskType() == 5))
	{
		if ((maskType() == 1) || (maskType() == 2))
			p->setMaskMode(1);
		else
			p->setMaskMode(3);
		if ((!gradientMask().isEmpty()) && (!m_Doc->docGradients.contains(gradientMask())))
			gradientMaskVal = "";
		if (!(gradientMask().isEmpty()) && (m_Doc->docGradients.contains(gradientMask())))
			mask_gradient = m_Doc->docGradients[gradientMask()];
		p->mask_gradient = mask_gradient;
		if ((maskType() == 1) || (maskType() == 4))
			p->setGradientMask(VGradient::linear, FPoint(GrMaskStartX, GrMaskStartY), FPoint(GrMaskEndX, GrMaskEndY), FPoint(GrMaskStartX, GrMaskStartY), GrMaskScale, GrMaskSkew);
		else
			p->setGradientMask(VGradient::radial, FPoint(GrMaskStartX, GrMaskStartY), FPoint(GrMaskEndX, GrMaskEndY), FPoint(GrMaskFocalX, GrMaskFocalY), GrMaskScale, GrMaskSkew);
	}
	else if ((maskType() == 3) || (maskType() == 6) || (maskType() == 7) || (maskType() == 8))
	{
		if ((patternMask().isEmpty()) || (!m_Doc->docPatterns.contains(patternMask())))
			p->setMaskMode(0);
		else
		{
			double scw = Width / groupWidth;
			double sch = Height / groupHeight;
			p->setPatternMask(&m_Doc->docPatterns[patternMask()], patternMaskScaleX * scw, patternMaskScaleY * sch, patternMaskOffsetX, patternMaskOffsetY, patternMaskRotation, patternMaskSkewX, patternMaskSkewY, patternMaskMirrorX, patternMaskMirrorY);
			if (maskType() == 3)
				p->setMaskMode(2);
			else if (maskType() == 6)
				p->setMaskMode(4);
			else if (maskType() == 7)
				p->setMaskMode(5);
			else
				p->setMaskMode(6);
		}
	}
	else
		p->setMaskMode(0);
	p->setFillRule(fillRule);
	p->beginLayer(1.0 - fillTransparency(), fillBlendmode(), &PoLine);
	p->setMaskMode(0);
	p->scale(Width / groupWidth, Height / groupHeight);
	for (int em = 0; em < groupItemList.count(); ++em)
	{
		PageItem* embedded = groupItemList.at(em);
		p->save();
		p->translate(embedded->gXpos, embedded->gYpos);
		embedded->isEmbedded = true;
		embedded->invalidateLayout();
		embedded->DrawObj(p, QRectF());
		embedded->isEmbedded = false;
		p->restore();
		if (m_Doc->guidesPrefs().framesShown)
		{
			p->save();
			double x = embedded->xPos();
			double y = embedded->yPos();
			embedded->setXYPos(embedded->gXpos, embedded->gYpos, true);
			embedded->DrawObj_Decoration(p);
			embedded->setXYPos(x, y, true);
			p->restore();
		}
		if (m_Doc->layerOutline(LayerID))
		{
//.........这里部分代码省略.........
开发者ID:piksels-and-lines-orchestra,项目名称:scribus,代码行数:101,代码来源:pageitem_group.cpp

示例9: FPoint

void CanvasMode_EditMeshGradient::mouseMoveEvent(QMouseEvent *m)
{
    const FPoint mousePointDoc = m_canvas->globalToCanvas(m->globalPos());
    m->accept();
    if (m_selectedMeshPoints.count() == 0)
        return;
    if (m_canvas->m_viewMode.m_MouseButtonPressed && m_view->moveTimerElapsed())
    {
        FPoint npfN;
        double nx = mousePointDoc.x();
        double ny = mousePointDoc.y();
        if (!m_doc->ApplyGuides(&nx, &ny) && !m_doc->ApplyGuides(&nx, &ny,true))
            npfN = m_doc->ApplyGridF(FPoint(nx, ny));
        else
            npfN = FPoint(nx, ny);
        PageItem *currItem = m_doc->m_Selection->itemAt(0);
        QTransform pp = currItem->getTransform();
        FPoint npf = npfN.transformPoint(pp, true);
        if (m_view->editStrokeGradient == 6)
        {
            if (m_selectedMeshPoints.count() > 0)
            {
                QPair<int, int> selP = m_selectedMeshPoints[0];
                FPoint cP = currItem->meshGradientArray[selP.first][selP.second].controlColor;
                FPoint gP = currItem->meshGradientArray[selP.first][selP.second].gridPoint;
                m_canvas->displayXYHUD(m->globalPos(), cP.x() - gP.x(), cP.y() - gP.y());
            }
        }
        else
            m_canvas->displayXYHUD(m->globalPos(), npf.x(), npf.y());
        FPoint npx(m_Mxp - npfN.x(), m_Myp - npfN.y(), 0, 0, currItem->rotation(), 1, 1, true);
        if (m_selectedMeshPoints.count() > 0)
        {
            if (m_view->editStrokeGradient == 5)
            {
                for (int mo = 0; mo < m_selectedMeshPoints.count(); mo++)
                {
                    QPair<int, int> selP = m_selectedMeshPoints[mo];
                    currItem->meshGradientArray[selP.first][selP.second].moveRel(-npx.x(), -npx.y());
                }
            }
            else if (m_view->editStrokeGradient == 6)
            {
                QPair<int, int> selP = m_selectedMeshPoints[0];
                currItem->meshGradientArray[selP.first][selP.second].controlColor -= npx;
            }
            else if (m_view->editStrokeGradient == 7)
            {
                QPair<int, int> selP = m_selectedMeshPoints[0];
                if (m_gradientPoint == useControlT)
                    currItem->meshGradientArray[selP.first][selP.second].controlTop -= npx;
                else if (m_gradientPoint == useControlB)
                    currItem->meshGradientArray[selP.first][selP.second].controlBottom -= npx;
                else if (m_gradientPoint == useControlL)
                    currItem->meshGradientArray[selP.first][selP.second].controlLeft -= npx;
                else if (m_gradientPoint == useControlR)
                    currItem->meshGradientArray[selP.first][selP.second].controlRight -= npx;
            }
            currItem->update();
            QTransform itemMatrix = currItem->getTransform();
            m_doc->regionsChanged()->update(itemMatrix.mapRect(QRectF(0, 0, currItem->width(), currItem->height())).adjusted(-currItem->width() / 2.0, -currItem->height() / 2.0, currItem->width(), currItem->height()));
        }
        m_Mxp = npfN.x();
        m_Myp = npfN.y();
    }
}
开发者ID:aoloe,项目名称:scribus,代码行数:66,代码来源:canvasmode_editmeshgradient.cpp

示例10: if

void CanvasMode_EditMeshGradient::keyPressEvent(QKeyEvent *e)
{
    if (m_selectedMeshPoints.count() == 0)
        return;
    int kk = e->key();
    if (m_keyRepeat)
        return;
    m_keyRepeat = true;
    e->accept();
    Qt::KeyboardModifiers buttonModifiers = e->modifiers();
    if ((!m_view->m_ScMW->zoomSpinBox->hasFocus()) && (!m_view->m_ScMW->pageSelector->hasFocus()))
    {
        if (m_doc->m_Selection->count() != 0)
        {
            double moveBy = 1.0;
            double moveX = 0.0;
            double moveY = 0.0;
            bool isMoving = false;
            bool doUpdate = false;
            if ((buttonModifiers & Qt::ShiftModifier) && !(buttonModifiers & Qt::ControlModifier) && !(buttonModifiers & Qt::AltModifier))
                moveBy=0.1;
            else if (!(buttonModifiers & Qt::ShiftModifier) && (buttonModifiers & Qt::ControlModifier) && !(buttonModifiers & Qt::AltModifier))
                moveBy=10.0;
            else if ((buttonModifiers & Qt::ShiftModifier) && (buttonModifiers & Qt::ControlModifier) && !(buttonModifiers & Qt::AltModifier))
                moveBy=0.01;
            moveBy/=m_doc->unitRatio();//Lets allow movement by the current doc ratio, not only points
            moveBy /= m_canvas->m_viewMode.scale;
            PageItem *currItem = m_doc->m_Selection->itemAt(0);
            switch (kk)
            {
            case Qt::Key_7:
                moveX = -moveBy;
                moveY = -moveBy;
                isMoving = true;
                doUpdate = true;
                break;
            case Qt::Key_9:
                moveX = moveBy;
                moveY = -moveBy;
                isMoving = true;
                doUpdate = true;
                break;
            case Qt::Key_3:
                moveX = moveBy;
                moveY = moveBy;
                isMoving = true;
                doUpdate = true;
                break;
            case Qt::Key_1:
                moveX = -moveBy;
                moveY = moveBy;
                isMoving = true;
                doUpdate = true;
                break;
            case Qt::Key_Left:
            case Qt::Key_4:
                moveX = -moveBy;
                isMoving = true;
                doUpdate = true;
                break;
            case Qt::Key_Right:
            case Qt::Key_6:
                moveX = moveBy;
                isMoving = true;
                doUpdate = true;
                break;
            case Qt::Key_Up:
            case Qt::Key_8:
                moveY = -moveBy;
                isMoving = true;
                doUpdate = true;
                break;
            case Qt::Key_Down:
            case Qt::Key_2:
                moveY = moveBy;
                isMoving = true;
                doUpdate = true;
                break;
            case Qt::Key_5:
                if (m_view->editStrokeGradient == 6)
                {
                    QPair<int, int> selP = m_selectedMeshPoints[0];
                    currItem->meshGradientArray[selP.first][selP.second].controlColor = currItem->meshGradientArray[selP.first][selP.second].gridPoint;
                    doUpdate = true;
                }
                else if (m_view->editStrokeGradient == 7)
                {
                    QPair<int, int> selP = m_selectedMeshPoints[0];
                    if (m_gradientPoint == useControlT)
                        currItem->meshGradientArray[selP.first][selP.second].controlTop = currItem->meshGradientArray[selP.first][selP.second].gridPoint;
                    else if (m_gradientPoint == useControlB)
                        currItem->meshGradientArray[selP.first][selP.second].controlBottom = currItem->meshGradientArray[selP.first][selP.second].gridPoint;
                    else if (m_gradientPoint == useControlL)
                        currItem->meshGradientArray[selP.first][selP.second].controlLeft = currItem->meshGradientArray[selP.first][selP.second].gridPoint;
                    else if (m_gradientPoint == useControlR)
                        currItem->meshGradientArray[selP.first][selP.second].controlRight = currItem->meshGradientArray[selP.first][selP.second].gridPoint;
                    doUpdate = true;
                }
                break;
            }
//.........这里部分代码省略.........
开发者ID:aoloe,项目名称:scribus,代码行数:101,代码来源:canvasmode_editmeshgradient.cpp

示例11: while


//.........这里部分代码省略.........
                }
            }
            else if (command == "stroke-width")
                strokewidth = ScCLocale::toDoubleC(params);
            else if( command == "stroke-linejoin" )
            {
                if( params == "miter" )
                    LineJoin = Qt::MiterJoin;
                else if( params == "round" )
                    LineJoin = Qt::RoundJoin;
                else if( params == "bevel" )
                    LineJoin = Qt::BevelJoin;
            }
            else if( command == "stroke-linecap" )
            {
                if( params == "butt" )
                    LineEnd = Qt::FlatCap;
                else if( params == "round" )
                    LineEnd = Qt::RoundCap;
                else if( params == "square" )
                    LineEnd = Qt::SquareCap;
            }
        }
        if (STag == "svg:line")
        {
            x1 = ScCLocale::toDoubleC(pg.attribute("x1")) * Conversion;
            y1 = ScCLocale::toDoubleC(pg.attribute("y1")) * Conversion;
            x2 = ScCLocale::toDoubleC(pg.attribute("x2")) * Conversion;
            y2 = ScCLocale::toDoubleC(pg.attribute("y2")) * Conversion;
            PoLine.addPoint(x1, y1);
            PoLine.addPoint(x1, y1);
            PoLine.addPoint(x2, y2);
            PoLine.addPoint(x2, y2);
            int z = m_Doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, baseX, baseY, 10, 10, strokewidth, CommonStrings::None, StrokeCol);
            m_Doc->Items->at(z)->PoLine = PoLine.copy();
            finishItem(m_Doc->Items->at(z));
        }
        else if (STag == "svg:rect")
        {
            x1 = ScCLocale::toDoubleC(pg.attribute("x")) * Conversion;
            y1 = ScCLocale::toDoubleC(pg.attribute("y")) * Conversion;
            x2 = ScCLocale::toDoubleC(pg.attribute("width")) * Conversion;
            y2 = ScCLocale::toDoubleC(pg.attribute("height")) * Conversion;
            int z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, baseX + x1, baseY + y1, x2, y2, strokewidth, FillCol, StrokeCol);
            m_Doc->Items->at(z)->setLineJoin(LineJoin);
            m_Doc->Items->at(z)->setLineEnd(LineEnd);
            finishItem(m_Doc->Items->at(z));
        }
        else if ((STag == "svg:polygon") || (STag == "svg:polyline"))
        {
            bool bFirst = true;
            double x = 0.0;
            double y = 0.0;
            QString points = pg.attribute( "points" ).simplified().replace(',', " ");
            QStringList pointList = points.split(' ', QString::SkipEmptyParts);
            FirstM = true;
            for( QStringList::Iterator it = pointList.begin(); it != pointList.end(); it++ )
            {
                x = ScCLocale::toDoubleC(*(it++));
                y = ScCLocale::toDoubleC(*it);
                if( bFirst )
                {
                    svgMoveTo(x * Conversion, y * Conversion);
                    bFirst = false;
                    WasM = true;
                }
开发者ID:gyuris,项目名称:scribus,代码行数:67,代码来源:importshape.cpp

示例12: if

void CanvasMode_EditWeldPoint::keyPressEvent(QKeyEvent *e)
{
	if (m_selectedPoint < 0)
		return;
	int kk = e->key();
	if (m_keyRepeat)
		return;
	m_keyRepeat = true;
	e->accept();

	if (e->key() == Qt::Key_Escape)
	{
		// Go back to normal mode.
		m_view->requestMode(modeNormal);
		return;
	}

	Qt::KeyboardModifiers buttonModifiers = e->modifiers();
	if ((!m_view->m_ScMW->zoomSpinBox->hasFocus()) && (!m_view->m_ScMW->pageSelector->hasFocus()))
	{
		if (m_doc->m_Selection->count() != 0)
		{
			double moveBy = 1.0;
			double moveX = 0.0;
			double moveY = 0.0;
			bool isMoving = false;
			bool doUpdate = false;
			if (m_doc->unitIndex()!=SC_INCHES)
			{
				if ((buttonModifiers & Qt::ShiftModifier) && !(buttonModifiers & Qt::ControlModifier) && !(buttonModifiers & Qt::AltModifier))
					moveBy=0.1;
				else if (!(buttonModifiers & Qt::ShiftModifier) && (buttonModifiers & Qt::ControlModifier) && !(buttonModifiers & Qt::AltModifier))
					moveBy=10.0;
				else if ((buttonModifiers & Qt::ShiftModifier) && (buttonModifiers & Qt::ControlModifier) && !(buttonModifiers & Qt::AltModifier))
					moveBy=0.01;
				moveBy/=m_doc->unitRatio();//Lets allow movement by the current doc ratio, not only points
			}
			else
			{
				if ((buttonModifiers & Qt::ShiftModifier) && !(buttonModifiers & Qt::ControlModifier) && !(buttonModifiers & Qt::AltModifier))
					moveBy=0.1/m_doc->unitRatio();
				else if (!(buttonModifiers & Qt::ShiftModifier) && (buttonModifiers & Qt::ControlModifier) && !(buttonModifiers & Qt::AltModifier))
					moveBy=1.0/m_doc->unitRatio();
				else if ((buttonModifiers & Qt::ShiftModifier) && (buttonModifiers & Qt::ControlModifier) && !(buttonModifiers & Qt::AltModifier))
					moveBy=0.01/m_doc->unitRatio();
			}
			moveBy /= m_canvas->m_viewMode.scale;
			PageItem *currItem = m_doc->m_Selection->itemAt(0);
			switch (kk)
			{
				case Qt::Key_7:
					moveX = -moveBy;
					moveY = -moveBy;
					isMoving = true;
					doUpdate = true;
					break;
				case Qt::Key_9:
					moveX = moveBy;
					moveY = -moveBy;
					isMoving = true;
					doUpdate = true;
					break;
				case Qt::Key_3:
					moveX = moveBy;
					moveY = moveBy;
					isMoving = true;
					doUpdate = true;
					break;
				case Qt::Key_1:
					moveX = -moveBy;
					moveY = moveBy;
					isMoving = true;
					doUpdate = true;
					break;
				case Qt::Key_Left:
				case Qt::Key_4:
					moveX = -moveBy;
					isMoving = true;
					doUpdate = true;
					break;
				case Qt::Key_Right:
				case Qt::Key_6:
					moveX = moveBy;
					isMoving = true;
					doUpdate = true;
					break;
				case Qt::Key_Up:
				case Qt::Key_8:
					moveY = -moveBy;
					isMoving = true;
					doUpdate = true;
					break;
				case Qt::Key_Down:
				case Qt::Key_2:
					moveY = moveBy;
					isMoving = true;
					doUpdate = true;
					break;
			}
			if (isMoving)
//.........这里部分代码省略.........
开发者ID:nitramr,项目名称:scribus,代码行数:101,代码来源:canvasmode_editweldpoint.cpp

示例13: PyList_Size

PyObject *scribus_polygon(PyObject* /* self */, PyObject* args)
{
	char *Name = const_cast<char*>("");
	PyObject *il;
	// FIXME: PyList_Check failing will cause the function to return NULL w/o an exception. Separarate out the check.
	if ((!PyArg_ParseTuple(args, "O|es", &il, "utf-8", &Name)) || (!PyList_Check(il)))
		return NULL;
	if(!checkHaveDocument())
		return NULL;
	int len = PyList_Size(il);
	if (len < 6)
	{
		PyErr_SetString(PyExc_ValueError, QObject::tr("Point list must contain at least three points (six values).","python error").toLocal8Bit().constData());
		return NULL;
	}
	if ((len % 2) != 0)
	{
		PyErr_SetString(PyExc_ValueError, QObject::tr("Point list must contain an even number of values.","python error").toLocal8Bit().constData());
		return NULL;
	}
//	if (ItemExists(QString::fromUtf8(Name)))
//	{
//		PyErr_SetString(NameExistsError, QObject::tr("An object with the requested name already exists.","python error").toLocal8Bit().constData());
//		return NULL;
//	}
	double x, y, w, h;
	int i = 0;
	x = pageUnitXToDocX(static_cast<double>(PyFloat_AsDouble(PyList_GetItem(il, i))));
	i++;
	y = pageUnitYToDocY(static_cast<double>(PyFloat_AsDouble(PyList_GetItem(il, i))));
	i++;
	int ic = ScCore->primaryMainWindow()->doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, x, y, 1, 1,	ScCore->primaryMainWindow()->doc->itemToolPrefs().shapeLineWidth, ScCore->primaryMainWindow()->doc->itemToolPrefs().shapeFillColor, ScCore->primaryMainWindow()->doc->itemToolPrefs().shapeLineColor);
	PageItem *it = ScCore->primaryMainWindow()->doc->Items->at(ic);
	it->PoLine.resize(2);
	it->PoLine.setPoint(0, 0, 0);
	it->PoLine.setPoint(1, 0, 0);
	int pp = 6;
	for (i = 2; i < len - 2; i += 2)
	{
		w = pageUnitXToDocX(static_cast<double>(PyFloat_AsDouble(PyList_GetItem(il, i))));
		h = pageUnitYToDocY(static_cast<double>(PyFloat_AsDouble(PyList_GetItem(il, i+1))));
		it->PoLine.resize(pp);
		it->PoLine.setPoint(pp-4, w-x, h-y);
		it->PoLine.setPoint(pp-3, w-x, h-y);
		it->PoLine.setPoint(pp-2, w-x, h-y);
		it->PoLine.setPoint(pp-1, w-x, h-y);
		pp += 4;
	}
	w = pageUnitXToDocX(static_cast<double>(PyFloat_AsDouble(PyList_GetItem(il, len-2))));
	h = pageUnitYToDocY(static_cast<double>(PyFloat_AsDouble(PyList_GetItem(il, len-1))));
	it->PoLine.resize(pp);
	it->PoLine.setPoint(pp-4, w-x, h-y);
	it->PoLine.setPoint(pp-3, w-x, h-y);
	it->PoLine.setPoint(pp-2, w-x, h-y);
	it->PoLine.setPoint(pp-1, w-x, h-y);
	pp += 2;
	it->PoLine.resize(pp);
	it->PoLine.setPoint(pp-2, 0, 0);
	it->PoLine.setPoint(pp-1, 0, 0);
	FPoint np2 = getMinClipF(&it->PoLine);
	if (np2.x() < 0)
	{
		it->PoLine.translate(-np2.x(), 0);
		ScCore->primaryMainWindow()->doc->moveItem(np2.x(), 0, it);
	}
	if (np2.y() < 0)
	{
		it->PoLine.translate(0, -np2.y());
		ScCore->primaryMainWindow()->doc->moveItem(0, np2.y(), it);
	}
	ScCore->primaryMainWindow()->doc->sizeItem(it->PoLine.WidthHeight().x(), it->PoLine.WidthHeight().y(), it, false, false, false);
	ScCore->primaryMainWindow()->doc->adjustItemSize(it);
	if (strlen(Name) > 0)
	{
		QString objName = QString::fromUtf8(Name);
		if (!ItemExists(objName))
			ScCore->primaryMainWindow()->doc->Items->at(ic)->setItemName(objName);
	}
	return PyString_FromString(it->itemName().toUtf8());
}
开发者ID:Fahad-Alsaidi,项目名称:scribus-svn,代码行数:80,代码来源:cmdobj.cpp

示例14: CodeAF

void XfigPlug::processArrows(int forward_arrow, QString fArrowData, int backward_arrow, QString bArrowData, int depth, PageItem *ite)
{
	int		arrow_typeAF;			// (enumeration type)
	int		arrow_styleAF;			// (enumeration type)
	float	arrow_thicknessAF;		// (1/80 inch)
	float	arrow_widthAF;			// (Fig units)
	float	arrow_heightAF;			// (Fig units)
	int		arrow_typeAB;			// (enumeration type)
	int		arrow_styleAB;			// (enumeration type)
	float	arrow_thicknessAB;		// (1/80 inch)
	float	arrow_widthAB;			// (Fig units)
	float	arrow_heightAB;			// (Fig units)
	FPointArray arrow;
	int z = -1;
	PageItem::ItemType iteType;
	if (forward_arrow == 1)
	{
		arrow.resize(0);
		ScTextStream CodeAF(&fArrowData, QIODevice::ReadOnly);
		CodeAF >> arrow_typeAF >> arrow_styleAF >> arrow_thicknessAF >> arrow_widthAF >> arrow_heightAF;
		arrow_widthAF = fig2Pts(arrow_widthAF);
		arrow_heightAF = fig2Pts(arrow_heightAF);
		arrow_thicknessAF = arrow_thicknessAF / 80.0 * 72.0;
		FPoint End = ite->PoLine.point(ite->PoLine.size()-2);
		for (uint xx = ite->PoLine.size()-1; xx > 0; xx -= 2)
		{
			FPoint Vector = ite->PoLine.point(xx);
			if ((End.x() != Vector.x()) || (End.y() != Vector.y()))
			{
				double r = atan2(End.y()-Vector.y(),End.x()-Vector.x())*(180.0/M_PI);
				QTransform arrowTrans;
				if (arrow_typeAF == 0)
					arrow.parseSVG("M -1, -0.5 L 0, 0 L -1, 0.5");
				else if (arrow_typeAF == 1)
					arrow.parseSVG("M -1, -0.5 L 0, 0 L -1, 0.5 z");
				else if (arrow_typeAF == 2)
					arrow.parseSVG("M -1, -0.5 L 0, 0 L -1, 0.5 L -0.7 0 z");
				else if (arrow_typeAF == 3)
					arrow.parseSVG("M -0.7, -0.5 L 0, 0 L -0.7, 0.5 L -1 0 z");
				arrowTrans.translate(End.x(), End.y());
				arrowTrans.rotate(r);
				arrowTrans.scale(arrow_heightAF, arrow_widthAF);
				arrow.map(arrowTrans);
				break;
			}
		}
		QString fillC = "White";
		if (arrow_styleAF == 1)
			fillC = CurrColorStroke;
		if (arrow_typeAF == 0)
		{
			fillC = CommonStrings::None;
			iteType = PageItem::PolyLine;
		}
		else
			iteType = PageItem::Polygon;
		z = m_Doc->itemAdd(iteType, PageItem::Unspecified, ite->xPos(), ite->yPos(), 10, 10, arrow_thicknessAF, fillC, CurrColorStroke);
		if (z >= 0)
		{
			PageItem *item = m_Doc->Items->at(z);
			item->PoLine = arrow.copy();
			item->ClipEdited = true;
			item->FrameType = 3;
			item->setFillShade(CurrFillShade);
			item->setLineShade(CurrStrokeShade);
			FPoint wh = getMaxClipF(&item->PoLine);
			item->setWidthHeight(wh.x(),wh.y());
			item->setTextFlowMode(PageItem::TextFlowDisabled);
			m_Doc->adjustItemSize(item);
			item->setWidthHeight(qMax(item->width(), 1.0), qMax(item->height(), 1.0));
			depthMap.insert(999 - depth, currentItemNr);
			currentItemNr++;
		}
	}
开发者ID:Fahad-Alsaidi,项目名称:scribus,代码行数:74,代码来源:importxfig.cpp

示例15: GetUniqueItem

/*
 * Craig Ringer, 2004-09-09
 * Apply the named style to the currently selected object.
 * pv, 2004-09-13, optionaly param objectName + "check the page" stuff
 */
PyObject *scribus_setstyle(PyObject* /* self */, PyObject* args)
{
	char *style = const_cast<char*>("");
	char *name = const_cast<char*>("");
	if (!PyArg_ParseTuple(args, "es|es", "utf-8", &style, "utf-8", &name))
		return NULL;
	if(!checkHaveDocument())
		return NULL;
	PageItem *item = GetUniqueItem(QString::fromUtf8(name));
	if (item == NULL)
		return NULL;
	if ((item->itemType() == PageItem::TextFrame) || (item->itemType() == PageItem::PathText))
	{
		// First, find the style number associated with the requested style
		// by scanning through the styles looking for the name. If
		// we can't find it, raise PyExc_Exception.
		// FIXME: Should use a more specific exception.
		bool found = false;
		uint styleid = 0;
		// We start at zero here because it's OK to match an internal name
		int docParagraphStylesCount=ScCore->primaryMainWindow()->doc->paragraphStyles().count();
		for (int i=0; i < docParagraphStylesCount; ++i)
		{
			if (ScCore->primaryMainWindow()->doc->paragraphStyles()[i].name() == QString::fromUtf8(style)) {
				found = true;
				styleid = i;
				break;
			}
		}
		if (!found) {
			// whoops, the user specified an invalid style, complain loudly.
			PyErr_SetString(NotFoundError, QObject::tr("Style not found.","python error").toLocal8Bit().constData());
			return NULL;
		}
		// for current item only
		if (ScCore->primaryMainWindow()->doc->m_Selection->count() == 0 || (strlen(name) > 0))
		{
			// quick hack to always apply on the right frame - pv
			ScCore->primaryMainWindow()->view->Deselect(true);
			//CB I dont think we need to draw here. Its faster if we dont.
			ScCore->primaryMainWindow()->view->SelectItem(item, false);
			// Now apply the style.
			int mode = ScCore->primaryMainWindow()->doc->appMode;
			ScCore->primaryMainWindow()->doc->appMode = modeEdit;
			ScCore->primaryMainWindow()->setNewParStyle(QString::fromUtf8(style));
			ScCore->primaryMainWindow()->doc->appMode = mode;
		}
		else // for multiple selection
		{
			int mode = ScCore->primaryMainWindow()->doc->appMode;
			ScCore->primaryMainWindow()->doc->appMode = modeNormal;
			ScCore->primaryMainWindow()->doc->itemSelection_ApplyParagraphStyle(ScCore->primaryMainWindow()->doc->paragraphStyles()[styleid]);
			ScCore->primaryMainWindow()->doc->appMode = mode;
		}
	}
	else
	{
		PyErr_SetString(WrongFrameTypeError, QObject::tr("Cannot set style on a non-text frame.","python error").toLocal8Bit().constData());
		return NULL;
	}
//	Py_INCREF(Py_None);
//	return Py_None;
	Py_RETURN_NONE;
}
开发者ID:Fahad-Alsaidi,项目名称:scribus-svn,代码行数:69,代码来源:cmdobj.cpp


注:本文中的PageItem类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。