OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimColorProperty.cpp
Go to the documentation of this file.
1 //*******************************************************************
2 //
3 // License: See top level LICENSE.txt file.
4 //
5 // Author: Garrett Potts (gpotts@imagelinks.com)
6 //
7 //*************************************************************************
8 // $Id: ossimColorProperty.cpp 13667 2008-10-02 19:59:55Z gpotts $
9 #include <sstream>
11 
12 RTTI_DEF1(ossimColorProperty, "ossimColorProperty", ossimProperty);
13 
15  const ossimRgbVector& value)
16  :ossimProperty(name),
17  theValue(value)
18 {
19 }
20 
22  :ossimProperty(rhs),
23  theValue(rhs.theValue)
24 {
25 }
26 
28 {
29 }
30 
32 {
33  return new ossimColorProperty(*this);
34 }
35 
37 {
39 
40  const ossimColorProperty* rhsPtr = dynamic_cast<const ossimColorProperty*>(&rhs);
41  if(rhsPtr)
42  {
43  theValue = rhsPtr->theValue;
44  }
45  else
46  {
47  setValue(rhs.valueToString());
48  }
49 
50  return *this;
51 }
52 
54 {
55  bool result = false;
56  std::vector<ossimString> splitArray;
57 
58  value.split(splitArray, " ");
59  if(splitArray.size() == 3)
60  {
61  int r,g,b;
62  r = splitArray[0].toInt32();
63  g = splitArray[1].toInt32();
64  b = splitArray[2].toInt32();
65  result = true;
66 
67  theValue = ossimRgbVector(r,g,b);
68  }
69 
70  return result;
71 }
72 
74 {
75  ostringstream out;
76 
77  out << (int)theValue.getR() << " " << (int)theValue.getG() << " " << (int)theValue.getB() << endl;
78 
79  valueResult = out.str().c_str();
80 }
81 
83 {
84  return theValue;
85 }
86 
88 {
89  theValue = value;
90 }
91 
93 {
94  return theValue.getR();
95 }
96 
98 {
99  return theValue.getG();
100 }
101 
103 {
104  return theValue.getB();
105 }
106 
108 {
109  theValue.setR(r);
110 }
111 
113 {
114  theValue.setG(g);
115 }
116 
118 {
119  theValue.setB(b);
120 }
ossimRgbVector theValue
virtual void valueToString(ossimString &valueResult) const =0
ossimColorProperty(const ossimString &name=ossimString(""), const ossimRgbVector &value=ossimRgbVector(0, 0, 0))
void setGreen(ossim_uint8 r)
void setRed(ossim_uint8 r)
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition: ossimIosFwd.h:35
unsigned char getR() const
void setBlue(ossim_uint8 r)
void setR(unsigned char R)
void split(std::vector< ossimString > &result, const ossimString &separatorList, bool skipBlankFields=false) const
Splits this string into a vector of strings (fields) using the delimiter list specified.
virtual const ossimProperty & assign(const ossimProperty &rhs)
virtual ossimString valueToString() const
void setB(unsigned char B)
ossim_uint8 getRed() const
const ossimRgbVector & getColor() const
ossim_uint8 getGreen() const
unsigned char getB() const
virtual bool setValue(const ossimString &value)
virtual ossimObject * dup() const
void setG(unsigned char G)
unsigned char getG() const
virtual const ossimProperty & assign(const ossimProperty &rhs)
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string&#39;s contents...
Definition: ossimString.h:396
void setColor(const ossimRgbVector &value)
unsigned char ossim_uint8
ossim_uint8 getBlue() const
RTTI_DEF1(ossimColorProperty, "ossimColorProperty", ossimProperty)