void TransformRect( LPTFORM lpTForm, LPRECT lpRect, LPRECT lpNewRect ) /************************************************************************/ { int x1, x2, x3, x4, y1, y2, y3, y4; POINT Point; // check for identity transform if (ISNULLTFORM(lpTForm)) { *lpNewRect = *lpRect; return; } Point.x = lpRect->left; Point.y = lpRect->top; Transformer( lpTForm, &Point, &x1, &y1 ); Point.x = lpRect->right; Point.y = lpRect->top; Transformer( lpTForm, &Point, &x2, &y2 ); Point.x = lpRect->right; Point.y = lpRect->bottom; Transformer( lpTForm, &Point, &x3, &y3 ); Point.x = lpRect->left; Point.y = lpRect->bottom; Transformer( lpTForm, &Point, &x4, &y4 ); lpNewRect->left = min( x1, min( x2, min( x3, x4 ) ) ); lpNewRect->right = max( x1, max( x2, max( x3, x4 ) ) ); lpNewRect->top = min( y1, min( y2, min( y3, y4 ) ) ); lpNewRect->bottom = max( y1, max( y2, max( y3, y4 ) ) ); }
//================================================================ // Function : TexturesExt_Presentation::sampleBottle // Purpose : //================================================================ void TexturesExt_Presentation::sampleBottle() { TopoDS_Shape aShape; if (!loadShape(aShape, "bottle.brep")) return; // resize and move the shape to the center of the viewer gp_Trsf aTrsf1, aTrsf2; aTrsf1.SetScale(gp_Pnt(0,0,0), 0.8); aTrsf2.SetTranslation(gp_Pnt(0,0,0),gp_Pnt(0,0,-20)); aTrsf1.Multiply(aTrsf2); BRepBuilderAPI_Transform Transformer(aTrsf1); Transformer.Perform(aShape); aShape = Transformer.Shape(); TopTools_IndexedMapOfShape aFaces; TopExp::MapShapes(aShape, TopAbs_FACE, aFaces); // display original shape in shaded display mode Handle_AIS_Shape aShapeIO = drawShape(aShape, Graphic3d_NOM_BRASS, Standard_False); getAISContext()->SetDisplayMode(aShapeIO, AIS_Shaded, Standard_False); // Set increased polygon offset for the main shape to avoid depth collision with textured faces aShapeIO->SetPolygonOffsets(Aspect_POM_Fill, 1.5, 0.5); DISP(aShapeIO); Handle_AIS_TexturedShape aTFace1 = Texturize(aFaces(16), "carrelage1.gif", 1, 1, 3, 2); DISP(aTFace1); Handle_AIS_TexturedShape aTFace2 = Texturize(aFaces(21), "carrelage1.gif", 1, 1, 3, 2); DISP(aTFace2); getViewer()->Update(); }
RefPtr<API::Object> WebProcessProxy::transformHandlesToObjects(API::Object* object) { struct Transformer final : UserData::Transformer { Transformer(WebProcessProxy& webProcessProxy) : m_webProcessProxy(webProcessProxy) { } virtual bool shouldTransformObject(const API::Object& object) const override { switch (object.type()) { case API::Object::Type::FrameHandle: return static_cast<const API::FrameHandle&>(object).isAutoconverting(); case API::Object::Type::PageHandle: return static_cast<const API::PageHandle&>(object).isAutoconverting(); case API::Object::Type::PageGroupHandle: #if PLATFORM(COCOA) case API::Object::Type::ObjCObjectGraph: #endif return true; default: return false; } } virtual RefPtr<API::Object> transformObject(API::Object& object) const override { switch (object.type()) { case API::Object::Type::FrameHandle: ASSERT(static_cast<API::FrameHandle&>(object).isAutoconverting()); return m_webProcessProxy.webFrame(static_cast<API::FrameHandle&>(object).frameID()); case API::Object::Type::PageGroupHandle: return WebPageGroup::get(static_cast<API::PageGroupHandle&>(object).webPageGroupData().pageGroupID); case API::Object::Type::PageHandle: ASSERT(static_cast<API::PageHandle&>(object).isAutoconverting()); return m_webProcessProxy.webPage(static_cast<API::PageHandle&>(object).pageID()); #if PLATFORM(COCOA) case API::Object::Type::ObjCObjectGraph: return m_webProcessProxy.transformHandlesToObjects(static_cast<ObjCObjectGraph&>(object)); #endif default: return &object; } } WebProcessProxy& m_webProcessProxy; }; return UserData::transform(object, Transformer(*this)); }
void Scrollable::draw(Canvas* c, const Allocation& a) const { c->damage(0, 0, width_, height_); Extension e; e.set(c, a); c->push_clipping(); c->push_transform(); c->transformer(Transformer()); c->clip_rect(e.left(), e.bottom(), e.right(), e.top()); Patch::draw(c, a); c->pop_transform(); c->pop_clipping(); }
void XYView::scene2view(const Allocation& a) const { float m00 = width()/a.x_allotment().span(); float m11 = height()/a.y_allotment().span(); //takes a canvas transformation from scene to parent glyph coordinates // transforms vectors from original to xyview XYView* xyv = (XYView*)this; xyv->scene2viewparent_ = Transformer( m00, 0, 0, m11, left() - a.left()*m00, bottom() - a.bottom()*m11 ); //print_t("scene2view", scene2viewparent_); }
RefPtr<API::Object> WebProcess::transformObjectsToHandles(API::Object* object) { struct Transformer final : UserData::Transformer { virtual bool shouldTransformObject(const API::Object& object) const override { switch (object.type()) { case API::Object::Type::BundleFrame: case API::Object::Type::BundlePage: case API::Object::Type::BundlePageGroup: #if PLATFORM(COCOA) case API::Object::Type::ObjCObjectGraph: #endif return true; default: return false; } } virtual RefPtr<API::Object> transformObject(API::Object& object) const override { switch (object.type()) { case API::Object::Type::BundleFrame: return API::FrameHandle::createAutoconverting(static_cast<const WebFrame&>(object).frameID()); case API::Object::Type::BundlePage: return API::PageHandle::createAutoconverting(static_cast<const WebPage&>(object).pageID()); case API::Object::Type::BundlePageGroup: { WebPageGroupData pageGroupData; pageGroupData.pageGroupID = static_cast<const WebPageGroupProxy&>(object).pageGroupID(); return API::PageGroupHandle::create(WTF::move(pageGroupData)); } #if PLATFORM(COCOA) case API::Object::Type::ObjCObjectGraph: return transformObjectsToHandles(static_cast<ObjCObjectGraph&>(object)); #endif default: return &object; } } }; return UserData::transform(object, Transformer()); }
void Transformer( LPTFORM lpTForm, LPPOINT lpPoint, LPLONG lpx, LPLONG lpy ) /***********************************************************************/ { Transformer( lpTForm, lpPoint, ( LPINT )lpx, ( LPINT )lpy ); }
WRATHLayerIntermediateTransformation::handle WRATHLayerItemNodeTranslateValues:: create_pre_transformer(const WRATHTripleBufferEnabler::handle &tr) { return WRATHNew Transformer(tr, this); }
//======================================================================= // Returns the number of points that GetData would use given the same // iPointsToUse. //======================================================================= int CPoly::SizeData(int iPointsToUse, LPTFORM lpTForm) //======================================================================= { int iout=0; // points output POINT curve[BEZIER_IN]; int i, count, iTempCurPointPos; int curpoint = CurPoint; int curpointpos = CurPointPos; if (!Num) goto Done; // be sure we are at the begining if (curpointpos < 0) curpointpos = curpoint = 0; // skip to begining or end of bezier if (i=get_curve_index(curpointpos)) { if (i==1) curpointpos--; else if (i<BEZIER_IN) { curpointpos += BEZIER_IN-i; curpoint += BEZIER_IN-i; } } // need to do all points? if (iPointsToUse < 0) iPointsToUse = bClosed ? Num : (Num - CurPoint - 1); count = iPointsToUse; // points remaining while( count >= 0) { // wrap if (curpointpos >= EntriesUsed) { curpointpos = 0; curpoint = 0; if (!bClosed) goto Done; if (lpPoints[curpointpos].x == BEZIER_MARKER) { iout++; // for the joiner count--; continue; } } if (lpPoints[curpointpos].x == BEZIER_MARKER) // bezier { // get bezier points curpointpos++; curve[0] = lpPoints[curpointpos++]; curve[1] = lpPoints[curpointpos++]; curve[2] = lpPoints[curpointpos++]; curpoint += 3; count -= 3; iTempCurPointPos = curpointpos; if (iTempCurPointPos >= EntriesUsed) iTempCurPointPos = 0; if (lpPoints[iTempCurPointPos].x == BEZIER_MARKER) curve[3] = lpPoints[iTempCurPointPos+1]; else { curve[3] = lpPoints[iTempCurPointPos++]; curpointpos++; curpoint++; count--; } // curve expansion may be dependant on resolution if (lpTForm) { Transformer(lpTForm, &curve[0], &curve[0].x, &curve[0].y); Transformer(lpTForm, &curve[1], &curve[1].x, &curve[1].y); Transformer(lpTForm, &curve[2], &curve[2].x, &curve[2].y); Transformer(lpTForm, &curve[3], &curve[3].x, &curve[3].y); } // expand curve i = CurveToPoints(curve, BEZIER_MARKER, NULL); iout += i; } else { // point only iout++; count--; curpointpos++; curpoint++; } } Done: return(iout); }
//======================================================================= // LPPOINT CPoly::GetData(LPPOINT lpStorage, LPINT lpiSize) // lpStorage: An array of points, filled by this fn. // iStorage: The size of lpStorage in points. // iPointsToUse: The number of polygon points to attempt. -1 for // entire shape from current point (closed shapes will wrap). // Any bezier which is started will be completed. // lpTForm: Applys the given tform to the data- can be null. (Note: // the current code assumes rotation and translation only!) // lpiOut: Upon exit it will contain the number of pixel points written. // lpStorage: Optional. Memory to put the data into. // iStorage: Optional. On call should have the size of lpStorage. On Return // It will contain the number of polygon points expanded. // // This function expands any curves into points and puts the new // polygon segment into lpStorage. // The fn wrorks from, and will update, the current point. // // Note: SizeData must mirror this function. //======================================================================= LPPOINT CPoly::GetData(int iPointsToUse, LPTFORM lpTForm, LPINT lpiOut, LPPOINT lpStorage, LPINT lpiStorage) //======================================================================= { int iout=0; // points output LPPOINT lpout; POINT curve[BEZIER_IN]; int i, count, iStorage, iTempCurPointPos; if (lpiStorage) { iStorage = *lpiStorage; *lpiStorage = 0; } if (!iPointsToUse || !Num || (lpStorage && !lpiStorage)) goto ExitNoneDone; if (!lpStorage) { iStorage = SizeData(iPointsToUse, lpTForm); iStorage += MAX_BEZIER_OUT + 1; lpStorage = (LPPOINT)Alloc(sizeof(POINT)*(iStorage + 1)); if (!lpStorage) goto ExitNoneDone; } // be sure we are at the begining if (CurPointPos < 0) CurPointPos = CurPoint = 0; // skip to begining or end of bezier if (i=get_curve_index(CurPointPos)) { if (i==1) CurPointPos--; else if (i<BEZIER_IN) { CurPointPos += BEZIER_IN-i; CurPoint += BEZIER_IN-i; } } // need to do all points? if (iPointsToUse < 0) iPointsToUse = bClosed ? Num : (Num - CurPoint - 1); count = iPointsToUse; // points remaining lpout = lpStorage; while( count >= 0 && iout < iStorage) { // wrap if (CurPointPos >= EntriesUsed) { CurPointPos = 0; CurPoint = 0; if (!bClosed) break; // connect end with current point (if bezier) if (lpPoints[CurPointPos].x == BEZIER_MARKER) { // add the start of bezier... but dont update current position if (lpTForm) Transformer(lpTForm, &lpPoints[CurPointPos+1], &lpout->x, &lpout->y); else *lpout = lpPoints[CurPointPos+1]; lpout++; iout++; count--; continue; } } if (lpPoints[CurPointPos].x == BEZIER_MARKER) // bezier { // be sure we can handle it if (iout+MAX_BEZIER_OUT > iStorage) break; // get bezier points CurPointPos++; curve[0] = lpPoints[CurPointPos++]; // start curve[1] = lpPoints[CurPointPos++]; // handle1 curve[2] = lpPoints[CurPointPos++]; // handle2 CurPoint += 3; count -= 3; // dont do wrap now... save for next time iTempCurPointPos = CurPointPos; if (iTempCurPointPos >= EntriesUsed) iTempCurPointPos = 0; if (lpPoints[iTempCurPointPos].x == BEZIER_MARKER) curve[3] = lpPoints[iTempCurPointPos+1]; else { curve[3] = lpPoints[iTempCurPointPos++]; CurPointPos++; CurPoint++; count--; } if (lpTForm) { Transformer(lpTForm, &curve[0], &curve[0].x, &curve[0].y); Transformer(lpTForm, &curve[1], &curve[1].x, &curve[1].y); Transformer(lpTForm, &curve[2], &curve[2].x, &curve[2].y); Transformer(lpTForm, &curve[3], &curve[3].x, &curve[3].y); } // expand curve i = CurveToPoints(curve, BEZIER_MARKER, lpout); iout += i; lpout += i; } else { // point only if (lpTForm) Transformer(lpTForm, &lpPoints[CurPointPos], &lpout->x, &lpout->y); else *lpout = lpPoints[CurPointPos]; lpout++; iout++; count--; CurPointPos++; CurPoint++; } } // wrap if (CurPointPos >= EntriesUsed) { CurPointPos = 0; CurPoint = 0; } if (lpiStorage) *lpiStorage = iPointsToUse - count; ExitNoneDone: // ensure that current point isn't a bezier marker if (WITHIN(CurPointPos, 0, EntriesUsed-1)) { if (lpPoints[CurPointPos].x == BEZIER_MARKER) CurPointPos++; } *lpiOut = iout; return(lpStorage); }
LOCAL BOOL point_tform(LPPOINT lpPoint, WORD wFlags, LPTFORM lpTForm) { Transformer(lpTForm, lpPoint, &lpPoint->x, &lpPoint->y); return(TRUE); }
inline transform_iterator<Iterator, Transformer> make_transform_iterator(Iterator const& it) { return transform_iterator<Iterator, Transformer>(it, Transformer()); }