예제 #1
0
void TCacheResource::release2(const TRect &rect)
{
	//DIAGNOSTICS_NUMBEREDSTRSET(prefix + QString::number((UINT) this) + " | Stack | ",
	//"crStack", "release", ::traduce(rect));

	if (m_locksCount > 0)
		return;

	std::map<PointLess, CellData>::iterator it;
	for (it = m_cellDatas.begin(); it != m_cellDatas.end();) {
		if (!it->second.m_referenced) {
			++it;
			continue;
		}

		TPoint cellPos(getCellPos(it->first));
		TRect cellRect(cellPos, TDimension(latticeStep, latticeStep));

		if (isEmpty(cellRect * rect)) {
			++it;
			continue;
		}

		QRect cellQRect(toQRect(cellRect));
		if (--it->second.m_refsCount <= 0) {
			releaseCell(cellQRect, it->first, it->second.m_modified);
			std::map<PointLess, CellData>::iterator jt = it++;
			m_cellDatas.erase(jt);
		} else
			++it;
	}
}
예제 #2
0
//! Clears the complex on the specified region. Please observe that the actually cleared region
//! consists of all lattice cells intersecting the passed region, therefore resulting in a cleared region
//! typically larger than passed one, up to the lattice granularity.
void TCacheResource::clear(QRegion region)
{
	if (!m_region.intersects(region))
		return;

	//Get the region bbox
	TRect bbox(toTRect(region.boundingRect()));

	//For all cells intersecting the bbox
	TPoint initialPos(getCellPos(bbox.getP00()));
	TPoint pos;
	for (pos.x = initialPos.x; pos.x <= bbox.x1; pos.x += latticeStep)
		for (pos.y = initialPos.y; pos.y <= bbox.y1; pos.y += latticeStep) {
			QRect cellQRect(toQRect(TRect(pos, TDimension(latticeStep, latticeStep))));

			if (region.intersects(cellQRect) && m_region.intersects(cellQRect)) {
				//Release the associated cell from cache and clear the cell from the content region.
				TImageCache::instance()->remove(getCellCacheId(pos));
				m_region -= cellQRect;

				--m_cellsCount;

				//DIAGNOSTICS_GLOADD("crCellsCnt", -1);

				//Release the cell from m_cellDatas
				m_cellDatas[getCellIndex(pos)].m_modified = true;
			}
		}

	if (m_region.isEmpty()) {
		m_tileType = NONE;
		m_locksCount = 0;
	}
}
예제 #3
0
EntityValueDialog::EntityValueDialog(const Interface::Adaptor<IStorage> &storage, const EntityValue &value, const ValueModel::Files &files, QWidget *parent) :
    NestedPlainDialog(parent),
    m_handler(this),
    m_mainWidget(storage, value, files, &m_handler, this)
{
    init(toQRect(storage->editorGeometry(m_mainWidget.entity())));
    setWindowTitle(tr("Editing value of \"%1\"").arg(toUnicode(m_mainWidget.entity().name())));
}
예제 #4
0
EntityValueDialog::EntityValueDialog(const Interface::Adaptor<IStorage> &storage, const EntityValueReader &reader, QWidget *parent) :
    NestedPlainDialog(parent),
    m_handler(this),
    m_mainWidget(storage, reader, &m_handler, this)
{
    init(toQRect(storage->listGeometry(m_mainWidget.entity())));
    setWindowTitle(tr("Values of \"%1\"").arg(toUnicode(m_mainWidget.entity().name())));
}
예제 #5
0
//! Fills the passed tile with the data contained in the complex, returning
//! the copied region.
//! The same restriction of the upload() method applies here.
QRegion TCacheResource::download(const TPoint &pos, TRasterP ras)
{
	int tileType;
	if (!checkRasterType(ras, tileType))
		return QRegion();

	//Build the tile's rect
	TRect tileRect(ras->getBounds() + pos);

	if (!m_region.intersects(toQRect(tileRect)))
		return QRegion();

	//For all cells intersecting the tile's rect, copy all those intersecting the
	//complex's content region.
	TPoint initialPos(getCellPos(tileRect.getP00()));

	TPoint currPos;
	for (currPos.x = initialPos.x; currPos.x <= tileRect.x1; currPos.x += latticeStep)
		for (currPos.y = initialPos.y; currPos.y <= tileRect.y1; currPos.y += latticeStep) {
			TRect cellRect(currPos, TDimension(latticeStep, latticeStep));

			TRect overlapRect(tileRect * cellRect);
			assert(!overlapRect.isEmpty());
			QRect overlapQRect(toQRect(overlapRect));

			if (m_region.intersects(overlapQRect)) {
				//Extract the associated rasters and perform the copy to the input tile.
				std::pair<TRasterP, CellData *> cellInfos(touch(getCellIndex(currPos)));
				TRasterP cellRas(cellInfos.first);

				TRect temp(overlapRect - currPos);
				TRasterP overlappingCellRas(cellRas->extract(temp));
				temp = TRect(overlapRect - tileRect.getP00());
				TRasterP overlappingTileRas(ras->extract(temp));

				TRop::copy(overlappingTileRas, overlappingCellRas);
			}
		}

	return m_region.intersected(QRegion(toQRect(tileRect)));
}
예제 #6
0
파일: Util.cpp 프로젝트: netromdk/mocam
  void Util::paintOverlays(QImage &image, const QList<FacePtr> &faces,
                           bool noFaces, bool noEyes) {
    QPainter painter;
    painter.begin(&image);

    QPen pen = painter.pen();
    pen.setWidth(3);
    painter.setPen(pen);

    foreach (const auto &face, faces) {
      if (!noFaces) {
        painter.drawRect(toQRect(face->getFace()));
      }
      if (!noEyes && face->hasEyes()) {
        painter.drawRect(toQRect(face->getEye1()));
        painter.drawRect(toQRect(face->getEye2()));
      }
    }

    painter.end();
  }
