File: starlayer.cpp

package info (click to toggle)
munipack 0.6.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 33,104 kB
  • sloc: cpp: 29,677; sh: 4,909; f90: 2,872; makefile: 278; python: 140; xml: 72; awk: 12
file content (74 lines) | stat: -rw-r--r-- 2,080 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*

  Star layer

  Copyright © 2019 F.Hroch (hroch@physics.muni.cz)

  This file is part of Munipack.

  Munipack is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  Munipack is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with Munipack.  If not, see <http://www.gnu.org/licenses/>.

*/

#include "xmunipack.h"
#include <wx/wx.h>
#include <vector>

using namespace std;

MuniStarLayer::MuniStarLayer():
  gold(wxColour(255,215,0,240)),DarkOrange2(wxColour(238,118,0)),hwhm(1) {}

MuniLayer MuniStarLayer::GetLayer() const
{
  MuniLayer layer(ID_PHOTOMETRY,objects);
  return layer;
}


void MuniStarLayer::DrawObjects(const vector<double>& xcoo,
				const vector<double>& ycoo,
				const vector<double>& flux)
{
  wxASSERT(xcoo.size() == ycoo.size() && flux.size() == xcoo.size());

  objects.push_back(new MuniDrawFont(*wxNORMAL_FONT,gold));
  objects.push_back(new MuniDrawPen(wxPen(gold,1.8)));
  objects.push_back(new MuniDrawBrush(wxColour(90,90,255,190)));

  double fmax = 0.0;
  for(size_t i = 0; i < flux.size(); i++)
    if( flux[i] > 0.0 && flux[i] > fmax )
      fmax = flux[i];

  double fmin = fmax;
  for(size_t i = 0; i < flux.size(); i++)
    if( flux[i] > 0.0 && flux[i] < fmin )
      fmin = flux[i];

  const double size1 = hwhm > 1 ? 3*hwhm : 3;
  const double size2 = 2.0;
  const double sizec = 3.0;
  double r1 = (size1 - size2)/(fmax - fmin);

  for(size_t i = 0; i < xcoo.size(); i++) {

    if( flux[i] > 0.0 ) {
      double r = r1*(flux[i] - fmin) + size2;
      objects.push_back(new MuniDrawCircle(xcoo[i],ycoo[i],r));
    }
    else
      objects.push_back(new MuniDrawCross(xcoo[i],ycoo[i],sizec));
  }
}