本文整理汇总了C++中RectD类的典型用法代码示例。如果您正苦于以下问题:C++ RectD类的具体用法?C++ RectD怎么用?C++ RectD使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RectD类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: k
void
ViewerNode::setPartialUpdateParams(const std::list<RectD>& rois,
bool recenterViewer)
{
double viewerCenterX = 0;
double viewerCenterY = 0;
if (recenterViewer) {
RectD bbox;
bool bboxSet = false;
for (std::list<RectD>::const_iterator it = rois.begin(); it != rois.end(); ++it) {
if (!bboxSet) {
bboxSet = true;
bbox = *it;
} else {
bbox.merge(*it);
}
}
viewerCenterX = (bbox.x1 + bbox.x2) / 2.;
viewerCenterY = (bbox.y1 + bbox.y2) / 2.;
}
QMutexLocker k(&_imp->partialUpdatesMutex);
_imp->partialUpdateRects = rois;
_imp->viewportCenterSet = recenterViewer;
_imp->viewportCenter.x = viewerCenterX;
_imp->viewportCenter.y = viewerCenterY;
}
示例2: getCenterKnob
RectI
TrackMarker::getMarkerImageRoI(int time) const
{
const unsigned int mipmapLevel = 0;
Point center, offset;
KnobDoublePtr centerKnob = getCenterKnob();
KnobDoublePtr offsetKnob = getOffsetKnob();
center.x = centerKnob->getValueAtTime(time, 0);
center.y = centerKnob->getValueAtTime(time, 1);
offset.x = offsetKnob->getValueAtTime(time, 0);
offset.y = offsetKnob->getValueAtTime(time, 1);
RectD roiCanonical;
KnobDoublePtr swBl = getSearchWindowBottomLeftKnob();
KnobDoublePtr swTr = getSearchWindowTopRightKnob();
roiCanonical.x1 = swBl->getValueAtTime(time, 0) + center.x + offset.x;
roiCanonical.y1 = swBl->getValueAtTime(time, 1) + center.y + offset.y;
roiCanonical.x2 = swTr->getValueAtTime(time, 0) + center.x + offset.x;
roiCanonical.y2 = swTr->getValueAtTime(time, 1) + center.y + offset.y;
RectI roi;
NodePtr node = getContext()->getNode();
NodePtr input = node->getInput(0);
if (!input) {
return RectI();
}
roiCanonical.toPixelEnclosing(mipmapLevel, input ? input->getEffectInstance()->getAspectRatio(-1) : 1., &roi);
return roi;
}
示例3: name
// caller must free() the result
char *DestRectToStr(BaseEngine *engine, PageDestination *dest)
{
if (ScopedMem<WCHAR>(dest->GetDestName())) {
ScopedMem<char> name(Escape(dest->GetDestName()));
return str::Format("Name=\"%s\"", name);
}
// as handled by LinkHandler::ScrollTo in WindowInfo.cpp
int pageNo = dest->GetDestPageNo();
if (pageNo <= 0 || pageNo > engine->PageCount())
return NULL;
RectD rect = dest->GetDestRect();
if (rect.IsEmpty()) {
PointD pt = engine->Transform(rect.TL(), pageNo, 1.0, 0);
return str::Format("Point=\"%.0f %.0f\"", pt.x, pt.y);
}
if (rect.dx != DEST_USE_DEFAULT && rect.dy != DEST_USE_DEFAULT) {
RectI rc = engine->Transform(rect, pageNo, 1.0, 0).Round();
return str::Format("Rect=\"%d %d %d %d\"", rc.x, rc.y, rc.dx, rc.dy);
}
if (rect.y != DEST_USE_DEFAULT) {
PointD pt = engine->Transform(rect.TL(), pageNo, 1.0, 0);
return str::Format("Point=\"x %.0f\"", pt.y);
}
return NULL;
}
示例4: GetTileRectDevice
// get the coordinates of a specific tile
static RectI GetTileRectDevice(BaseEngine* engine, int pageNo, int rotation, float zoom, TilePosition tile) {
RectD mediabox = engine->PageMediabox(pageNo);
if (tile.res > 0 && tile.res != INVALID_TILE_RES)
mediabox = GetTileRect(mediabox, tile);
RectD pixelbox = engine->Transform(mediabox, pageNo, zoom, rotation);
return pixelbox.Round();
}
示例5: DetermineLinearGradientPoints
void XARGenerator::DetermineLinearGradientPoints(const Gradient* pGradient, const Transformation& trans,
const RectD& boundings, DocCoord& p1, DocCoord& p2)
{
if (pGradient->units == Gradient::ObjectBoundingBox) {
PointD pLower = boundings.LowerCoord();
PointD pHigher = boundings.HigherCoord();
p1 = DocCoord((INT32)pLower.x, m_docSize.y - (INT32)pLower.y);
p2 = DocCoord((INT32)pHigher.x, m_docSize.y - (INT32)pHigher.y);
#ifdef SVGDEBUG
svgtrace(DBGTRACE_GRADIENTS, "using ObjectBoundingBox %d,%d %d,%d\n", p1.x, p1.y, p2.x, p2.y);
#endif
} else { // Gradient->units == Gradient::UserSpaceOnUse
double fX1 = pGradient->x1;
double fY1 = pGradient->y1;
double fX2 = pGradient->x2;
double fY2 = pGradient->y2;
trans.ApplyToCoordinate(fX1, fY1, &fX1, &fY1);
trans.ApplyToCoordinate(fX2, fY2, &fX2, &fY2);
p1 = DocCoord((INT32)fX1, m_docSize.y - (INT32)fY1);
p2 = DocCoord((INT32)fX2, m_docSize.y - (INT32)fY2);
#if SVGDEBUG
svgtrace(DBGTRACE_GRADIENTS, "using UserSpaceOnUse %d,%d %d,%d\n", p1.x, p1.y, p2.x, p2.y);
#endif
}
}
示例6: OnPaint
static LRESULT OnPaint(HWND hwnd)
{
ClientRect rect(hwnd);
DoubleBuffer buffer(hwnd, rect);
HDC hdc = buffer.GetDC();
HBRUSH brushBg = CreateSolidBrush(COL_WINDOW_BG);
HBRUSH brushWhite = GetStockBrush(WHITE_BRUSH);
FillRect(hdc, &rect.ToRECT(), brushBg);
PreviewBase *preview = (PreviewBase *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
if (preview && preview->renderer) {
int pageNo = GetScrollPos(hwnd, SB_VERT);
RectD page = preview->renderer->GetPageRect(pageNo);
if (!page.IsEmpty()) {
rect.Inflate(-PREVIEW_MARGIN, -PREVIEW_MARGIN);
float zoom = (float)min(rect.dx / page.dx, rect.dy / page.dy) - 0.001f;
RectI onScreen = RectD(rect.x, rect.y, page.dx * zoom, page.dy * zoom).Round();
onScreen.Offset((rect.dx - onScreen.dx) / 2, (rect.dy - onScreen.dy) / 2);
FillRect(hdc, &onScreen.ToRECT(), brushWhite);
preview->renderer->Render(hdc, onScreen, pageNo, zoom);
}
}
DeleteObject(brushBg);
DeleteObject(brushWhite);
PAINTSTRUCT ps;
buffer.Flush(BeginPaint(hwnd, &ps));
EndPaint(hwnd, &ps);
return 0;
}
示例7: DumpThumbnail
void DumpThumbnail(BaseEngine *engine)
{
RectD rect = engine->Transform(engine->PageMediabox(1), 1, 1.0, 0);
if (rect.IsEmpty()) {
Out("\t<Thumbnail />\n");
return;
}
float zoom = min(128 / (float)rect.dx, 128 / (float)rect.dy) - 0.001f;
RectI thumb = RectD(0, 0, rect.dx * zoom, rect.dy * zoom).Round();
rect = engine->Transform(thumb.Convert<double>(), 1, zoom, 0, true);
RenderedBitmap *bmp = engine->RenderBitmap(1, zoom, 0, &rect);
if (!bmp) {
Out("\t<Thumbnail />\n");
return;
}
size_t len;
ScopedMem<unsigned char> data(tga::SerializeBitmap(bmp->GetBitmap(), &len));
ScopedMem<char> hexData(data ? str::MemToHex(data, len) : NULL);
if (hexData)
Out("\t<Thumbnail>\n\t\t%s\n\t</Thumbnail>\n", hexData.Get());
else
Out("\t<Thumbnail />\n");
delete bmp;
}
示例8: BoundSelectionOnPage
static RectD BoundSelectionOnPage(const Vec<SelectionOnPage> &sel, int pageNo) {
RectD bounds;
for (size_t i = 0; i < sel.Count(); i++) {
if (sel.At(i).pageNo == pageNo)
bounds = bounds.Union(sel.At(i).rect);
}
return bounds;
}
示例9: CreateCompatibleDC
void DjVuEngineImpl::AddUserAnnots(RenderedBitmap *bmp, int pageNo, float zoom, int rotation, RectI screen)
{
if (!bmp || userAnnots.Count() == 0)
return;
HDC hdc = CreateCompatibleDC(NULL);
HGDIOBJ prevBmp = SelectObject(hdc, bmp->GetBitmap());
{
using namespace Gdiplus;
Graphics g(hdc);
g.SetCompositingQuality(CompositingQualityHighQuality);
g.SetPageUnit(UnitPixel);
for (size_t i = 0; i < userAnnots.Count(); i++) {
PageAnnotation& annot = userAnnots.At(i);
if (annot.pageNo != pageNo)
continue;
RectD arect;
switch (annot.type) {
case Annot_Highlight:
arect = Transform(annot.rect, pageNo, zoom, rotation);
arect.Offset(-screen.x, -screen.y);
g.FillRectangle(&SolidBrush(Unblend(annot.color, 119)), arect.ToGdipRectF());
break;
case Annot_Underline:
case Annot_StrikeOut:
arect = RectD(annot.rect.x, annot.rect.BR().y, annot.rect.dx, 0);
if (Annot_StrikeOut == annot.type)
arect.y -= annot.rect.dy / 2;
arect = Transform(arect, pageNo, zoom, rotation);
arect.Offset(-screen.x, -screen.y);
g.DrawLine(&Pen(FromColor(annot.color), zoom), (float)arect.x,
(float)arect.y, (float)arect.BR().x, (float)arect.BR().y);
break;
case Annot_Squiggly:
{
Pen p(FromColor(annot.color), 0.5f * zoom);
REAL dash[2] = { 2, 2 };
p.SetDashPattern(dash, dimof(dash));
p.SetDashOffset(1);
arect = Transform(RectD(annot.rect.x, annot.rect.BR().y - 0.25f, annot.rect.dx, 0), pageNo, zoom, rotation);
arect.Offset(-screen.x, -screen.y);
g.DrawLine(&p, (float)arect.x, (float)arect.y, (float)arect.BR().x, (float)arect.BR().y);
p.SetDashOffset(3);
arect = Transform(RectD(annot.rect.x, annot.rect.BR().y + 0.25f, annot.rect.dx, 0), pageNo, zoom, rotation);
arect.Offset(-screen.x, -screen.y);
g.DrawLine(&p, (float)arect.x, (float)arect.y, (float)arect.BR().x, (float)arect.BR().y);
}
break;
}
}
}
SelectObject(hdc, prevBmp);
DeleteDC(hdc);
}
示例10:
void
ViewerGL::Implementation::getPolygonTextureCoordinates(const QPolygonF & polygonPoints,
const RectD & texRect,
QPolygonF & texCoords)
{
texCoords.resize( polygonPoints.size() );
for (int i = 0; i < polygonPoints.size(); ++i) {
const QPointF & polygonPoint = polygonPoints.at(i);
QPointF texCoord;
texCoord.setX( (polygonPoint.x() - texRect.x1) / texRect.width() ); // * (right - left));
texCoord.setY( (polygonPoint.y() - texRect.y1) / texRect.height() ); // * (top - bottom));
texCoords[i] = texCoord;
}
}
示例11:
// The offset of the current project in canonical coordinates.
// The offset is related to the kOfxImageEffectPropProjectSize and is the offset from the origin
// of the project 'subwindow'. For example for a PAL SD project that is in letterbox form, the
// project offset is the offset to the bottom left hand corner of the letter box. The project
// offset is in canonical coordinates.
void
OfxImageEffectInstance::getProjectOffset(double & xOffset,
double & yOffset) const
{
Format f;
_ofxEffectInstance->getRenderFormat(&f);
RectI pixelF;
pixelF.x1 = f.x1;
pixelF.x2 = f.x2;
pixelF.y1 = f.y1;
pixelF.y2 = f.y2;
RectD canonicalF;
pixelF.toCanonical_noClipping(0, f.getPixelAspectRatio(), &canonicalF);
xOffset = canonicalF.left();
yOffset = canonicalF.bottom();
}
示例12: make_pair
std::pair<ImagePtr, RectD>
TrackMarker::getMarkerImage(TimeValue time,
const RectD& roi) const
{
assert( !roi.isNull() );
NodePtr node = getModel()->getNode();
NodePtr input = node->getInput(0);
if (!input) {
return std::make_pair(ImagePtr(), roi);
}
TreeRender::CtorArgsPtr args(new TreeRender::CtorArgs);
{
args->treeRootEffect = input->getEffectInstance();
args->time = time;
args->view = ViewIdx(0);
// Render default plane
args->plane = 0;
args->mipMapLevel = 0;
args->proxyScale = RenderScale(1.);
args->canonicalRoI = &roi;
args->draftMode = false;
args->playback = false;
args->byPassCache = false;
}
TreeRenderPtr render = TreeRender::create(args);
FrameViewRequestPtr outputRequest;
ActionRetCodeEnum stat = render->launchRender(&outputRequest);
if (isFailureRetCode(stat)) {
return std::make_pair(ImagePtr(), roi);
}
ImagePtr sourceImage = outputRequest->getRequestedScaleImagePlane();
// Make sure the Natron image rendered is RGBA full rect and on CPU, we don't support other formats
if (sourceImage->getStorageMode() != eStorageModeRAM) {
Image::InitStorageArgs initArgs;
initArgs.bounds = sourceImage->getBounds();
initArgs.plane = sourceImage->getLayer();
initArgs.bufferFormat = eImageBufferLayoutRGBAPackedFullRect;
initArgs.storage = eStorageModeRAM;
initArgs.bitdepth = sourceImage->getBitDepth();
ImagePtr tmpImage = Image::create(initArgs);
if (!tmpImage) {
return std::make_pair(ImagePtr(), roi);
}
Image::CopyPixelsArgs cpyArgs;
cpyArgs.roi = initArgs.bounds;
tmpImage->copyPixels(*sourceImage, cpyArgs);
sourceImage = tmpImage;
}
return std::make_pair(sourceImage, roi);
} // TrackMarker::getMarkerImage
示例13: GetTileRectDevice
// get the coordinates of a specific tile
static RectI GetTileRectDevice(BaseEngine *engine, int pageNo, int rotation, float zoom, TilePosition tile)
{
RectD mediabox = engine->PageMediabox(pageNo);
if (tile.res && tile.res != INVALID_TILE_RES) {
CrashIf(tile.res > 30);
double width = mediabox.dx / (1ULL << tile.res);
mediabox.x += tile.col * width;
mediabox.dx = width;
double height = mediabox.dy / (1ULL << tile.res);
mediabox.y += ((1 << tile.res) - tile.row - 1) * height;
mediabox.dy = height;
}
RectD pixelbox = engine->Transform(mediabox, pageNo, zoom, rotation);
return pixelbox.Round();
}
示例14: getHolder
void
Double_Knob::normalize(int dimension,
double time,
double* value) const
{
EffectInstance* effect = dynamic_cast<EffectInstance*>( getHolder() );
assert(effect);
if (!effect) {
// coverity[dead_error_line]
return;
}
RectD rod;
getInputRoD(effect,time,rod);
if (dimension == 0) {
*value /= rod.width();
} else if (dimension == 1) {
*value /= rod.height();
}
}
示例15: GetInvalidateRect
bool GetInvalidateRect(RectD & retVal) const
{
if (!m_invalidateRect.IsEmptyArea())
retVal = m_invalidateRect;
if (m_hotItem)
{
if (hpcc::ElementG * hotElementG = GetElementG(m_hotItem))
{
retVal = hotElementG->GetBoundingBox();
if (m_hotEdge)
{
if (hpcc::ElementG * hotElementG = GetElementG(m_hotEdge->GetFromVertex()))
retVal.Union(hotElementG->GetBoundingBox());
if (hpcc::ElementG * hotElementG = GetElementG(m_hotEdge->GetToVertex()))
retVal.Union(hotElementG->GetBoundingBox());
}
else if(m_hotVertex)
{
for(IEdgeSet::const_iterator itr = m_hotVertex->GetInEdges().begin(); itr != m_hotVertex->GetInEdges().end(); ++itr)
{
if (hpcc::ElementG * hotElementG = GetElementG(itr->get()))
retVal.Union(hotElementG->GetBoundingBox());
}
for(IEdgeSet::const_iterator itr = m_hotVertex->GetOutEdges().begin(); itr != m_hotVertex->GetOutEdges().end(); ++itr)
{
if (hpcc::ElementG * hotElementG = GetElementG(itr->get()))
retVal.Union(hotElementG->GetBoundingBox());
}
}
}
}
m_invalidateRect = retVal;
return !m_invalidateRect.IsEmptyArea();
}