| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273 |
- /*
- ** Command & Conquer Renegade(tm)
- ** Copyright 2025 Electronic Arts Inc.
- **
- ** This program 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.
- **
- ** This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
- */
- /***********************************************************************************************
- *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
- ***********************************************************************************************
- * *
- * Project Name : LevelEdit *
- * *
- * $Archive:: /Commando/Code/Tools/LevelEdit/HistogramCtl.h $Modtime:: 7/2/99 6:28p $*
- * *
- * $Revision:: 3 $*
- * *
- *---------------------------------------------------------------------------------------------*
- * Functions: *
- * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
- #if defined(_MSC_VER)
- #pragma once
- #endif
- #ifndef __HISTOGRAM_CTL_H
- #define __HISTOGRAM_CTL_H
- #include "Vector.H"
- #include "Vector3.H"
- ///////////////////////////////////////////////////////////////////
- //
- // HistogramCtlClass
- //
- ///////////////////////////////////////////////////////////////////
- class HistogramCtlClass
- {
- public:
- //////////////////////////////////////////////////////////////
- // Public constructors/destructors
- //////////////////////////////////////////////////////////////
- HistogramCtlClass (void);
- virtual ~HistogramCtlClass (void);
- //////////////////////////////////////////////////////////////
- // Public methods
- //////////////////////////////////////////////////////////////
- void Add_Data_Point (float value);
- void Reset_Data_Points (void);
- // Selection managment
- void Get_Selection (float &range_min, float &range_max);
- void Set_Selection (float range_min, float range_max);
- void Set_Selection (int min_pixel, int max_pixel);
- void Clear_Selection (void);
-
- // Control customization
- void Set_X_Axis_Range (float min, float max);
- void Set_Y_Axis_Range (float min, float max);
- void Set_Dimensions (int width, int height);
- void Set_Bk_Color (const Vector3 &low, const Vector3 &high);
- void Set_Color (const Vector3 &low, const Vector3 &high);
- // Painting methods
- bool Is_Dirty (void) const { return m_IsDirty; }
- void Set_Dirty (bool dirty = true);
- void Allow_Refresh (bool onoff = true);
- void Render (HDC hdc, int x_pos, int y_pos);
- protected:
- //////////////////////////////////////////////////////////////
- // Protected methods
- //////////////////////////////////////////////////////////////
- void Create_DIB_Section (void);
- void Destroy_DIB_Section (void);
- void Paint_DIB (void);
- int Find_Value_Index (float value);
-
- private:
- //////////////////////////////////////////////////////////////
- // Private data types
- //////////////////////////////////////////////////////////////
- typedef struct
- {
- float min;
- float max;
- } RANGE;
- typedef struct _VALUE
- {
- // Data members
- float value;
- int count;
- // For DynamicVectorClass
- _VALUE (void) : value (0), count (0) { }
- _VALUE (float _value, DWORD _count) : value (_value), count (_count) { }
- bool operator== (const _VALUE &src) { return false; }
- bool operator!= (const _VALUE &src) { return true; }
- } VALUE;
- typedef DynamicVectorClass<VALUE> VALUE_LIST;
-
- //////////////////////////////////////////////////////////////
- // Private member data
- //////////////////////////////////////////////////////////////
- HBITMAP m_hBitmap;
- unsigned char *m_pBits;
- int m_ScanlineSize;
- int m_BMPWidth;
- int m_BMPHeight;
- bool m_IsDirty;
- bool m_AllowRefresh;
- Vector3 m_BkLowColor;
- Vector3 m_BkHighColor;
- Vector3 m_LowColor;
- Vector3 m_HighColor;
- Vector3 m_SelColor;
- Vector3 m_BkSelColor;
- RANGE m_XAxis;
- RANGE m_YAxis;
- RANGE m_Selection;
- VALUE_LIST m_ValueList;
- };
- inline void
- HistogramCtlClass::Set_X_Axis_Range (float min, float max)
- {
- m_XAxis.min = min;
- m_XAxis.max = max;
- Set_Dirty (true);
- return ;
- }
- inline void
- HistogramCtlClass::Set_Y_Axis_Range (float min, float max)
- {
- m_YAxis.min = min;
- m_YAxis.max = max;
- Set_Dirty (true);
- return ;
- }
- inline void
- HistogramCtlClass::Clear_Selection (void)
- {
- m_Selection.min = -1;
- m_Selection.max = -1;
- Set_Dirty (true);
- return ;
- }
- inline void
- HistogramCtlClass::Set_Selection (int min_pixel, int max_pixel)
- {
- float x_range = m_XAxis.max - m_XAxis.min;
- //int start_index = Find_Value_Index (m_XAxis.min);
- //int end_index = Find_Value_Index (m_XAxis.max);
- /*float *x_vector = new float[m_BMPWidth*2];
- ::memset (x_vector, 0, sizeof (float) * m_BMPWidth * 2);
-
- if (m_ValueList[)
- //
- // Loop through all the values and combine pixel-duplicates
- //
- for (int index = start_index; index <= end_index; index ++) {
- VALUE &value = m_ValueList[index];
- int x_pos = int((value.value / x_range) * (float)(m_BMPWidth-1));
- x_vector[x_pos] = min (x_vector[x_pos], value.value);
- x_vector[x_pos*2] = max (x_vector[x_pos*2], value.value);
- }
-
- //float value1 = ((float)(min_pixel * x_range) / ((float)m_BMPWidth));
- //float value2 = ((float)(max_pixel * x_range) / ((float)m_BMPWidth));
- float value1 = x_vector[min_pixel];
- float value2 = x_vector[max_pixel*2];
- delete [] x_vector;*/
- float pixel_range = x_range / (float)m_BMPWidth;
- float left = min_pixel * pixel_range;
- float right = (max_pixel + 1) * pixel_range;
- float value1 = m_XAxis.min + left;
- float value2 = m_XAxis.min + right;
- m_Selection.min = min (value1, value2);
- m_Selection.max = max (value1, value2);
-
- /*if (min_pixel != -1) {
- m_Selection.min = min (value1, value2);
- }
- if (max_pixel != -1) {
- m_Selection.max = max (value1, value2);
- }*/
- /*float real_min = min (value1, value2);
- float real_max = max (value1, value2);
- m_Selection.min = min (m_Selection.min, real_min);
- m_Selection.max = max (m_Selection.max, real_max);*/
- Set_Dirty (true);
- return ;
- }
- inline void
- HistogramCtlClass::Set_Selection (float min, float max)
- {
- m_Selection.min = min;
- m_Selection.max = max;
- Set_Dirty (true);
- return ;
- }
- inline void
- HistogramCtlClass::Get_Selection (float &min, float &max)
- {
- min = m_Selection.min;
- max = m_Selection.max;
- return ;
- }
- inline void
- HistogramCtlClass::Set_Dirty (bool dirty)
- {
- m_IsDirty = dirty;
- return ;
- }
- inline void
- HistogramCtlClass::Allow_Refresh (bool onoff)
- {
- m_AllowRefresh = onoff;
- return ;
- }
- #endif //__HISTOGRAM_CTL_H
|