Exemplo n.º 1
0
        public ColorModel(string description, int maxPixelValue = 0, int gradientSize = 1024)
        {
            if (maxPixelValue == 0)
            {
                maxPixelValue = GlobalVars.MaxPixelValue;
            }

            m_description = description;

            m_gradientSize = gradientSize;

            m_gain = 1.0;

            m_controlPts = new ObservableCollection <ColorControlPoint>();
            m_stops      = new ObservableCollection <ColorStop>();

            m_gradient = new WG_Color[m_gradientSize];

            for (int i = 0; i < m_gradientSize; i++)
            {
                m_gradient[i] = new WG_Color(0, 0, 0);
            }

            SetMaxPixelValue(maxPixelValue);
        }
Exemplo n.º 2
0
        private void RangeSlider_TrackFillDragCompleted(object sender, Infragistics.Controls.Editors.TrackFillChangedEventArgs <double> e)
        {
            m_colorModel.m_controlPts[1].m_value      = (int)RangeMinThumb.Value;
            m_colorModel.m_controlPts[1].m_colorIndex = 0;
            m_colorModel.m_controlPts[2].m_value      = (int)RangeMaxThumb.Value;
            m_colorModel.m_controlPts[2].m_colorIndex = 1023;
            m_colorModel.BuildColorMap();

            WG_Color color = m_colorModel.m_colorMap[500];

            if (ImageDisplay.IsReady() && ImageDisplay.HasImage())
            {
                ImageDisplay.SetColorMap(m_colorModel.m_colorMap);
                ImageDisplay.UpdateImage();
            }
        }
Exemplo n.º 3
0
        void ControlChart_MouseMove(object sender, MouseEventArgs e)
        {
            if (m_isDragging)
            {
                var series = this.ControlChart.Series.FirstOrDefault();
                if (series == null)
                {
                    return;
                }

                var position = e.GetPosition(series);

                // Get the XY value of the mouse in the series.
                ScalerParams sparams = new ScalerParams(ControlChart.ActualWindowRect, ControlChart.ViewportRect, ControlChart_LineSeries.YAxis.IsInverted);
                double       xValue  = ControlChart_LineSeries.XAxis.GetUnscaledValue(e.GetPosition(ControlChart_LineSeries.RootCanvas).X, sparams);
                double       yValue  = ControlChart_LineSeries.YAxis.GetUnscaledValue(e.GetPosition(ControlChart_LineSeries.RootCanvas).Y, sparams);

                if (xValue < m_colorModel.m_controlPts[m_draggingIndex - 1].m_value)
                {
                    xValue = m_colorModel.m_controlPts[m_draggingIndex - 1].m_value;
                }
                else if (xValue > m_colorModel.m_controlPts[m_draggingIndex + 1].m_value)
                {
                    xValue = m_colorModel.m_controlPts[m_draggingIndex + 1].m_value;
                }

                if (yValue < 0)
                {
                    yValue = 0;
                }
                else if (yValue > m_colorModel.m_gradientSize)
                {
                    yValue = m_colorModel.m_gradientSize;
                }

                m_colorModel.m_controlPts[m_draggingIndex].m_value      = (int)xValue;
                m_colorModel.m_controlPts[m_draggingIndex].m_colorIndex = (int)yValue;

                m_colorModel.BuildColorMap();
                DrawColorMap();

                WG_Color color = m_colorModel.m_colorMap[500];
            }
        }
Exemplo n.º 4
0
        public ColorModel()
        {
            m_description  = "Default Color Model";
            m_gradientSize = 1024;
            m_gain         = 1.0;

            m_controlPts = new ObservableCollection <ColorControlPoint>();
            m_stops      = new ObservableCollection <ColorStop>();

            m_gradient = new WG_Color[m_gradientSize];


            m_controlPts.Add(new ColorControlPoint(0, 0));
            m_controlPts.Add(new ColorControlPoint(GlobalVars.MaxPixelValue, m_gradientSize - 1));

            m_stops.Add(new ColorStop(0, new WG_Color(0, 0, 0)));
            m_stops.Add(new ColorStop(GlobalVars.MaxPixelValue, new WG_Color(255, 255, 255)));

            m_maxPixelValue = GlobalVars.MaxPixelValue;
            m_colorMap      = new WG_Color[m_maxPixelValue + 1];

            for (int i = 0; i < m_maxPixelValue + 1; i++)
            {
                m_colorMap[i] = new WG_Color(0, 0, 0);
            }

            //SetMaxPixelValue(maxPixelValue);
            m_maxPixelValue = GlobalVars.MaxPixelValue;
            m_colorMap      = new WG_Color[m_maxPixelValue + 1];

            for (int i = 0; i < m_gradientSize; i++)
            {
                byte val = (byte)((float)(i * 255) / (float)(m_gradientSize));
                m_gradient[i] = new WG_Color(val, val, val);
            }

            for (int i = 0; i < m_maxPixelValue + 1; i++)
            {
                byte val = (byte)((float)(i * 255) / (float)(m_maxPixelValue));
                m_colorMap[i] = new WG_Color(val, val, val);
            }
        }
