Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

vtkPalette.h

Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- 00002 * 00003 * $Id: vtkPalette.h,v 1.2 2004/06/12 20:01:23 xpxqx Exp $ 00004 * 00005 * Copyright (c) 2004 Sean McInerney 00006 * All rights reserved. 00007 * 00008 * See Copyright.txt or http://vtkextensions.sourceforge.net/Copyright.html 00009 * for details. 00010 * 00011 * This software is distributed WITHOUT ANY WARRANTY; without even 00012 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00013 * PURPOSE. See the above copyright notice for more information. 00014 * 00015 */ 00016 #ifndef VTK_PALETTE_H_ 00017 # define VTK_PALETTE_H_ 00018 # include "vtkPaletteElement.h" 00019 00020 VTK_EXTENSIONS_PALETTE_NAMESPACE_BEGIN 00021 00022 class vtkAbstractPaletteMaterial; 00023 class vtkPaletteColor; 00024 class vtkPaletteMaterial; 00025 class vtkPaletteElementHashMap; 00026 class vtkPaletteElementHashMapIterator; 00027 00039 class VTK_EXTENSIONS_PALETTE_EXPORT vtkPalette 00040 : public vtkPaletteElement 00041 { 00042 public: 00043 static vtkPalette* New (void); 00044 vtkTypeRevisionMacro (vtkPalette, vtkPaletteElement); 00045 void PrintSelf (ostream&, vtkIndent); 00046 00048 int GetType (void) const; 00049 00050 //BTX 00052 const vtkXMLChType* GetTagName (void) const; 00053 00055 const vtkXMLChType* GetFullName (void); 00056 //ETX 00057 00060 vtkGetXMLStringMacro(VersionAttr, vtkXMLChType); 00061 vtkSetXMLStringMacro(VersionAttr, vtkXMLChType); 00065 virtual vtkPalette* GetParent (void) const; 00066 00068 int IsRoot (void) const 00069 { return (this->Parent == NULL ? VTK_TRUE : VTK_FALSE); } 00070 00072 int IsLeaf (void) const { return VTK_FALSE; } 00073 00075 int IsEmpty (void) const; 00076 00078 vtkIdType GetSize (void) const; 00079 00081 vtkIdType GetCapacity (void) const; 00082 00084 vtkGetObjectMacro (Elements, vtkPaletteElementHashMap); 00085 00093 vtkPaletteElement* Find (const char* name) const; 00094 00104 int Find (const char* name, 00105 vtkPalette* & element); 00106 00107 int Find (const char* name, 00108 vtkPaletteColor* & element); 00109 00110 int Find (const char* name, 00111 vtkPaletteMaterial* & element); 00112 00113 int Find (const char* name, 00114 vtkAbstractPaletteMaterial* & element); 00125 vtkPaletteElement* FindInScope (const char* name) const; 00126 00136 int FindInScope (const char* name, 00137 vtkPalette* & element); 00138 00139 int FindInScope (const char* name, 00140 vtkPaletteColor* & element); 00141 00142 int FindInScope (const char* name, 00143 vtkPaletteMaterial* & element); 00144 00145 int FindInScope (const char* name, 00146 vtkAbstractPaletteMaterial* & element); 00162 int Insert (vtkPaletteElement* element); 00174 int Insert (const char* name, 00175 vtkPalette* element); 00176 00177 int Insert (const char* name, 00178 vtkPaletteColor* element); 00179 00180 int Insert (const char* name, 00181 vtkPaletteMaterial* element); 00194 int InsertInScope (const char* name, 00195 vtkPaletteElement* element); 00207 int InsertInScope (const char* name, 00208 vtkPalette* element); 00209 00210 int InsertInScope (const char* name, 00211 vtkPaletteColor* element); 00212 00213 int InsertInScope (const char* name, 00214 vtkPaletteMaterial* element); 00226 int Erase (const char* name); 00227 00234 int EraseInScope (const char* name); 00243 int InsertColor (const char* name, 00244 const double c0, 00245 const double c1, 00246 const double c2, 00247 const double alpha, 00248 vtkPaletteColor* object); 00249 00254 int InsertColor (const char* name, 00255 const double c0, 00256 const double c1, 00257 const double c2, 00258 const double alpha); 00259 00264 int InsertColor (const char* name, 00265 const double c0, 00266 const double c1, 00267 const double c2); 00268 00273 int InsertColor (const char* name, 00274 const double color[4]); 00275 00280 int InsertColor (const char* name, 00281 const unsigned char c0, 00282 const unsigned char c1, 00283 const unsigned char c2, 00284 const unsigned char alpha); 00285 00290 int InsertColor (const char* name, 00291 const unsigned char c0, 00292 const unsigned char c1, 00293 const unsigned char c2); 00294 00299 int InsertColor (const char* name, 00300 const unsigned char color[4]); 00301 00306 int InsertColor (const char* name, 00307 const vtkColorWord rgba); 00308 00313 int InsertMaterial (const char* name, 00314 const vtkMaterial material, 00315 vtkPaletteMaterial* object); 00316 00321 int InsertMaterial (const char* name, 00322 const vtkMaterial material); 00332 int FindColor (const char* name, 00333 double& c0, 00334 double& c1, 00335 double& c2, 00336 double& alpha); 00337 00342 int FindColor (const char* name, 00343 double& c0, 00344 double& c1, 00345 double& c2); 00346 00351 int FindColor (const char* name, 00352 double color[4]); 00353 00358 int FindColor (const char* name, 00359 vtkColorWord & rgba); 00360 00365 int FindColor (const char* name, 00366 unsigned char & c0, 00367 unsigned char & c1, 00368 unsigned char & c2, 00369 unsigned char & alpha); 00370 00375 int FindColor (const char* name, 00376 unsigned char & c0, 00377 unsigned char & c1, 00378 unsigned char & c2); 00379 00384 int FindColor (const char* name, 00385 unsigned char color[4]); 00386 00391 int FindMaterial (const char* name, 00392 vtkMaterial & material); 00396 #if 0 00401 int FindColorElement (double c0, 00402 double c1, 00403 double c2, 00404 double alpha, 00405 vtkColorMaterial* & element); 00406 00411 int FindMaterialElement (vtkMaterial material, 00412 vtkPaletteMaterial* & element); 00413 00420 int FindMaterialName (vtkMaterial material, 00421 const char* & name); 00422 00427 int FindColorName (double c0, 00428 double c1, 00429 double c2, 00430 double alpha, 00431 const char* & name); 00432 00439 int FindNextName (const char* & name); 00441 #endif /* 0 */ 00442 00443 00447 int InitTraversal (void); 00448 00455 int InitTraversal (const char* name); 00456 00464 int GetNextElement (const char* & name, 00465 vtkPaletteElement* & element); 00466 00472 int GetCurrentElement (const char* & name, 00473 vtkPaletteElement* & element) const; 00474 00479 int GetFirstElement (const char* & name, 00480 vtkPaletteElement* & element); 00481 00486 int GetLastElement (const char* & name, 00487 vtkPaletteElement* & element); 00488 00496 int GetNextPalette (const char* & name, 00497 vtkPalette* & palette); 00498 00505 int GetCurrentPalette (const char* & name, 00506 vtkPalette* & palette) const; 00507 00515 int GetNextColor (const char* & name, 00516 vtkPaletteColor* & color); 00517 00524 int GetCurrentColor (const char* & name, 00525 vtkPaletteColor* & color) const; 00526 00534 int GetNextMaterial (const char* & name, 00535 vtkPaletteMaterial* & material); 00536 00543 int GetCurrentMaterial (const char* & name, 00544 vtkPaletteMaterial* & material) const; 00545 00553 int GetNextAbstractMaterial (const char* & name, 00554 vtkAbstractPaletteMaterial* & material); 00555 00562 int GetCurrentAbstractMaterial (const char* & name, 00563 vtkAbstractPaletteMaterial* & material) const; 00564 00565 00571 virtual void InsertDefaultPalettes (int revert = VTK_FALSE); 00572 00574 virtual void InsertDefaultMaterials (int revert = VTK_FALSE); 00575 00577 virtual void InsertDefaultColors (int revert = VTK_FALSE); 00578 00580 void InsertDefaults (int revert = VTK_FALSE); 00583 #if 1 00592 const char* StringToColor (const char* name, 00593 double & red, 00594 double & green, 00595 double & blue, 00596 double & alpha); 00597 #endif 00598 00599 //BTX 00601 static const char* const PalettePathsEnvVar; 00602 00604 static const char* const PaletteFilesEnvVar; 00605 00606 static const vtkXMLChType* const paletteString; 00607 00608 static const vtkXMLChType* const createdString; 00609 static const vtkXMLChType* const modifiedString; 00610 static const vtkXMLChType* const versionString; 00611 //ETX 00612 00613 protected: 00614 vtkPalette (void); 00615 ~vtkPalette(); 00616 00617 //BTX 00618 friend class vtkPaletteParser; 00619 00622 void MarshalAttributes (ostream&); 00623 00628 void MarshalContent (ostream&, vtkIndent); 00629 00630 void UnmarshalAttribute (const vtkXMLChType* const& attr, 00631 const vtkXMLChType* const& value); 00632 00637 virtual void PrintMaterial (ostream& target, 00638 vtkIndent indent, 00639 const char* const& name, 00640 vtkMaterial const& material) {} 00641 00646 void PrintColor (ostream& target, 00647 vtkIndent indent, 00648 const char* const& name, 00649 vtkColorWord const& color); 00652 static void BuildSearchLists (void); 00653 00654 static void InitSearchPathsTraversal (const char* const& name = NULL); 00655 static int TraverseSearchPathsForward (const char* & name); 00656 00657 static void InitSearchFilesTraversal (const char* const& name = NULL); 00658 static int TraverseSearchFilesForward (const char* & name); 00659 00660 vtkXMLChType* FullName; 00661 vtkXMLChType* CreatedAttr; 00662 vtkXMLChType* ModifiedAttr; 00663 vtkXMLChType* VersionAttr; 00664 00665 vtkPaletteElementHashMap* Elements; 00666 vtkPaletteElementHashMapIterator* Iterator; 00667 //ETX 00668 00669 virtual void SetParent (vtkPalette* a) 00670 { this->Superclass::SetParent(a); } 00671 00672 private: 00673 void SetParent (vtkPaletteElement* a) 00674 { this->Superclass::SetParent(a); } 00675 00676 private: 00682 vtkPalette (const vtkPalette&); 00683 void operator= (const vtkPalette&); 00685 }; 00686 00687 00688 ostream& operator<< (ostream&, vtkMaterial&); 00689 00690 00691 // ---------------------------------------------------------------------------- 00692 inline vtkPalette* 00693 vtkPalette::GetParent (void) const 00694 { 00695 return vtkPalette::SafeDownCast(this->Superclass::GetParent()); 00696 } 00697 00698 // ---------------------------------------------------------------------------- 00699 inline void 00700 vtkPalette::InsertDefaults (int aFlag) 00701 { 00702 this->InsertDefaultPalettes(aFlag); 00703 this->InsertDefaultMaterials(aFlag); 00704 this->InsertDefaultColors(aFlag); 00705 } 00706 00707 // ---------------------------------------------------------------------------- 00708 inline int 00709 vtkPalette::FindColor (const char* aName, 00710 double & a0, 00711 double & a1, 00712 double & a2) 00713 { 00714 double alpha; 00715 return this->FindColor(aName, a0, a1, a2, alpha); 00716 } 00717 00718 inline int 00719 vtkPalette::FindColor (const char* aName, 00720 double a[4]) 00721 { 00722 return this->FindColor(aName, a[0], a[1], a[2], a[3]); 00723 } 00724 00725 inline int 00726 vtkPalette::FindColor (const char* aName, 00727 vtkColorWord& aColor) 00728 { 00729 double c0, c1, c2, alpha; 00730 00731 if (this->FindColor(aName, c0, c1, c2, alpha)) 00732 { 00733 vtkPalette::ConvertColor(c0, c1, c2, alpha, aColor); 00734 return VTK_TRUE; 00735 } 00736 00737 return VTK_FALSE; 00738 } 00739 00740 inline int 00741 vtkPalette::FindColor (const char* aName, 00742 unsigned char & a0, 00743 unsigned char & a1, 00744 unsigned char & a2, 00745 unsigned char & aA) 00746 { 00747 vtkColorWord color; 00748 00749 if (this->FindColor(aName, color)) 00750 { 00751 vtkPalette::ConvertColor(color, a0, a1, a2, aA); 00752 return VTK_TRUE; 00753 } 00754 00755 return VTK_FALSE; 00756 } 00757 00758 inline int 00759 vtkPalette::FindColor (const char* aName, 00760 unsigned char & a0, 00761 unsigned char & a1, 00762 unsigned char & a2) 00763 { 00764 unsigned char alpha; 00765 return this->FindColor(aName, a0, a1, a2, alpha); 00766 } 00767 00768 inline int 00769 vtkPalette::FindColor (const char* aName, 00770 unsigned char a[4]) 00771 { 00772 return this->FindColor(aName, a[0], a[1], a[2], a[3]); 00773 } 00774 00775 // ---------------------------------------------------------------------------- 00776 inline int 00777 vtkPalette::InsertColor (const char* aName, 00778 const double a0, 00779 const double a1, 00780 const double a2) 00781 { 00782 return this->InsertColor(aName, a0, a1, a2, 1.0); 00783 } 00784 00785 inline int 00786 vtkPalette::InsertColor (const char* aName, 00787 const double a[4]) 00788 { 00789 return this->InsertColor(aName, a[0], a[1], a[2], a[3]); 00790 } 00791 00792 inline int 00793 vtkPalette::InsertColor (const char* aName, 00794 const unsigned char a0, 00795 const unsigned char a1, 00796 const unsigned char a2, 00797 const unsigned char a3) 00798 { 00799 return 00800 this->InsertColor( aName, 00801 double(a0)/double(VTK_EXTENSIONS_UINT8_MAX), 00802 double(a1)/double(VTK_EXTENSIONS_UINT8_MAX), 00803 double(a2)/double(VTK_EXTENSIONS_UINT8_MAX), 00804 double(a3)/double(VTK_EXTENSIONS_UINT8_MAX) ); 00805 } 00806 00807 inline int 00808 vtkPalette::InsertColor (const char* aName, 00809 const unsigned char a0, 00810 const unsigned char a1, 00811 const unsigned char a2) 00812 { 00813 return this->InsertColor(aName, a0, a1, a2, VTK_EXTENSIONS_RGB_MAX); 00814 } 00815 00816 inline int 00817 vtkPalette::InsertColor (const char* aName, 00818 const unsigned char a[4]) 00819 { 00820 return this->InsertColor(aName, a[0], a[1], a[2], a[3]); 00821 } 00822 00823 inline int 00824 vtkPalette::InsertColor (const char* aName, 00825 const vtkColorWord a) 00826 { 00827 return this->InsertColor( aName, 00828 VTK_EXTENSIONS_GET_COLORBYTE(a, 0), 00829 VTK_EXTENSIONS_GET_COLORBYTE(a, 1), 00830 VTK_EXTENSIONS_GET_COLORBYTE(a, 2), 00831 VTK_EXTENSIONS_GET_COLORBYTE(a, 3) ); 00832 } 00833 00834 #if 0 00835 // ---------------------------------------------------------------------------- 00836 inline int 00837 vtkPalette::FindName (unsigned char aR, 00838 unsigned char aG, 00839 unsigned char aB, 00840 const char* & aName) 00841 { 00842 return this->FindName(VTK_EXTENSIONS_MAKE_RGB(aR, aG, aB), aName); 00843 } 00844 00845 inline int 00846 vtkPalette::FindName (unsigned char aR, 00847 unsigned char aG, 00848 unsigned char aB, 00849 unsigned char aA, 00850 const char* & aName) 00851 { 00852 return this->FindName(VTK_EXTENSIONS_MAKE_RGBA(aR, aG, aB, aA), aName); 00853 } 00854 #endif /* 0 */ 00855 00856 VTK_EXTENSIONS_PALETTE_NAMESPACE_END 00857 00858 #endif /* VTK_PALETTE_H_ */ 00859 /* 00860 * End of: $Id: vtkPalette.h,v 1.2 2004/06/12 20:01:23 xpxqx Exp $. 00861 * 00862 */

Generated on Tue Aug 10 03:38:09 2004 for vtkExtensions by doxygen 1.3.7