7fd59977 |
1 | #include "stdafx.h" |
2 | |
3 | #include "Sample2D_Image.h" |
4 | #include <Graphic2d_View.hxx> |
5 | |
6 | IMPLEMENT_STANDARD_HANDLE(Sample2D_Image,AIS2D_InteractiveObject) |
7 | IMPLEMENT_STANDARD_RTTIEXT(Sample2D_Image,AIS2D_InteractiveObject) |
8 | |
9 | #include <Graphic2d_ImageFile.hxx> |
10 | Sample2D_Image::Sample2D_Image(OSD_File& aFile, |
11 | const Quantity_Length X, // = 0.0 |
12 | const Quantity_Length Y, // = 0.0 |
13 | const Quantity_Length adx, // = 0.0 |
14 | const Quantity_Length ady, // = 0.0 |
15 | const Aspect_CardinalPoints aTypeOfPlacement,// = Aspect_CP_Center |
16 | const Quantity_Factor aScale) // = 1.0 |
17 | :AIS2D_InteractiveObject() |
18 | { |
19 | |
20 | myFile = aFile ; |
21 | myX = X ; |
22 | myY = Y ; |
23 | myDx = adx ; |
24 | myDy = ady ; |
25 | myTypeOfPlacement = aTypeOfPlacement ; |
26 | myScale = aScale ; |
27 | |
28 | } |
29 | |
30 | Sample2D_Image::Sample2D_Image(Standard_CString& aFileName, |
31 | const Quantity_Length X, // = 0.0 |
32 | const Quantity_Length Y, // = 0.0 |
33 | const Quantity_Length adx, // = 0.0 |
34 | const Quantity_Length ady, // = 0.0 |
35 | const Aspect_CardinalPoints aTypeOfPlacement,// = Aspect_CP_Center |
36 | const Quantity_Factor aScale) // = 1.0) |
37 | :AIS2D_InteractiveObject() |
38 | { |
39 | TCollection_AsciiString TheDependentName(aFileName); |
40 | OSD_Path aPath(TheDependentName); |
41 | OSD_File aFile(aPath); |
42 | myFile = aFile ; |
43 | myX = X ; |
44 | myY = Y ; |
45 | myDx = adx ; |
46 | myDy = ady ; |
47 | myTypeOfPlacement = aTypeOfPlacement ; |
48 | myScale = aScale ; |
49 | |
50 | //Attach a graphic view to this object |
51 | } |
52 | |
53 | void Sample2D_Image::SetContext(const Handle(AIS2D_InteractiveContext)& theContext) |
54 | { |
55 | |
56 | if(theContext.IsNull() || theContext->CurrentViewer().IsNull()) return; |
57 | |
58 | AIS2D_InteractiveObject::SetContext(theContext); |
59 | Graphic2d_GraphicObject::SetView(theContext->CurrentViewer()->View()); |
60 | |
61 | |
62 | Handle(Graphic2d_ImageFile) aGraphic2dImageFile = new Graphic2d_ImageFile ( |
63 | this, |
64 | myFile, |
65 | myX, |
66 | myY, |
67 | myDx, |
68 | myDy, |
69 | myTypeOfPlacement, |
70 | myScale); |
71 | if (myIsZoomable) |
72 | aGraphic2dImageFile->SetZoomable(Standard_True); |
73 | } |
74 | |
75 | Standard_CString Sample2D_Image::GetFileName() const |
76 | { |
77 | static OSD_Path aPath; |
78 | myFile.Path(aPath); |
79 | return aPath.Name().ToCString(); |
80 | } |
81 | |
82 | void Sample2D_Image::SetFileName(const Standard_CString aFileName) |
83 | { |
84 | TCollection_AsciiString TheDependentName(aFileName); |
85 | OSD_Path aPath(TheDependentName); |
86 | OSD_File aFile(aPath); |
87 | myFile = aFile; |
88 | } |
89 | |
90 | |
91 | |
92 | |