Exemplo n.º 5
0
        public double m_gain;          // value used to amplify pixel values


        public void SetMaxPixelValue(int maxPixelValue)
        {
            m_maxPixelValue = maxPixelValue;

            m_colorMap = new WG_Color[m_maxPixelValue + 1];

            for (int i = 0; i < m_maxPixelValue + 1; i++)
            {
                m_colorMap[i] = new WG_Color(0, 0, 0);
            }

            //m_controlPts.Add(new ColorControlPoint(0, 0));
            //m_controlPts.Add(new ColorControlPoint(100 / 3, m_gradientSize / 3));
            //m_controlPts.Add(new ColorControlPoint(100 * 2 / 3, m_gradientSize * 2 / 3));
            //m_controlPts.Add(new ColorControlPoint(100, m_gradientSize - 1));

            m_controlPts.Add(new ColorControlPoint(0, 0));
            m_controlPts.Add(new ColorControlPoint(0, 0));
            m_controlPts.Add(new ColorControlPoint(m_maxPixelValue, m_gradientSize - 1));
            m_controlPts.Add(new ColorControlPoint(m_maxPixelValue, m_gradientSize - 1));
        }
Exemplo n.º 6
0
        public ColorModel(ColorModelContainer cModelCont, int maxPixelValue = 65535, int gradientSize = 1024)
        {
            m_description  = cModelCont.Description;
            m_gradientSize = gradientSize;
            m_gain         = 1.0;

            m_controlPts = new ObservableCollection <ColorControlPoint>();
            m_stops      = new ObservableCollection <ColorStop>();

            m_gradient = new WG_Color[m_gradientSize];

            for (int i = 0; i < m_gradientSize; i++)
            {
                m_gradient[i] = new WG_Color(0, 0, 0);
            }

            foreach (ColorModelControlPointContainer pc in cModelCont.ControlPts)
            {
                m_controlPts.Add(new ColorControlPoint(pc.Value, pc.ColorIndex));
            }

            foreach (ColorModelStopContainer sc in cModelCont.Stops)
            {
                m_stops.Add(new ColorStop(sc.ColorIndex, new WG_Color(sc.Red, sc.Green, sc.Blue)));
            }

            //SetMaxPixelValue(maxPixelValue);
            m_maxPixelValue = maxPixelValue;
            m_colorMap      = new WG_Color[m_maxPixelValue + 1];

            for (int i = 0; i < m_maxPixelValue + 1; i++)
            {
                m_colorMap[i] = new WG_Color(0, 0, 0);
            }

            BuildColorGradient();

            BuildColorMap();
        }
Exemplo n.º 7
0
        public void InsertColorStop(int index, byte red, byte green, byte blue)
        {
            WG_Color  color = new WG_Color(red, green, blue);
            ColorStop cstop = new ColorStop(index, color);

            int position = 0;
            int maxIndex = m_gradientSize - 1;

            if (index == 0)
            {
                position = 0;
            }

            else if (index == maxIndex)
            {
                position = m_stops.Count();
            }

            else
            {
                for (int i = 0; i < m_stops.Count(); i++)
                {
                    if (index > m_stops[i].m_index)
                    {
                        position = i + 1;
                    }
                    else
                    {
                        break;
                    }
                }
            }


            m_stops.Insert(position, cstop);
        }
Exemplo n.º 8
0
 public ColorStop(int index, WG_Color color)
 {
     m_color = color;
     m_index = index;
 }