source: trunk/source/digits_hits/utils/src/G4VScoreColorMap.cc @ 978

Last change on this file since 978 was 850, checked in by garnier, 16 years ago

geant4.8.2 beta

File size: 3.9 KB
Line 
1//
2// ********************************************************************
3// * License and Disclaimer                                           *
4// *                                                                  *
5// * The  Geant4 software  is  copyright of the Copyright Holders  of *
6// * the Geant4 Collaboration.  It is provided  under  the terms  and *
7// * conditions of the Geant4 Software License,  included in the file *
8// * LICENSE and available at  http://cern.ch/geant4/license .  These *
9// * include a list of copyright holders.                             *
10// *                                                                  *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work  make  any representation or  warranty, express or implied, *
14// * regarding  this  software system or assume any liability for its *
15// * use.  Please see the license in the file  LICENSE  and URL above *
16// * for the full disclaimer and the limitation of liability.         *
17// *                                                                  *
18// * This  code  implementation is the result of  the  scientific and *
19// * technical work of the GEANT4 collaboration.                      *
20// * By using,  copying,  modifying or  distributing the software (or *
21// * any work based  on the software)  you  agree  to acknowledge its *
22// * use  in  resulting  scientific  publications,  and indicate your *
23// * acceptance of all terms of the Geant4 Software license.          *
24// ********************************************************************
25//
26//
27// $Id: G4VScoreColorMap.cc,v 1.3 2008/02/14 10:45:12 akimura Exp $
28// GEANT4 tag $Name: HEAD $
29//
30
31#include "G4VScoreColorMap.hh"
32
33#include "G4VVisManager.hh"
34#include "G4VisAttributes.hh"
35#include "G4Text.hh"
36#include "G4Circle.hh"
37#include "G4Polyline.hh"
38#include "G4Colour.hh"
39
40G4VScoreColorMap::G4VScoreColorMap(G4String mName)
41:fName(mName),ifFloat(true),fMinVal(0.),fMaxVal(DBL_MAX)
42{;}
43
44G4VScoreColorMap::~G4VScoreColorMap()
45{;}
46
47void G4VScoreColorMap::DrawColorChart(G4int _nPoint) {
48
49  fVisManager = G4VVisManager::GetConcreteInstance();
50  if(!fVisManager) {
51    G4cerr << "G4VScoringMesh::DrawColorChart(): no visualization system" << G4endl;
52    return;
53  }
54
55  DrawColorChartBar(_nPoint);
56  DrawColorChartText(_nPoint);
57}
58
59void G4VScoreColorMap::DrawColorChartBar(G4int _nPoint) {
60
61  G4double min = this->GetMin();
62  G4double max = this->GetMax();
63  G4double smin = -0.89, smax = smin + 0.05*(_nPoint)*0.83, step=0.001;
64  G4double c[4];
65  for(G4double y = smin; y < smax; y+=step) {
66    G4double ra = (y-smin)/(smax-smin), rb = 1.-ra;
67    G4Polyline line;
68    line.push_back(G4Point3D(-0.96, y, 0.));
69    line.push_back(G4Point3D(-0.91, y, 0.));
70    this->GetMapColor((ra*max+rb*min)/(ra+rb), c);
71    G4Colour col(c[0], c[1], c[2]);
72    G4VisAttributes att(col);
73    line.SetVisAttributes(&att);
74    fVisManager->Draw2D(line);
75  }
76
77}
78void G4VScoreColorMap::DrawColorChartText(G4int _nPoint) {
79  G4double min = this->GetMin();
80  G4double max = this->GetMax();
81  G4double c[4];
82  G4Colour black(0., 0., 0.);
83  for(int n = 0; n < _nPoint; n++) {
84    G4double a = n/(_nPoint-1.), b = 1.-a;
85    G4double v = (a*max + b*min)/(a+b);
86    // background color
87    for(int l = 0; l < 21; l++) {
88      G4Polyline line;
89      line.push_back(G4Point3D(-0.908, -0.905+0.05*n+0.002*l, 0.));
90      line.push_back(G4Point3D(-0.705, -0.905+0.05*n+0.002*l, 0.));
91      G4VisAttributes attblack(black);
92      line.SetVisAttributes(&attblack);
93      fVisManager->Draw2D(line);
94    }
95    // text
96    char cstring[80]; 
97    std::sprintf(cstring, "%8.2e", v);
98    G4String value(cstring);
99    G4Text text(value, G4Point3D(-0.9, -0.9+0.05*n, 0));
100    G4double size = 12.;
101    text.SetScreenSize(size);
102    this->GetMapColor(v, c);
103    G4Colour color(c[0], c[1], c[2]);
104    G4VisAttributes att(color);
105    text.SetVisAttributes(&att);
106
107    fVisManager->Draw2D(text);
108  }
109}
Note: See TracBrowser for help on using the repository browser.