コード例 #1
0
ファイル: guidemanagercore.cpp プロジェクト: luzpaz/scribus
void GuideManagerCore::drawPage(ScPainter *p, ScribusDoc *doc, double lineWidth)
{
	Guides::iterator it;
	const GuideManager* guideManager = ScCore->primaryMainWindow()->guidePalette;
	QColor color(doc->guidesPrefs().guideColor);

	if (!m_page || guideManager->pageNr() < 0)
		return;

	// real painting margins including bleeds
	double verticalFrom = 0.0 - doc->bleeds()->top();
	double verticalTo = m_page->height() + doc->bleeds()->bottom();
	double horizontalFrom = 0.0 - doc->bleeds()->left();
	double horizontalTo = m_page->width() + doc->bleeds()->right();

	// all standard
	p->setPen(color, lineWidth, Qt::DashDotLine, Qt::FlatCap, Qt::MiterJoin);
	for (it = m_verticalStdG.begin(); it != m_verticalStdG.end(); ++it)
// 		if ((*it) >= 0 && (*it) <= m_page->width())
// 			p->drawLine(FPoint((*it), 0), FPoint((*it), m_page->height()));
		p->drawLine(FPoint((*it), verticalFrom), FPoint((*it), verticalTo));
	for (it = m_horizontalStdG.begin(); it != m_horizontalStdG.end(); ++it)
// 		if ((*it) >= 0 && (*it) <= m_page->height())
// 			p->drawLine(FPoint(0, (*it)), FPoint(m_page->width(), (*it)));
		p->drawLine(FPoint(horizontalFrom, (*it)), FPoint(horizontalTo, (*it)));

	// highlight selected standards
	if (guideManager->currentIndex() == 0
		   && m_page->pageNr() == guideManager->pageNr())
	{
		p->setPen(Qt::red, lineWidth, Qt::DashDotLine, Qt::FlatCap, Qt::MiterJoin);
		Guides highlight = guideManager->selectedVerticals();
		for (it = highlight.begin(); it != highlight.end(); ++it)
// 			if ((*it) >= 0 && (*it) <= m_page->width())
// 				p->drawLine(FPoint((*it), 0), FPoint((*it), m_page->height()));
			p->drawLine(FPoint((*it), verticalFrom), FPoint((*it), verticalTo));
		highlight = guideManager->selectedHorizontals();
		for (it = highlight.begin(); it != highlight.end(); ++it)
// 			if ((*it) >= 0 && (*it) <= m_page->height())
// 				p->drawLine(FPoint(0, (*it)), FPoint(m_page->width(), (*it)));
			p->drawLine(FPoint(horizontalFrom, (*it)), FPoint(horizontalTo, (*it)));
	}

	// all auto
	if (guideManager->currentIndex() == 1 && guideManager->isVisible())
		color = Qt::red;
	else
		color = doc->guidesPrefs().guideColor;
	p->setPen(color, lineWidth, Qt::DashDotLine, Qt::FlatCap, Qt::MiterJoin);

	for (it = m_verticalAutoG.begin(); it != m_verticalAutoG.end(); ++it)
// 		if ((*it) >= 0 && (*it) <= m_page->width())
// 			p->drawLine(FPoint((*it), 0), FPoint((*it), m_page->height()));
		p->drawLine(FPoint((*it), verticalFrom), FPoint((*it), verticalTo));
	for (it = m_horizontalAutoG.begin(); it != m_horizontalAutoG.end(); ++it)
// 		if ((*it) >= 0 && (*it) <= m_page->height())
// 			p->drawLine(FPoint(0, (*it)), FPoint(m_page->width(), (*it)));
		p->drawLine(FPoint(horizontalFrom, (*it)), FPoint(horizontalTo, (*it)));
}
コード例 #2
0
ファイル: guidemanager.cpp プロジェクト: AlterScribus/ece15
Guides GuideManager::selectedHorizontals()
{
	QModelIndex i;
	QModelIndexList selectedIndexes = horizontalView->selectionModel()->selectedIndexes();
	Guides ret;
	Guides curr = horizontalModel->values();
	foreach (i , selectedIndexes)
	{
		ret.append(curr.at(i.row()));
	}
コード例 #3
0
ファイル: guidemanagercore.cpp プロジェクト: luzpaz/scribus
QString GuideManagerIO::writeVerticalGuides(ScPage *page, GuideManagerCore::GuideType type)
{
	Guides::iterator it;
	QString retval;
	QString tmp;
	Guides tmpGuides = page->guides.verticals(type);
	for (it = tmpGuides.begin(); it != tmpGuides.end(); ++it)
	{
		tmp = tmp.setNum((*it));
		retval += tmp + " ";
	}
	return retval;
}
コード例 #4
0
ファイル: guidemanagercore.cpp プロジェクト: avary/scribus
Guides GuideManagerCore::getAutoVerticals(Page* page)
{
	Guides guides;
	double columnSize;
	int value = m_verticalAutoCount;
	double offset = 0.0;
	double newPageWidth = page->width();

	if (page == NULL)
		page = m_page;
	if (page == NULL)
		return guides;

	if (m_verticalAutoCount == 0)
		return guides;
	++value;

	if (m_verticalAutoRefer == 1)
	{
		newPageWidth = newPageWidth - page->Margins.Left - page->Margins.Right;
		offset = page->Margins.Left;
	}
	else if (m_verticalAutoRefer == 2)
	{
		if (qRound(page->guides.gx) != 0)
		{
			offset = page->guides.gx;
			newPageWidth = page->guides.gw;
		}
	}

	if (page->guides.verticalAutoGap() > 0.0)
		columnSize = (newPageWidth - (value - 1) * page->guides.verticalAutoGap()) / value;
	else
		columnSize = newPageWidth / value;

	for (int i = 1, gapCount = 0; i < value; ++i)
	{
		if (page->guides.verticalAutoGap() > 0.0)
		{
			guides.append(offset + i * columnSize + gapCount * page->guides.verticalAutoGap());
			++gapCount;
			guides.append(offset + i * columnSize + gapCount * page->guides.verticalAutoGap());
		}
		else
			guides.append(offset + columnSize * i);
	}
	return guides;
}
コード例 #5
0
ファイル: guidemanagercore.cpp プロジェクト: avary/scribus
Guides GuideManagerCore::getAutoHorizontals(Page* page)
{
	Guides guides;
	double rowSize;
	int value = m_horizontalAutoCount;
	double offset = 0.0;
	double newPageHeight = page->height();

	if (page == NULL)
		page = m_page;
	if (page == NULL)
		return guides;

	if (m_horizontalAutoCount == 0)
		return guides;
	++value;

	if (m_horizontalAutoRefer == 1)
	{
		newPageHeight = newPageHeight - page->Margins.Top - page->Margins.Bottom;
		offset = page->Margins.Top;
	}
	else if (m_horizontalAutoRefer == 2)
	{
		if (qRound(page->guides.gy) != 0.0)
		{
			offset = page->guides.gy;
			newPageHeight = page->guides.gh;
		}
	}

	if (page->guides.horizontalAutoGap() > 0.0)
		rowSize = (newPageHeight - (value - 1) * page->guides.horizontalAutoGap()) / value;
	else
		rowSize = newPageHeight / value;

	for (int i = 1, gapCount = 0; i < value; ++i)
	{
		if (page->guides.horizontalAutoGap() > 0.0)
		{
			guides.append(offset + i * rowSize + gapCount * page->guides.horizontalAutoGap());
			++gapCount;
			guides.append(offset + i * rowSize + gapCount * page->guides.horizontalAutoGap());
		}
		else
			guides.append(offset + rowSize * i);
	}
	return guides;
}
コード例 #6
0
ファイル: guidemanager.cpp プロジェクト: AlterScribus/ece15
void GuideManager::delVerButton_clicked()
{
	QModelIndexList indexes = verticalView->selectionModel()->selectedRows(0);
	QModelIndex ix;
	Guides v;

	foreach(ix, indexes)
		// here *must* go EditRole due truncations in DisplayRole
		// see GuidesModel::data()
		v.append(verticalModel->data(ix, Qt::EditRole).toDouble());

	verticalModel->removeValues(v);

	currentPage->guides.clearVerticals(GuideManagerCore::Standard);
	currentPage->guides.addVerticals(verticalModel->values(), GuideManagerCore::Standard);
	drawGuides();
	m_Doc->changed();
}
コード例 #7
0
ファイル: guidemanagercore.cpp プロジェクト: luzpaz/scribus
void GuideManagerCore::addHorizontals(Guides values, GuideType type)
{
	Guides::iterator it;
	switch (type)
	{
		case Standard:
			for (it = values.begin(); it != values.end(); ++it)
			{
				if (!m_horizontalStdG.contains((*it)))
					m_horizontalStdG.append((*it));
			}
			break;
		case Auto:
			m_horizontalAutoG.clear();
			for (it = values.begin(); it != values.end(); ++it)
				m_horizontalAutoG.append((*it));
			break;
	}
}
コード例 #8
0
ファイル: cmdpage.cpp プロジェクト: AlterScribus/ece15
PyObject *scribus_getVguides(PyObject* /* self */)
{
	if(!checkHaveDocument())
		return NULL;
	Guides g = ScCore->primaryMainWindow()->doc->currentPage()->guides.verticals(GuideManagerCore::Standard);
	int n = g.count();//ScCore->primaryMainWindow()->doc->currentPage->XGuides.count();
	if (n == 0)
		return Py_BuildValue((char*)"[]");
	int i;
	double tmp;
	PyObject *l, *guide;
	l = PyList_New(0);
	for (i=0; i<n; i++)
	{
		tmp = g[i];
		guide = Py_BuildValue("d", PointToValue(tmp));
		PyList_Append(l, guide);
	}
	return l;
}
コード例 #9
0
ファイル: guidemanagercore.cpp プロジェクト: luzpaz/scribus
int GuideManagerCore::isMouseOnVertical(double low, double high, GuideType type)
{
	Guides tmp;
	Guides::iterator it;

	switch (type)
	{
		case Standard:
			tmp = m_verticalStdG;
			break;
		case Auto:
			tmp = m_horizontalAutoG;
			break;
	}
	for (it = tmp.begin(); it != tmp.end(); ++it)
	{
		double guideOffset = (*it) + m_page->xOffset();
		if (guideOffset < low && guideOffset > high)
			return it - tmp.begin();
	}
	return -1;
}