예제 #7
0
//! Copies the passed tile in the tile complex. The passed tile \b must
//! possess integer geometry (ie tile.m_pos must have integer coordinates),
//! otherwise this function is a no-op.
bool TCacheResource::upload(const TPoint &pos, TRasterP ras)
{
	int tileType;
	if (!checkRasterType(ras, tileType))
		return false;

	if (m_tileType == NONE)
		m_tileType = tileType;

	//For all cells of the lattice which intersect the tile, upload the content in the
	//complex
	TRect tileRect(ras->getBounds() + pos);
	TPoint initialPos(getCellPos(tileRect.getP00()));

	//DIAGNOSTICS_NUMBEREDSTRSET(prefix + QString::number((UINT) this) + " | Stack | ",
	//"crStack", "upload", ::traduce(TRect(pos, ras->getSize())));

	TPoint currPos;
	for (currPos.x = initialPos.x; currPos.x <= tileRect.x1; currPos.x += latticeStep)
		for (currPos.y = initialPos.y; currPos.y <= tileRect.y1; currPos.y += latticeStep) {
			//Copy tile's content into the cell's raster.
			TRect cellRect(currPos, TDimension(latticeStep, latticeStep));

			TRect overlapRect(tileRect * cellRect);
			assert(!overlapRect.isEmpty());

			PointLess cellIndex(getCellIndex(currPos));
			std::pair<TRasterP, CellData *> cellInfos(touch(cellIndex));
			TRasterP cellRas(cellInfos.first);

			TRect temp(overlapRect - currPos);
			TRasterP overlappingCellRas(cellRas->extract(temp));
			temp = TRect(overlapRect - tileRect.getP00());
			TRasterP overlappingTileRas(ras->extract(temp));

			assert(overlappingCellRas->getBounds() == overlappingTileRas->getBounds());
			TRop::copy(overlappingCellRas, overlappingTileRas);

			cellInfos.second->m_modified = true;
		}

	//Update the complex's content region
	m_region += toQRect(tileRect);

	return true;
}
예제 #8
0
bool TCacheResource::downloadAll(const TPoint &pos, TRasterP ras)
{
	int tileType;
	if (!checkRasterType(ras, tileType))
		return false;

	//Build the tile's rect
	TRect tileRect(ras->getBounds() + pos);

	if (!contains(m_region, tileRect))
		return false;

	//DIAGNOSTICS_NUMBEREDSTRSET(prefix + QString::number((UINT) this) + " | Stack | ",
	//"crStack", "downloadAll", ::traduce(TRect(pos, ras->getSize())));

	//For all cells intersecting the tile's rect, copy all those intersecting the
	//complex's content region.
	TPoint initialPos(getCellPos(tileRect.getP00()));

	TPoint currPos;
	for (currPos.x = initialPos.x; currPos.x <= tileRect.x1; currPos.x += latticeStep)
		for (currPos.y = initialPos.y; currPos.y <= tileRect.y1; currPos.y += latticeStep) {
			TRect cellRect(currPos, TDimension(latticeStep, latticeStep));

			TRect overlapRect(tileRect * cellRect);
			assert(!overlapRect.isEmpty());
			QRect overlapQRect(toQRect(overlapRect));

			if (m_region.intersects(overlapQRect)) {
				//Extract the associated rasters and perform the copy to the input tile.
				std::pair<TRasterP, CellData *> cellInfos(touch(getCellIndex(currPos)));
				TRasterP cellRas(cellInfos.first);

				TRect temp(overlapRect - currPos);
				TRasterP overlappingCellRas(cellRas->extract(temp));
				temp = TRect(overlapRect - tileRect.getP00());
				TRasterP overlappingTileRas(ras->extract(temp));

				TRop::copy(overlappingTileRas, overlappingCellRas);
			}
		}

	return true;
}
예제 #9
0
//! Returns true if the passed tile is compatible with the complex, and some
//! part of it is downloadable.
bool TCacheResource::canDownloadSome(const TTile &tile) const
{
	return checkTile(tile) && m_region.intersects(toQRect(getTileRect(tile)));
}
예제 #10
0
bool TCacheResource::canDownloadSome(const TRect &rect) const
{
	return m_region.intersects(toQRect(rect));
}