LCOV - code coverage report
Current view: top level - imageanalysis/Annotations - AnnSymbol.cc (source / functions) Hit Total Coverage
Test: ctest_coverage.info Lines: 0 79 0.0 %
Date: 2023-11-06 10:06:49 Functions: 0 10 0.0 %

          Line data    Source code
       1             : //# GaussianShape.cc:
       2             : //# Copyright (C) 1998,1999,2000
       3             : //# Associated Universities, Inc. Washington DC, USA.
       4             : //#
       5             : //# This library is free software; you can redistribute it and/or modify it
       6             : //# under the terms of the GNU Library General Public License as published by
       7             : //# the Free Software Foundation; either version 2 of the License, or (at your
       8             : //# option) any later version.
       9             : //#
      10             : //# This library is distributed in the hope that it will be useful, but WITHOUT
      11             : //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
      12             : //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
      13             : //# License for more details.
      14             : //#
      15             : //# You should have received a copy of the GNU Library General Public License
      16             : //# along with this library; if not, write to the Free Software Foundation,
      17             : //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
      18             : //#
      19             : //# Correspondence concerning AIPS++ should be addressed as follows:
      20             : //#        Internet email: aips2-request@nrao.edu.
      21             : //#        Postal address: AIPS++ Project Office
      22             : //#                        National Radio Astronomy Observatory
      23             : //#                        520 Edgemont Road
      24             : //#                        Charlottesville, VA 22903-2475 USA
      25             : //#
      26             : 
      27             : #include <imageanalysis/Annotations/AnnSymbol.h>
      28             : 
      29             : using namespace casacore;
      30             : namespace casa {
      31             : 
      32             : std::map<Char, AnnSymbol::Symbol> AnnSymbol::_symbolMap;
      33             : 
      34             : const String AnnSymbol::_class = "AnnSymbol";
      35             : 
      36           0 : AnnSymbol::AnnSymbol(
      37             :         const Quantity& x, const Quantity& y,
      38             :         const String& dirRefFrameString,
      39             :         const CoordinateSystem& csys,
      40             :         const Char symbolChar,
      41             :         const Quantity& beginFreq,
      42             :         const Quantity& endFreq,
      43             :         const String& freqRefFrame,
      44             :         const String& dopplerString,
      45             :         const Quantity& restfreq,
      46             :         const Vector<Stokes::StokesTypes>& stokes
      47           0 : ) : AnnotationBase(
      48             :                 SYMBOL, dirRefFrameString, csys, beginFreq, endFreq,
      49             :                 freqRefFrame, dopplerString, restfreq, stokes
      50             :         ),
      51             :         _inputDirection(AnnotationBase::Direction(1)),
      52           0 :         _symbolChar(symbolChar) {
      53           0 :         _init(x, y);
      54           0 :         if ((_symbol = charToSymbol(symbolChar)) == UNKNOWN) {
      55             :                 throw AipsError(
      56           0 :                         String(symbolChar)
      57           0 :                                 + " does not correspond to a known symbol"
      58           0 :                 );
      59             :         }
      60           0 : }
      61             : 
      62           0 : AnnSymbol::AnnSymbol(
      63             :         const Quantity& x, const Quantity& y,
      64             :         const CoordinateSystem& csys,
      65             :         const Symbol symbol,
      66             :         const Vector<Stokes::StokesTypes>& stokes
      67           0 : ) : AnnotationBase(SYMBOL, csys, stokes),
      68             :         _inputDirection(AnnotationBase::Direction(1)),
      69           0 :         _symbol(symbol) {
      70           0 :         _init(x, y);
      71           0 :         _symbolChar = symbolToChar(_symbol);
      72           0 : }
      73             : 
      74           0 : AnnSymbol& AnnSymbol::operator= (
      75             :         const AnnSymbol& other
      76             : ) {
      77           0 :     if (this == &other) {
      78           0 :         return *this;
      79             :     }
      80           0 :     AnnotationBase::operator=(other);
      81           0 :     _inputDirection.resize(other._inputDirection.nelements());
      82           0 :     _inputDirection = other._inputDirection;
      83           0 :     _symbol = other._symbol;
      84           0 :     _symbolChar = other._symbolChar;
      85           0 :     return *this;
      86             : }
      87             : 
      88           0 : void AnnSymbol::_init(const Quantity& x, const Quantity& y) {
      89           0 :         if (_symbolMap.size() == 0) {
      90           0 :                 _initMap();
      91             :         }
      92           0 :         _inputDirection[0].first = x;
      93           0 :         _inputDirection[0].second = y;
      94           0 :         _checkAndConvertDirections(String(__FUNCTION__), _inputDirection);
      95           0 : }
      96             : 
      97           0 : MDirection AnnSymbol::getDirection() const {
      98           0 :         return getConvertedDirections()[0];
      99             : }
     100             : 
     101           0 : AnnSymbol::Symbol AnnSymbol::getSymbol() const {
     102           0 :         return _symbol;
     103             : }
     104             : 
     105           0 : void AnnSymbol::_initMap() {
     106           0 :         _symbolMap['.'] = POINT;
     107           0 :         _symbolMap[','] = PIXEL;
     108           0 :         _symbolMap['o'] = CIRCLE;
     109           0 :         _symbolMap['v'] = TRIANGLE_DOWN;
     110           0 :         _symbolMap['^'] = TRIANGLE_UP;
     111           0 :         _symbolMap['<'] = TRIANGLE_LEFT;
     112           0 :         _symbolMap['>'] = TRIANGLE_RIGHT;
     113           0 :         _symbolMap['1'] = TRI_DOWN;
     114           0 :         _symbolMap['2'] = TRI_UP;
     115           0 :         _symbolMap['3'] = TRI_LEFT;
     116           0 :         _symbolMap['4'] = TRI_RIGHT;
     117           0 :         _symbolMap['s'] = SQUARE;
     118           0 :         _symbolMap['p'] = PENTAGON;
     119           0 :         _symbolMap['*'] = STAR;
     120           0 :         _symbolMap['h'] = HEXAGON1;
     121           0 :         _symbolMap['H'] = HEXAGON2;
     122           0 :         _symbolMap['+'] = PLUS;
     123           0 :         _symbolMap['x'] = X;
     124           0 :         _symbolMap['D'] = DIAMOND;
     125           0 :         _symbolMap['d'] = THIN_DIAMOND;
     126           0 :         _symbolMap['|'] = VLINE;
     127           0 :         _symbolMap['_'] = HLINE;
     128           0 : }
     129             : 
     130           0 : AnnSymbol::Symbol AnnSymbol::charToSymbol(
     131             :         const Char c
     132             : ) {
     133           0 :         if (_symbolMap.find(c) != _symbolMap.end()) {
     134           0 :                 return _symbolMap.at(c);
     135             :         }
     136             :         else {
     137           0 :                 return UNKNOWN;
     138             :         }
     139             : }
     140             : 
     141           0 : Char AnnSymbol::symbolToChar(const AnnSymbol::Symbol s) {
     142           0 :         for (
     143           0 :                 std::map<Char, Symbol>::const_iterator iter=_symbolMap.begin();
     144           0 :                 iter != _symbolMap.end(); iter++
     145             :         ) {
     146           0 :                 if (s == iter->second) {
     147           0 :                         return iter->first;
     148             :                 }
     149             :         }
     150           0 :         ostringstream oss;
     151           0 :         oss << _class << "::" << __FUNCTION__
     152           0 :                 << ": Logic error. No corresponding character found for symbol " << s;
     153           0 :         throw AipsError(oss.str());
     154             : }
     155             : 
     156           0 : ostream& AnnSymbol::print(ostream &os) const {
     157           0 :         os << "symbol [["
     158           0 :                 << _printDirection(_inputDirection[0].first, _inputDirection[0].second)
     159           0 :                 << "], " << _symbolChar << "]";
     160           0 :         _printPairs(os);
     161           0 :         return os;
     162             : }
     163             : 
     164             : 
     165             : }
     166             : 
     167             : 

Generated by: LCOV version 1.16