00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "TViewer3DPad.h"
00013 #include "TVirtualPad.h"
00014 #include "TView.h"
00015 #include "TBuffer3D.h"
00016 #include "TBuffer3DTypes.h"
00017
00018 #include <assert.h>
00019
00020
00021
00022
00023
00024
00025
00026 ClassImp(TViewer3DPad)
00027
00028
00029 Bool_t TViewer3DPad::PreferLocalFrame() const
00030 {
00031
00032
00033 return kFALSE;
00034 }
00035
00036
00037
00038 void TViewer3DPad::BeginScene()
00039 {
00040
00041 assert(!fBuilding);
00042
00043
00044 TView *view = fPad.GetView();
00045 if (!view) {
00046 view = TView::CreateView(1,0,0);
00047 if (!view) {
00048 assert(kFALSE);
00049 return;
00050 }
00051 fPad.SetView(view);
00052
00053
00054 view->SetAutoRange(kTRUE);
00055 }
00056
00057 fBuilding = kTRUE;
00058 }
00059
00060
00061 void TViewer3DPad::EndScene()
00062 {
00063
00064 assert(fBuilding);
00065
00066
00067 TView *view = fPad.GetView();
00068 if (view) {
00069 if (view->GetAutoRange()) {
00070 view->SetAutoRange(kFALSE);
00071 fPad.Paint();
00072 }
00073 }
00074
00075 fBuilding = kFALSE;
00076 }
00077
00078
00079 Int_t TViewer3DPad::AddObject(const TBuffer3D & buffer, Bool_t * addChildren)
00080 {
00081
00082
00083
00084
00085
00086
00087 if (addChildren) {
00088 *addChildren = kTRUE;
00089 }
00090
00091 TView * view = fPad.GetView();
00092 if (!view) {
00093 assert(kFALSE);
00094 return TBuffer3D::kNone;
00095 }
00096
00097 UInt_t reqSections = TBuffer3D::kCore|TBuffer3D::kRawSizes|TBuffer3D::kRaw;
00098 if (!buffer.SectionsValid(reqSections)) {
00099 return reqSections;
00100 }
00101
00102 UInt_t i;
00103 Int_t i0, i1, i2;
00104
00105
00106 if (view->GetAutoRange()) {
00107 Double_t x0, y0, z0, x1, y1, z1;
00108
00109 x0 = x1 = buffer.fPnts[0];
00110 y0 = y1 = buffer.fPnts[1];
00111 z0 = z1 = buffer.fPnts[2];
00112 for (i=1; i<buffer.NbPnts(); i++) {
00113 i0 = 3*i; i1 = i0+1; i2 = i0+2;
00114 x0 = buffer.fPnts[i0] < x0 ? buffer.fPnts[i0] : x0;
00115 y0 = buffer.fPnts[i1] < y0 ? buffer.fPnts[i1] : y0;
00116 z0 = buffer.fPnts[i2] < z0 ? buffer.fPnts[i2] : z0;
00117 x1 = buffer.fPnts[i0] > x1 ? buffer.fPnts[i0] : x1;
00118 y1 = buffer.fPnts[i1] > y1 ? buffer.fPnts[i1] : y1;
00119 z1 = buffer.fPnts[i2] > z1 ? buffer.fPnts[i2] : z1;
00120 }
00121 view->SetRange(x0,y0,z0,x1,y1,z1,2);
00122 }
00123
00124 else {
00125
00126 if (buffer.fTransparency > 50) {
00127 return TBuffer3D::kNone;
00128 }
00129 if (buffer.Type()== TBuffer3DTypes::kMarker ) {
00130 Double_t pndc[3], temp[3];
00131 for (i=0; i<buffer.NbPnts(); i++) {
00132 for ( i0=0; i0<3; i0++ ) temp[i0] = buffer.fPnts[3*i+i0];
00133 view->WCtoNDC(temp, pndc);
00134 fPad.PaintPolyMarker(1, &pndc[0], &pndc[1]);
00135 }
00136 } else {
00137 for (i=0; i<buffer.NbSegs(); i++) {
00138 i0 = 3*buffer.fSegs[3*i+1];
00139 Double_t *ptpoints_0 = &(buffer.fPnts[i0]);
00140 i0 = 3*buffer.fSegs[3*i+2];
00141 Double_t *ptpoints_3 = &(buffer.fPnts[i0]);
00142 fPad.PaintLine3D(ptpoints_0, ptpoints_3);
00143 }
00144 }
00145 }
00146
00147 return TBuffer3D::kNone;
00148 }
00149
00150
00151 Int_t TViewer3DPad::AddObject(UInt_t , const TBuffer3D & buffer, Bool_t * addChildren)
00152 {
00153
00154 return AddObject(buffer,addChildren);
00155 }
00156
00157
00158
00159 Bool_t TViewer3DPad::OpenComposite(const TBuffer3D & , Bool_t * )
00160 {
00161
00162
00163 return kTRUE;
00164 };
00165
00166
00167 void TViewer3DPad::CloseComposite()
00168 {};
00169
00170
00171 void TViewer3DPad::AddCompositeOp(UInt_t )
00172 {};