コード例 #1
0
bool PathConnectPlugin::run(ScribusDoc* doc, QString)
{
	currDoc = doc;
	firstUpdate = true;
	if (currDoc == 0)
		currDoc = ScCore->primaryMainWindow()->doc;
	if (currDoc->m_Selection->count() > 1)
	{
		Item1 = currDoc->m_Selection->itemAt(0);
		Item2 = currDoc->m_Selection->itemAt(1);
		originalPath1 = Item1->PoLine.copy();
		originalPath2 = Item2->PoLine.copy();
		originalXPos = Item1->xPos();
		originalYPos = Item1->yPos();
		PathConnectDialog *dia = new PathConnectDialog(currDoc->scMW());
		connect(dia, SIGNAL(updateValues(int, int, int, int)), this, SLOT(updateEffect(int, int, int, int)));
		if (dia->exec())
		{
			int pointOne = dia->getFirstLinePoint();
			int pointTwo = dia->getSecondLinePoint();
			int mode = dia->getMode();
			Item1->PoLine = computePath(pointOne, pointTwo, mode, originalPath1, originalPath2);
			Item1->Frame = false;
			Item1->ClipEdited = true;
			Item1->FrameType = 3;
			currDoc->AdjustItemSize(Item1);
			Item1->OldB2 = Item1->width();
			Item1->OldH2 = Item1->height();
			Item1->updateClip();
			Item1->ContourLine = Item1->PoLine.copy();
			currDoc->m_Selection->removeItem(Item1);
			currDoc->itemSelection_DeleteItem();
			currDoc->changed();
		}
		else
		{
			Item1->PoLine = originalPath1.copy();
			Item1->Frame = false;
			Item1->ClipEdited = true;
			Item1->FrameType = 3;
			Item1->setXYPos(originalXPos, originalYPos);
			currDoc->AdjustItemSize(Item1);
			Item1->OldB2 = Item1->width();
			Item1->OldH2 = Item1->height();
			Item1->updateClip();
			Item1->ContourLine = Item1->PoLine.copy();
		}
		currDoc->view()->DrawNew();
		delete dia;
	}
コード例 #2
0
ファイル: pathconnect.cpp プロジェクト: JLuc/scribus
bool PathConnectPlugin::run(ScribusDoc* doc, QString)
{
	m_doc = doc;
	firstUpdate = true;
	if (m_doc == 0)
		m_doc = ScCore->primaryMainWindow()->doc;
	if (m_doc->m_Selection->count() > 1)
	{
		m_item1 = m_doc->m_Selection->itemAt(0);
		m_item2 = m_doc->m_Selection->itemAt(1);
		originalPath1 = m_item1->PoLine.copy();
		originalPath2 = m_item2->PoLine.copy();
		originalXPos = m_item1->xPos();
		originalYPos = m_item1->yPos();
		PathConnectDialog *dia = new PathConnectDialog(m_doc->scMW());
		connect(dia, SIGNAL(updateValues(int, int, int, int)), this, SLOT(updateEffect(int, int, int, int)));
		if (dia->exec())
		{
			int pointOne = dia->getFirstLinePoint();
			int pointTwo = dia->getSecondLinePoint();
			int mode = dia->getMode();
			UndoTransaction *trans = NULL;
			if(UndoManager::undoEnabled())
				trans = new UndoTransaction(UndoManager::instance()->beginTransaction(Um::BezierCurve,Um::ILine,Um::ConnectPath,"",Um::ILine));

			m_item1->PoLine = computePath(pointOne, pointTwo, mode, originalPath1, originalPath2);
			m_item1->ClipEdited = true;
			m_item1->FrameType = 3;
			m_doc->AdjustItemSize(m_item1);
			m_item1->OldB2 = m_item1->width();
			m_item1->OldH2 = m_item1->height();
			if(UndoManager::undoEnabled())
			{
				ScItemState<QPair<FPointArray,FPointArray> > *is = new ScItemState<QPair<FPointArray,FPointArray> >(Um::ConnectPath);
				is->set("CONNECT_PATH","connect_path");
				is->set("OLDX", originalXPos);
				is->set("OLDY", originalYPos);
				is->set("NEWX", m_item1->xPos());
				is->set("NEWY", m_item1->yPos());
				is->setItem(qMakePair(originalPath1, m_item1->PoLine));
				UndoManager::instance()->action(m_item1, is);
			}
			m_item1->updateClip();
			m_item1->ContourLine = m_item1->PoLine.copy();
			m_doc->m_Selection->removeItem(m_item1);
			m_doc->itemSelection_DeleteItem();
			m_doc->changed();
			if (trans)
			{
				trans->commit();
				delete trans;
				trans = NULL;
			}
		}
		else
		{
			m_item1->PoLine = originalPath1.copy();
			m_item1->ClipEdited = true;
			m_item1->FrameType = 3;
			m_item1->setXYPos(originalXPos, originalYPos);
			m_doc->AdjustItemSize(m_item1);
			m_item1->OldB2 = m_item1->width();
			m_item1->OldH2 = m_item1->height();
			m_item1->updateClip();
			m_item1->ContourLine = m_item1->PoLine.copy();
		}
		m_doc->view()->DrawNew();
		delete dia;
	}