Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-26 09:04:33

0001 // Copyright (c) 2020 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 #ifndef _SelectMgr_SelectionImageFiller_HeaderFile
0015 #define _SelectMgr_SelectionImageFiller_HeaderFile
0016 
0017 #include <Image_PixMap.hxx>
0018 #include <math_BullardGenerator.hxx>
0019 #include <NCollection_Map.hxx>
0020 #include <StdSelect_TypeOfSelectionImage.hxx>
0021 
0022 class SelectMgr_ViewerSelector;
0023 
0024 //! Abstract class for filling pixel with color.
0025 //! This is internal tool for SelectMgr_ViewerSelector::ToPixMap().
0026 class SelectMgr_SelectionImageFiller : public Standard_Transient
0027 {
0028 public:
0029   //! Create filler of specified type.
0030   static occ::handle<SelectMgr_SelectionImageFiller> CreateFiller(
0031     Image_PixMap&                  thePixMap,
0032     SelectMgr_ViewerSelector*      theSelector,
0033     StdSelect_TypeOfSelectionImage theType);
0034 
0035 public:
0036   //! Main constructor.
0037   SelectMgr_SelectionImageFiller(Image_PixMap& thePixMap, SelectMgr_ViewerSelector* theSelector)
0038       : myImage(&thePixMap),
0039         myMainSel(theSelector)
0040   {
0041   }
0042 
0043   //! Fill pixel at specified position.
0044   virtual void Fill(const int theCol, const int theRow, const int thePicked) = 0;
0045 
0046   //! Flush results into final image.
0047   virtual void Flush() {}
0048 
0049 protected:
0050   //! Find the new unique random color.
0051   void randomPastelColor(Quantity_Color& theColor)
0052   {
0053     for (;;)
0054     {
0055       nextRandomPastelColor(theColor);
0056       if (myUniqueColors.Add(theColor))
0057       {
0058         return;
0059       }
0060     }
0061   }
0062 
0063   //! Fills the given color as random.
0064   void nextRandomPastelColor(Quantity_Color& theColor)
0065   {
0066     theColor = Quantity_Color(double(myBullardGenerator.NextInt() % 256) / 255.0,
0067                               double(myBullardGenerator.NextInt() % 256) / 255.0,
0068                               double(myBullardGenerator.NextInt() % 256) / 255.0,
0069                               Quantity_TOC_sRGB);
0070   }
0071 
0072 protected:
0073   Image_PixMap*                   myImage;
0074   SelectMgr_ViewerSelector*       myMainSel;
0075   math_BullardGenerator           myBullardGenerator;
0076   NCollection_Map<Quantity_Color> myUniqueColors;
0077 };
0078 
0079 #endif