@@ -117,7 +117,7 @@ TASImage* Screenshot::ScaleImage(TASImage* image, UInt_t desiredWidth, UInt_t de
117117 return scaledImage;
118118}
119119
120- void Screenshot::perform (std::string fileName, o2::detectors::DetID::mask_t detectorsMask, int runNumber, int firstTFOrbit, std::string collisionTime)
120+ std::string Screenshot::perform (std::string fileName, o2::detectors::DetID::mask_t detectorsMask, int runNumber, int firstTFOrbit, std::string collisionTime)
121121{
122122 TEnv settings;
123123 ConfigurationManager::getInstance ().getConfig (settings);
@@ -159,68 +159,41 @@ void Screenshot::perform(std::string fileName, o2::detectors::DetID::mask_t dete
159159 const auto annotationStateBottom = MultiView::getInstance ()->getAnnotationBottom ()->GetState ();
160160 MultiView::getInstance ()->getAnnotationTop ()->SetState (TGLOverlayElement::kInvisible );
161161 MultiView::getInstance ()->getAnnotationBottom ()->SetState (TGLOverlayElement::kInvisible );
162-
163- TImage* view3dImage = MultiView::getInstance ()->getView (MultiView::EViews::View3d)->GetGLViewer ()->GetPictureUsingBB ();
164-
162+ TImage* view3dImage = MultiView::getInstance ()->getView (MultiView::EViews::View3d)->GetGLViewer ()->GetPictureUsingFBO (width * 0.65 , height * 0.95 );
165163 MultiView::getInstance ()->getAnnotationTop ()->SetState (annotationStateTop);
166164 MultiView::getInstance ()->getAnnotationBottom ()->SetState (annotationStateBottom);
167-
168- scaledImage = ScaleImage ((TASImage*)view3dImage, width * 0.65 , height * 0.95 , backgroundColorHex);
165+ CopyImage (image, (TASImage*)view3dImage, width * 0.015 , height * 0.025 , 0 , 0 , view3dImage->GetWidth (), view3dImage->GetHeight ());
169166 delete view3dImage;
170- if (scaledImage) {
171- CopyImage (image, scaledImage, width * 0.015 , height * 0.025 , 0 , 0 , scaledImage->GetWidth (), scaledImage->GetHeight ());
172- delete scaledImage;
173- }
174167
175- TImage* viewRphiImage = MultiView::getInstance ()->getView (MultiView::EViews::ViewRphi)->GetGLViewer ()->GetPictureUsingBB ( );
176- scaledImage = ScaleImage (( TASImage*)viewRphiImage, width * 0.3 , height * 0.45 , backgroundColorHex );
168+ TImage* viewRphiImage = MultiView::getInstance ()->getView (MultiView::EViews::ViewRphi)->GetGLViewer ()->GetPictureUsingFBO (width * 0.3 , height * 0.45 );
169+ CopyImage (image, ( TASImage*)viewRphiImage, width * 0.68 , height * 0.025 , 0 , 0 , viewRphiImage-> GetWidth (), viewRphiImage-> GetHeight () );
177170 delete viewRphiImage;
178- if (scaledImage) {
179- CopyImage (image, scaledImage, width * 0.68 , height * 0.025 , 0 , 0 , scaledImage->GetWidth (), scaledImage->GetHeight ());
180- delete scaledImage;
181- }
182171
183- TImage* viewZYImage = MultiView::getInstance ()->getView (MultiView::EViews::ViewZY)->GetGLViewer ()->GetPictureUsingBB ( );
184- scaledImage = ScaleImage (( TASImage*)viewZYImage, width * 0.3 , height * 0.45 , backgroundColorHex );
172+ TImage* viewZYImage = MultiView::getInstance ()->getView (MultiView::EViews::ViewZY)->GetGLViewer ()->GetPictureUsingFBO (width * 0.3 , height * 0.45 );
173+ CopyImage (image, ( TASImage*)viewZYImage, width * 0.68 , height * 0.525 , 0 , 0 , viewZYImage-> GetWidth (), viewZYImage-> GetHeight () );
185174 delete viewZYImage;
186- if (scaledImage) {
187- CopyImage (image, scaledImage, width * 0.68 , height * 0.525 , 0 , 0 , scaledImage->GetWidth (), scaledImage->GetHeight ());
188- delete scaledImage;
189- }
190175
191- bool logo = true ;
192- if (logo) {
193- TASImage* aliceLogo = new TASImage (settings.GetValue (" screenshot.logo.alice" , " alice-white.png" ));
194- if (aliceLogo->IsValid ()) {
195- double ratio = 1434 . / 1939 .;
196- aliceLogo->Scale (0.08 * width, 0.08 * width / ratio);
197- image->Merge (aliceLogo, " alphablend" , 20 , 20 );
198- }
199- delete aliceLogo;
176+ TASImage* aliceLogo = new TASImage (settings.GetValue (" screenshot.logo.alice" , " alice-white.png" ));
177+ if (aliceLogo->IsValid ()) {
178+ double ratio = (double )(aliceLogo->GetWidth ()) / (double )(aliceLogo->GetHeight ());
179+ aliceLogo->Scale (0.08 * width, 0.08 * width / ratio);
180+ image->Merge (aliceLogo, " alphablend" , 0.01 * width, 0.01 * width);
200181 }
182+ delete aliceLogo;
201183
202- int fontSize = 0.015 * height;
203- int textX;
204- int textLineHeight = 0.015 * height;
205- int textY;
206-
207- if (logo) {
208- TASImage* o2Logo = new TASImage (settings.GetValue (" screenshot.logo.o2" , " o2.png" ));
209- if (o2Logo->IsValid ()) {
210- double ratio = (double )(o2Logo->GetWidth ()) / (double )(o2Logo->GetHeight ());
211- int o2LogoX = 0.01 * width;
212- int o2LogoY = 0.01 * width;
213- int o2LogoSize = 0.04 * width;
214- o2Logo->Scale (o2LogoSize, o2LogoSize / ratio);
215- image->Merge (o2Logo, " alphablend" , o2LogoX, height - o2LogoSize / ratio - o2LogoY);
216- textX = o2LogoX + o2LogoSize + o2LogoX;
217- textY = height - o2LogoSize / ratio - o2LogoY;
218- } else {
219- textX = 229 ;
220- textY = 1926 ;
221- }
222- delete o2Logo;
184+ TASImage* o2Logo = new TASImage (settings.GetValue (" screenshot.logo.o2" , " o2.png" ));
185+ int o2LogoMarginX = 0.01 * width;
186+ int o2LogoMarginY = 0.01 * width;
187+ int o2LogoSize = 0.04 * width;
188+
189+ if (o2Logo->IsValid ()) {
190+ double ratio = (double )(o2Logo->GetWidth ()) / (double )(o2Logo->GetHeight ());
191+ o2Logo->Scale (o2LogoSize, o2LogoSize / ratio);
192+ image->Merge (o2Logo, " alphablend" , o2LogoMarginX, height - o2LogoSize / ratio - o2LogoMarginY);
223193 }
194+ delete o2Logo;
195+ int textX = o2LogoMarginX + o2LogoSize + o2LogoMarginX;
196+ int textY = height - o2LogoSize - o2LogoMarginY;
224197
225198 auto detectorsString = detectors::DetID::getNames (detectorsMask);
226199
@@ -233,14 +206,18 @@ void Screenshot::perform(std::string fileName, o2::detectors::DetID::mask_t dete
233206 }
234207
235208 image->BeginPaint ();
209+ int fontSize = 0.015 * height;
210+ int textLineHeight = 0.015 * height;
236211
237212 for (int i = 0 ; i < 4 ; i++) {
213+ lines.push_back (" " ); // guard for empty collision time
238214 image->DrawText (textX, textY + i * textLineHeight, lines[i].c_str (), fontSize, " #BBBBBB" , " FreeSansBold.otf" );
239215 }
240216 image->EndPaint ();
241217
242218 image->WriteImage (fileName.c_str (), TImage::kPng );
243219 delete image;
220+ return fileName; // saved screenshod file name
244221}
245222
246223} // namespace event_visualisation
0 commit comments