Back to index

nux  3.0.0
ColorEditor.cpp
Go to the documentation of this file.
00001 /*
00002  * Copyright 2010 Inalogic® Inc.
00003  *
00004  * This program is free software: you can redistribute it and/or modify it
00005  * under the terms of the GNU Lesser General Public License, as
00006  * published by the  Free Software Foundation; either version 2.1 or 3.0
00007  * of the License.
00008  *
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranties of
00011  * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
00012  * PURPOSE.  See the applicable version of the GNU Lesser General Public
00013  * License for more details.
00014  *
00015  * You should have received a copy of both the GNU Lesser General Public
00016  * License along with this program. If not, see <http://www.gnu.org/licenses/>
00017  *
00018  * Authored by: Jay Taoko <jaytaoko@inalogic.com>
00019  *
00020  */
00021 
00022 
00023 #include "Nux.h"
00024 
00025 #include "NuxGraphics/GLSh_ColorPicker.h"
00026 #include "VLayout.h"
00027 #include "HLayout.h"
00028 #include "CheckBox.h"
00029 #include "EditTextBox.h"
00030 #include "RadioButton.h"
00031 #include "RadioButtonGroup.h"
00032 #include "ToggleButton.h"
00033 #include "Layout.h"
00034 #include "ColorEditor.h"
00035 
00036 namespace nux
00037 {
00038   Size ColorEditor::picker_area_size = Size(200, 200);
00039   int ColorEditor::channel_area_width = 12;
00040 
00041   static void ThreadColorEditorDialog(NThread *thread, void *InitData)
00042   {
00043     VLayout *MainLayout(new VLayout(NUX_TRACKER_LOCATION));
00044     ColorEditor *coloreditor(new ColorEditor());
00045     coloreditor->ComputeContentSize(); // necessary so all element of the widget get their rightful size.
00046     ColorDialogProxy *coloreditorproxy = static_cast<ColorDialogProxy *> (InitData);
00047 
00048     if (coloreditorproxy)
00049     {
00050       coloreditor->SetRGB(coloreditorproxy->GetColor());
00051       coloreditor->SetColorModel(coloreditorproxy->GetColorModel(), coloreditorproxy->GetColorChannel());
00052       coloreditor->sigChange.connect(sigc::mem_fun(coloreditorproxy, &ColorDialogProxy::RecvDialogChange));
00053     }
00054 
00055     HLayout *ButtonLayout(new HLayout("Dialog Buttons", NUX_TRACKER_LOCATION));
00056 
00057     ToggleButton *OkButton(new ToggleButton("OK", NUX_TRACKER_LOCATION));
00058     OkButton->SetMinimumWidth(60);
00059     OkButton->SetMinimumHeight(20);
00060 
00061     ToggleButton *CancelButton(new ToggleButton("Cancel", NUX_TRACKER_LOCATION));
00062     CancelButton->SetMinimumWidth(60);
00063     CancelButton->SetMinimumHeight(20);
00064 
00065     //FIXME - OkButton->sigClick.connect(sigc::mem_fun(static_cast<WindowThread *> (thread), &WindowThread::TerminateThread));
00066     //FIXME - OkButton->sigClick.connect(sigc::bind(sigc::mem_fun(coloreditorproxy, &ColorDialogProxy::RecvDialogOk), coloreditor));
00067     //FIXME - CancelButton->sigClick.connect(sigc::bind(sigc::mem_fun(coloreditorproxy, &ColorDialogProxy::RecvDialogCancel), coloreditor));
00068     //FIXME - CancelButton->sigClick.connect(sigc::mem_fun(static_cast<WindowThread *> (thread), &WindowThread::TerminateThread));
00069 
00070     ButtonLayout->SetHorizontalInternalMargin(6);
00071     ButtonLayout->SetVerticalExternalMargin(2);
00072     ButtonLayout->AddView(OkButton, 0);
00073     ButtonLayout->AddView(CancelButton, 0);
00074 
00075     MainLayout->AddView(coloreditor);
00076     MainLayout->AddLayout(ButtonLayout, 0);
00077     static_cast<WindowThread *> (thread)->SetLayout(MainLayout);
00078 
00079     MainLayout->SetBaseWidth(1);
00080     MainLayout->SetBaseHeight(1);
00081     MainLayout->ComputeContentSize();
00082     static_cast<WindowThread *> (thread)->SetWindowSize(MainLayout->GetBaseWidth(), MainLayout->GetBaseHeight());
00083 
00084     // Call StopThreadMonitoring in case the dialog was close by clicking the window close button.
00085     //coloreditorproxy->StopThreadMonitoring();
00086   }
00087 
00088   ColorDialogProxy::ColorDialogProxy(bool ModalWindow)
00089   {
00090     m_bDialogChange     = false;
00091     m_bDialogRunning    = false;
00092     m_ModalWindow       = ModalWindow;
00093     m_RGBColor          = Color(1.0f, 1.0f, 1.0f, 1.0f);
00094     m_ColorModel        = color::RGB;
00095     color_channel_      = color::RED;
00096   }
00097 
00098   ColorDialogProxy::~ColorDialogProxy()
00099   {
00100   }
00101 
00102   void ColorDialogProxy::Start()
00103   {
00104     m_PreviousRGBColor = m_RGBColor;
00105 
00106     int Width = 290;
00107     int Height = 230;
00108     m_Thread = CreateModalWindowThread(WINDOWSTYLE_TOOL, "Color Editor", Width, Height, GetWindowThread(),
00109                                         ThreadColorEditorDialog,
00110                                         this);
00111 
00112     if (m_Thread)
00113     {
00114       //todo(jaytaoko): m_DialogThreadID = m_Thread->GetThreadId();
00115       m_Thread->Start(0);
00116     }
00117 
00118     m_bDialogRunning = true;
00119   }
00120 
00121   bool ColorDialogProxy::IsActive()
00122   {
00123     return (m_Thread && (m_Thread->GetThreadState() != THREADSTOP) && m_bDialogRunning);
00124   }
00125 
00126   void ColorDialogProxy::RecvDialogOk(ColorEditor *coloreditor)
00127   {
00128     m_RGBColor = coloreditor->GetRGBColor();
00129     m_PreviousRGBColor = m_RGBColor;
00130     m_bDialogChange = true;
00131     m_bDialogRunning = false;
00132   }
00133 
00134   void ColorDialogProxy::RecvDialogCancel(ColorEditor *coloreditor)
00135   {
00136     m_RGBColor = m_PreviousRGBColor;
00137     m_bDialogChange = true;
00138     m_bDialogRunning = false;
00139   }
00140 
00141   void ColorDialogProxy::RecvDialogChange(ColorEditor *coloreditor)
00142   {
00143     m_RGBColor = coloreditor->GetRGBColor();
00144     m_bDialogChange = true;
00145   }
00146 
00147   void ColorDialogProxy::StopThreadMonitoring()
00148   {
00149     m_RGBColor = m_PreviousRGBColor;
00150     m_bDialogChange = true;
00151     m_bDialogRunning = false;
00152     m_Thread = 0;
00153     m_DialogThreadID = 0;
00154   }
00155 
00156   void ColorDialogProxy::SetColor(Color color)
00157   {
00158     m_RGBColor = color;
00159   }
00160 
00161   Color ColorDialogProxy::GetColor()
00162   {
00163     return m_RGBColor;
00164   }
00165 
00166   void ColorDialogProxy::SetPreviousColor(Color color)
00167   {
00168     m_PreviousRGBColor = color;
00169   }
00170 
00171   Color ColorDialogProxy::GetPreviousColor()
00172   {
00173     return m_PreviousRGBColor;
00174   }
00175 
00176   void ColorDialogProxy::SetColorModel(color::Model color_model)
00177   {
00178     m_ColorModel = color_model;
00179   }
00180 
00181   color::Model ColorDialogProxy::GetColorModel()
00182   {
00183     return m_ColorModel;
00184   }
00185 
00186   void ColorDialogProxy::SetColorChannel(color::Channel color_channel)
00187   {
00188     color_channel_ = color_channel;
00189   }
00190 
00191   color::Channel ColorDialogProxy::GetColorChannel()
00192   {
00193     return color_channel_;
00194   }
00195 
00196   ColorEditor::ColorEditor(NUX_FILE_LINE_DECL)
00197     : View(NUX_FILE_LINE_PARAM)
00198     , rgb_(1.0f, 1.0f, 0.0f)
00199     , hsv_(rgb_)
00200   {
00201     m_ColorModel = color::RGB;
00202     color_channel_ = color::RED;
00203     m_MarkerPosition = Point(0, 0);
00204     m_VertMarkerPosition = Point(0, 0);
00205 
00206     m_Validator.SetMinimum(0.0);
00207     m_Validator.SetMaximum(1.0);
00208     m_Validator.SetDecimals(2);
00209 
00210     picker_area_        = new InputArea(NUX_TRACKER_LOCATION);
00211     channel_area_   = new InputArea(NUX_TRACKER_LOCATION);
00212     selected_color_area_       = new InputArea(NUX_TRACKER_LOCATION);
00213     m_hlayout           = new HLayout(NUX_TRACKER_LOCATION);
00214 
00215     channel_area_->mouse_down.connect(sigc::mem_fun(this, &ColorEditor::RecvMouseDown));
00216     channel_area_->mouse_up.connect(sigc::mem_fun(this, &ColorEditor::RecvMouseUp));
00217     channel_area_->mouse_drag.connect(sigc::mem_fun(this, &ColorEditor::RecvMouseDrag));
00218 
00219     picker_area_->mouse_down.connect(sigc::mem_fun(this, &ColorEditor::RecvPickerMouseDown));
00220     picker_area_->mouse_up.connect(sigc::mem_fun(this, &ColorEditor::RecvPickerMouseUp));
00221     picker_area_->mouse_drag.connect(sigc::mem_fun(this, &ColorEditor::RecvPickerMouseDrag));
00222 
00223     selected_color_area_->SetMinMaxSize(62, 32);
00224     picker_area_->SetMinMaxSize(picker_area_size.width, picker_area_size.height);
00225     channel_area_->SetMaximumHeight(picker_area_size.height);
00226     channel_area_->SetMinimumWidth(channel_area_width);
00227     channel_area_->SetMaximumWidth(channel_area_width);
00228 
00229     m_hlayout->AddView(picker_area_, 1);
00230     m_hlayout->AddLayout(new SpaceLayout(5, 5, 20, 20), 0);
00231     m_hlayout->AddView(channel_area_, 0, eAbove, eFull);
00232     SetCompositionLayout(m_hlayout);
00233 
00234     // RGB
00235     {
00236       redlayout = new HLayout(NUX_TRACKER_LOCATION);
00237       {
00238         //FIXME - change to radio button
00239         redcheck = new RadioButton("R");
00240         redcheck->SetMinimumWidth(32);
00241         redtext = new EditTextBox("", NUX_TRACKER_LOCATION);
00242         redtext->SetMinimumWidth(36);
00243         redlayout->AddView(redcheck, 0);
00244         redlayout->AddView(redtext, 0);
00245         redcheck->click.connect(sigc::bind(sigc::bind(sigc::mem_fun(this, &ColorEditor::RecvCheckColorModel0), color::RED), color::RGB));
00246       }
00247       greenlayout = new HLayout(NUX_TRACKER_LOCATION);
00248       {
00249         //FIXME - Change to radio button
00250         greencheck = new RadioButton("G");
00251         greencheck->SetMinimumWidth(32);
00252         greentext = new EditTextBox("", NUX_TRACKER_LOCATION);
00253         greentext->SetMinimumWidth(36);
00254         greenlayout->AddView(greencheck, 0);
00255         greenlayout->AddView(greentext, 0);
00256         greencheck->click.connect(sigc::bind(sigc::bind(sigc::mem_fun(this, &ColorEditor::RecvCheckColorModel0), color::GREEN), color::RGB));
00257 
00258       }
00259       bluelayout = new HLayout(NUX_TRACKER_LOCATION);
00260       {
00261         //FIXME - change to radio button
00262         bluecheck = new RadioButton("B");
00263         bluecheck->SetMinimumWidth(32);
00264         bluetext = new EditTextBox("", NUX_TRACKER_LOCATION);
00265         bluetext->SetMinimumWidth(36);
00266         bluelayout->AddView(bluecheck, 0);
00267         bluelayout->AddView(bluetext, 0);
00268         bluecheck->click.connect(sigc::bind(sigc::bind(sigc::mem_fun(this, &ColorEditor::RecvCheckColorModel0), color::BLUE), color::RGB));
00269       }
00270     }
00271 
00272     // HSV
00273     {
00274       huelayout = new HLayout(NUX_TRACKER_LOCATION);
00275       {
00276         huecheck = new RadioButton("H");
00277         huecheck->SetMinimumWidth(32);
00278         hue_text_entry_ = new EditTextBox("", NUX_TRACKER_LOCATION);
00279         hue_text_entry_->SetMinimumWidth(36);
00280         huelayout->AddView(huecheck, 0);
00281         huelayout->AddView(hue_text_entry_, 0);
00282         huecheck->click.connect(sigc::bind(sigc::bind(sigc::mem_fun(this, &ColorEditor::RecvCheckColorModel0), color::HUE), color::HSV ));
00283       }
00284       saturationlayout = new HLayout(NUX_TRACKER_LOCATION);
00285       {
00286         saturationcheck = new RadioButton("S");
00287         saturationcheck->SetMinimumWidth(32);
00288         saturation_text_entry_ = new EditTextBox("", NUX_TRACKER_LOCATION);
00289         saturation_text_entry_->SetMinimumWidth(36);
00290         saturationlayout->AddView(saturationcheck, 0);
00291         saturationlayout->AddView(saturation_text_entry_, 0);
00292         saturationcheck->click.connect(sigc::bind(sigc::bind(sigc::mem_fun(this, &ColorEditor::RecvCheckColorModel0), color::SATURATION), color::HSV ));
00293       }
00294       valuelayout = new HLayout(NUX_TRACKER_LOCATION);
00295       {
00296         valuecheck = new RadioButton("V");
00297         valuecheck->SetMinimumWidth(32);
00298         value_text_entry_ = new EditTextBox("", NUX_TRACKER_LOCATION);
00299         value_text_entry_->SetMinimumWidth(36);
00300         valuelayout->AddView(valuecheck, 0);
00301         valuelayout->AddView(value_text_entry_, 0);
00302         valuecheck->click.connect(sigc::bind(sigc::bind(sigc::mem_fun(this, &ColorEditor::RecvCheckColorModel0), color::VALUE), color::HSV ));
00303       }
00304     }
00305 
00306     ctrllayout = new VLayout(NUX_TRACKER_LOCATION);
00307     ctrllayout->AddView(selected_color_area_);
00308     ctrllayout->AddView(new SpaceLayout(20, 20, 10, 10), 1);
00309     ctrllayout->AddLayout(redlayout, 0);
00310     ctrllayout->AddLayout(greenlayout, 0);
00311     ctrllayout->AddLayout(bluelayout, 0);
00312     ctrllayout->AddLayout(new SpaceLayout(10, 10, 10, 10));
00313     ctrllayout->AddLayout(huelayout, 0);
00314     ctrllayout->AddLayout(saturationlayout, 0);
00315     ctrllayout->AddLayout(valuelayout, 0);
00316     ctrllayout->SetHorizontalExternalMargin(2);
00317     ctrllayout->SetVerticalInternalMargin(2);
00318 
00319 //     //ctrllayout->AddView(new SpaceLayout(20,20,20,40), 1);
00320 //     OkButton = new ToggleButton("OK", NUX_TRACKER_LOCATION);
00321 //     OkButton->SetMinimumWidth(60);
00322 //     OkButton->SetMinimumHeight(20);
00323 //
00324 //     CancelButton = new ToggleButton("Cancel", NUX_TRACKER_LOCATION);
00325 //     CancelButton->SetMinimumWidth(60);
00326 //     CancelButton->SetMinimumHeight(20);
00327 //
00328 // //    ctrllayout->AddView(OkButton, 1);
00329 // //    ctrllayout->AddView(CancelButton, 1);
00330 
00331     m_hlayout->AddLayout(ctrllayout, 0);
00332 
00333     radiogroup = new RadioButtonGroup(NUX_TRACKER_LOCATION);
00334     radiogroup->ConnectButton(redcheck);
00335     radiogroup->ConnectButton(greencheck);
00336     radiogroup->ConnectButton(bluecheck);
00337     radiogroup->ConnectButton(huecheck);
00338     radiogroup->ConnectButton(saturationcheck);
00339     radiogroup->ConnectButton(valuecheck);
00340 
00341     m_RedShader = new GLSh_ColorPicker(color::RED);
00342     m_GreenShader = new GLSh_ColorPicker(color::GREEN);
00343     m_BlueShader = new GLSh_ColorPicker(color::BLUE);
00344     m_HueShader = new GLSh_ColorPicker(color::HUE);
00345     m_SaturationShader = new GLSh_ColorPicker(color::SATURATION);
00346     m_ValueShader = new GLSh_ColorPicker(color::VALUE);
00347 
00348     redtext->SetText(m_Validator.ToString(255 * rgb_.red));
00349     greentext->SetText(m_Validator.ToString(255 * rgb_.green));
00350     bluetext->SetText(m_Validator.ToString(255 * rgb_.blue));
00351     hue_text_entry_->SetText(m_Validator.ToString(360 * hsv_.hue));
00352     saturation_text_entry_->SetText(m_Validator.ToString(100 * hsv_.saturation));
00353     value_text_entry_->SetText(m_Validator.ToString(100 * hsv_.value));
00354   }
00355 
00356   ColorEditor::~ColorEditor()
00357   {
00358     delete m_RedShader;
00359     delete m_GreenShader;
00360     delete m_BlueShader;
00361     delete m_HueShader;
00362     delete m_SaturationShader;
00363     delete m_ValueShader;
00364     radiogroup->UnReference();
00365   }
00366 
00367   void ColorEditor::PreLayoutManagement()
00368   {
00369     View::PreLayoutManagement();
00370     if (view_layout_)
00371     {
00372       // Constrain the vertical expansion of the color picker.
00373       view_layout_->SetBaseWidth(1);
00374       view_layout_->SetBaseHeight(1);
00375     }
00376   }
00377 
00378   void ColorEditor::Draw(GraphicsEngine &graphics_engine, bool force_draw)
00379   {
00380     Geometry base = GetGeometry();
00381 
00382     GetPainter().PaintBackground(graphics_engine, base);
00383     //GetPainter().Paint2DQuadWireframe(graphics_engine, base, Color(COLOR_BACKGROUND_SECONDARY));
00384 
00385     base.OffsetPosition(1, 1);
00386     base.OffsetSize(-2, -2);
00387 
00388     graphics_engine.PushClippingRectangle(base);
00389 
00390     if (m_ColorModel == color::RGB)
00391     {
00392       DrawRGB(graphics_engine, force_draw);
00393     }
00394     else
00395     {
00396       DrawHSV(graphics_engine, force_draw);
00397     }
00398 
00399     redcheck->QueueDraw();
00400     redtext->QueueDraw();
00401     greencheck->QueueDraw();
00402     greentext->QueueDraw();
00403     bluecheck->QueueDraw();
00404     bluetext->QueueDraw();
00405 
00406     huecheck->QueueDraw();
00407     hue_text_entry_->QueueDraw();
00408     saturationcheck->QueueDraw();
00409     saturation_text_entry_->QueueDraw();
00410     valuecheck->QueueDraw();
00411     value_text_entry_->QueueDraw();
00412 
00413 //     OkButton->QueueDraw();
00414 //     CancelButton->QueueDraw();
00415 
00416     graphics_engine.PopClippingRectangle();
00417   }
00418 
00419 // Draw Marker on Base Chanel Area
00420   void ColorEditor::DrawBaseChannelMarker(GraphicsEngine &graphics_engine)
00421   {
00422     int marker_position_x;
00423     int marker_position_y;
00424 
00425     graphics_engine.PushClippingRectangle(channel_area_->GetGeometry());
00426 
00427     marker_position_x = channel_area_->GetBaseX();
00428     marker_position_y = channel_area_->GetBaseY() + m_VertMarkerPosition.y;
00429     GetPainter().Draw2DTriangleColor(graphics_engine, marker_position_x, marker_position_y - 5,
00430                                   marker_position_x + 5, marker_position_y,
00431                                   marker_position_x, marker_position_y + 5, Color(0.0f, 0.0f, 0.0f, 1.0f));
00432 
00433     GetPainter().Draw2DTriangleColor(graphics_engine, marker_position_x, marker_position_y - 4,
00434                                   marker_position_x + 4, marker_position_y,
00435                                   marker_position_x, marker_position_y + 4, Color(0.7f, 0.7f, 0.7f, 1.0f));
00436 
00437     marker_position_x = channel_area_->GetBaseX() + channel_area_->GetBaseWidth();
00438     marker_position_y = channel_area_->GetBaseY() + m_VertMarkerPosition.y;
00439     GetPainter().Draw2DTriangleColor(graphics_engine, marker_position_x, marker_position_y - 5,
00440                                   marker_position_x - 5, marker_position_y,
00441                                   marker_position_x, marker_position_y + 5, Color(0.0f, 0.0f, 0.0f, 1.0f));
00442 
00443     GetPainter().Draw2DTriangleColor(graphics_engine, marker_position_x, marker_position_y - 4,
00444                                   marker_position_x - 4, marker_position_y,
00445                                   marker_position_x, marker_position_y + 4, Color(0.7f, 0.7f, 0.7f, 1.0f));
00446     graphics_engine.PopClippingRectangle();
00447   }
00448 
00449   void ColorEditor::DrawRGB(GraphicsEngine &graphics_engine, bool force_draw)
00450   {
00451     if (m_ColorModel == color::RGB)
00452     {
00453       GetPainter().Paint2DQuadColor(graphics_engine, selected_color_area_->GetGeometry(), Color(rgb_));
00454       Color BaseChannelTop;
00455       Color BaseChannelBottom;
00456 
00457       if (color_channel_ == color::RED)
00458       {
00459         m_RedShader->SetColor(rgb_.red, rgb_.green, rgb_.blue, 1.0f);
00460         m_RedShader->SetScreenPositionOffset(graphics_engine.GetViewportX(), graphics_engine.GetViewportY());
00461         BaseChannelTop = Color(1.0f, rgb_.green, rgb_.blue, 1.0f);
00462         BaseChannelBottom = Color(0.0f, rgb_.green, rgb_.blue, 1.0f);
00463         m_RedShader->Render(
00464           picker_area_->GetBaseX(),
00465           picker_area_->GetBaseY(),
00466           0,
00467           picker_area_->GetBaseWidth(),
00468           picker_area_->GetBaseHeight(),
00469           graphics_engine.GetViewportWidth(), graphics_engine.GetViewportHeight()
00470         );
00471       }
00472       else if (color_channel_ == color::GREEN)
00473       {
00474         m_GreenShader->SetColor(rgb_.red, rgb_.green, rgb_.blue, 1.0f);
00475         m_GreenShader->SetScreenPositionOffset(graphics_engine.GetViewportX(), graphics_engine.GetViewportY());
00476         BaseChannelTop = Color(rgb_.red, 1.0f, rgb_.blue, 1.0f);
00477         BaseChannelBottom = Color(rgb_.red, 0.0f, rgb_.blue, 1.0f);
00478         m_GreenShader->Render(
00479           picker_area_->GetBaseX(),
00480           picker_area_->GetBaseY(),
00481           0,
00482           picker_area_->GetBaseWidth(),
00483           picker_area_->GetBaseHeight(),
00484           graphics_engine.GetViewportWidth(), graphics_engine.GetViewportHeight()
00485         );
00486       }
00487       else if (color_channel_ == color::BLUE)
00488       {
00489         m_BlueShader->SetColor(rgb_.red, rgb_.green, rgb_.blue, 1.0f);
00490         m_BlueShader->SetScreenPositionOffset(graphics_engine.GetViewportX(), graphics_engine.GetViewportY());
00491         BaseChannelTop = Color(rgb_.red, rgb_.green, 1.0f, 1.0f);
00492         BaseChannelBottom = Color(rgb_.red, rgb_.green, 0.0f, 1.0f);
00493         m_BlueShader->Render(
00494           picker_area_->GetBaseX(),
00495           picker_area_->GetBaseY(),
00496           0,
00497           picker_area_->GetBaseWidth(),
00498           picker_area_->GetBaseHeight(),
00499           graphics_engine.GetViewportWidth(), graphics_engine.GetViewportHeight()
00500         );
00501       }
00502 
00503       Geometry pickermarker = Geometry(GetBaseX() + m_MarkerPosition.x - 2, GetBaseY() + m_MarkerPosition.y - 2, 5, 5);
00504       Geometry basepickermarker = Geometry(channel_area_->GetBaseX(), channel_area_->GetBaseY() + m_VertMarkerPosition.y, 5, 5);
00505 
00506       Color color(rgb_.red, rgb_.green, rgb_.blue);
00507       float luma = color::LumaRed * rgb_.red + color::LumaGreen * rgb_.green + color::LumaBlue * rgb_.blue;
00508       Color one_minus_luma(1.0f - luma, 1.0f - luma, 1.0f - luma);
00509 
00510       GetPainter().Paint2DQuadWireframe(graphics_engine, pickermarker, one_minus_luma);
00511 
00512       GetPainter().Paint2DQuadColor(graphics_engine, channel_area_->GetGeometry(), BaseChannelTop, BaseChannelBottom, BaseChannelBottom, BaseChannelTop);
00513       // Draw Marker on Base Chanel Area
00514       DrawBaseChannelMarker(graphics_engine);
00515     }
00516   }
00517 
00518   void ColorEditor::DrawHSV(GraphicsEngine &graphics_engine, bool force_draw)
00519   {
00520     if (m_ColorModel == color::HSV)
00521     {
00522       color::RedGreenBlue rgb(hsv_);
00523       GetPainter().Paint2DQuadColor(graphics_engine, selected_color_area_->GetGeometry(), Color(rgb));
00524 
00525       Color BaseChannelTop;
00526       Color BaseChannelBottom;
00527 
00528       if (color_channel_ == color::HUE)
00529       {
00530         m_HueShader->SetColor(hsv_.hue, hsv_.saturation, hsv_.value, 1.0f);
00531         m_HueShader->SetScreenPositionOffset(graphics_engine.GetViewportX(), graphics_engine.GetViewportY());
00532         m_HueShader->Render(
00533           picker_area_->GetBaseX(),
00534           picker_area_->GetBaseY(),
00535           0,
00536           picker_area_->GetBaseWidth(),
00537           picker_area_->GetBaseHeight(),
00538           graphics_engine.GetViewportWidth(), graphics_engine.GetViewportHeight()
00539         );
00540 
00541         Geometry P = channel_area_->GetGeometry();
00542 
00543         float s = 1.0f - 1.0f;
00544         float v = 1.0f;
00545         float fw = P.GetHeight() / 6;
00546 
00547         Geometry p = Geometry(P.x, P.y, P.GetWidth(), fw);
00548         GetPainter().Paint2DQuadVGradient(graphics_engine, p, Color(1.0f * v, s * v, s * v), Color(1.0f * v, s * v, 1.0f * v));
00549         p.SetY(P.y + fw);
00550         GetPainter().Paint2DQuadVGradient(graphics_engine, p, Color(1.0f * v, s * v, 1.0f * v), Color(s * v, s * v, 1.0f * v));
00551         p.SetY(P.y + 2 * fw);
00552         GetPainter().Paint2DQuadVGradient(graphics_engine, p, Color(s * v, s * v, 1.0f * v), Color(s * v, 1.0f * v, 1.0f * v));
00553         p.SetY(P.y + 3 * fw);
00554         GetPainter().Paint2DQuadVGradient(graphics_engine, p, Color(s * v, 1.0f * v, 1.0f * v), Color(s * v, 1.0f * v, s * v));
00555         p.SetY(P.y + 4 * fw);
00556         GetPainter().Paint2DQuadVGradient(graphics_engine, p, Color(s * v, 1.0f * v, s * v), Color(1.0f * v, 1.0f * v, s * v));
00557         p.SetY(P.y + 5 * fw);
00558         p.SetHeight(P.GetHeight() - 5 * fw); // correct rounding errors
00559         GetPainter().Paint2DQuadVGradient(graphics_engine, p, Color(1.0f * v, 1.0f * v, s * v), Color(1.0f * v, s * v, s * v));
00560 
00561         Geometry pickermarker = Geometry(GetBaseX() + m_MarkerPosition.x - 2, GetBaseY() + m_MarkerPosition.y - 2, 5, 5);
00562 
00563         float luma = color::LumaRed * rgb_.red + color::LumaGreen * rgb_.green + color::LumaBlue * rgb_.blue;
00564         Color one_minus_luma(1.0f - luma, 1.0f - luma, 1.0f - luma);
00565         GetPainter().Paint2DQuadWireframe(graphics_engine, pickermarker, one_minus_luma);
00566       }
00567       else if (color_channel_ == color::SATURATION)
00568       {
00569         float value = hsv_.value;
00570         if (value < 0.3f) value = 0.3f;
00571 
00572         m_SaturationShader->SetColor(hsv_.hue, hsv_.saturation, hsv_.value, 1.0f);
00573         m_SaturationShader->SetScreenPositionOffset(graphics_engine.GetViewportX(), graphics_engine.GetViewportY());
00574         BaseChannelTop = Color(color::RedGreenBlue(color::HueSaturationValue(hsv_.hue, 1.0f, value)));
00575         BaseChannelBottom = Color(value, value, value, 1.0f);
00576         m_SaturationShader->Render(
00577           picker_area_->GetBaseX(),
00578           picker_area_->GetBaseY(),
00579           0,
00580           picker_area_->GetBaseWidth(),
00581           picker_area_->GetBaseHeight(),
00582           graphics_engine.GetViewportWidth(), graphics_engine.GetViewportHeight()
00583         );
00584 
00585         //Geometry pickermarker = Geometry(GetX() + x - 2, GetY() + y -2, 5, 5);
00586         Geometry pickermarker = Geometry(GetBaseX() + m_MarkerPosition.x - 2, GetBaseY() + m_MarkerPosition.y - 2, 5, 5);
00587 
00588         float luma = color::LumaRed * rgb_.red + color::LumaGreen * rgb_.green + color::LumaBlue * rgb_.blue;
00589         Color one_minus_luma(1.0f - luma, 1.0f - luma, 1.0f - luma);
00590 
00591         GetPainter().Paint2DQuadWireframe(graphics_engine, pickermarker, one_minus_luma);
00592         GetPainter().Paint2DQuadColor(graphics_engine, channel_area_->GetGeometry(), BaseChannelTop, BaseChannelBottom, BaseChannelBottom, BaseChannelTop);
00593       }
00594       else if (color_channel_ == color::VALUE)
00595       {
00596         m_ValueShader->SetColor(hsv_.hue, hsv_.saturation, hsv_.value, 1.0f);
00597         m_ValueShader->SetScreenPositionOffset(graphics_engine.GetViewportX(), graphics_engine.GetViewportY());
00598         BaseChannelTop = Color(color::RedGreenBlue(color::HueSaturationValue(hsv_.hue, hsv_.saturation, 1.0f)));
00599         BaseChannelBottom = Color(color::RedGreenBlue(color::HueSaturationValue(hsv_.hue, hsv_.saturation, 0.0f)));
00600         m_ValueShader->Render(
00601           picker_area_->GetBaseX(),
00602           picker_area_->GetBaseY(),
00603           0,
00604           picker_area_->GetBaseWidth(),
00605           picker_area_->GetBaseHeight(),
00606           graphics_engine.GetViewportWidth(), graphics_engine.GetViewportHeight()
00607         );
00608 
00609         //Geometry pickermarker = Geometry(GetX() + x - 2, GetY() + y -2, 5, 5);
00610         Geometry pickermarker = Geometry(GetBaseX() + m_MarkerPosition.x - 2, GetBaseY() + m_MarkerPosition.y - 2, 5, 5);
00611 
00612         float luma = color::LumaRed * rgb_.red + color::LumaGreen * rgb_.green + color::LumaBlue * rgb_.blue;
00613         Color one_minus_luma(1.0f - luma, 1.0f - luma, 1.0f - luma);
00614 
00615         GetPainter().Paint2DQuadWireframe(graphics_engine, pickermarker, one_minus_luma);
00616         GetPainter().Paint2DQuadColor(graphics_engine, channel_area_->GetGeometry(), BaseChannelTop, BaseChannelBottom, BaseChannelBottom, BaseChannelTop);
00617       }
00618 
00619       // Draw Marker on Base Chanel Area
00620       DrawBaseChannelMarker(graphics_engine);
00621     }
00622   }
00623 
00624   void ColorEditor::DrawContent(GraphicsEngine &graphics_engine, bool force_draw)
00625   {
00626     redcheck->ProcessDraw(graphics_engine, force_draw);
00627     redtext->ProcessDraw(graphics_engine, force_draw);
00628     greencheck->ProcessDraw(graphics_engine, force_draw);
00629     greentext->ProcessDraw(graphics_engine, force_draw);
00630     bluecheck->ProcessDraw(graphics_engine, force_draw);
00631     bluetext->ProcessDraw(graphics_engine, force_draw);
00632 
00633     huecheck->ProcessDraw(graphics_engine, force_draw);
00634     hue_text_entry_->ProcessDraw(graphics_engine, force_draw);
00635     saturationcheck->ProcessDraw(graphics_engine, force_draw);
00636     saturation_text_entry_->ProcessDraw(graphics_engine, force_draw);
00637     valuecheck->ProcessDraw(graphics_engine, force_draw);
00638     value_text_entry_->ProcessDraw(graphics_engine, force_draw);
00639   }
00640 
00641   void ColorEditor::RecvMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags)
00642   {
00643     float BaseValue;
00644 
00645     if (m_ColorModel == color::RGB)
00646     {
00647       if (y < 0)
00648         BaseValue = 1.0f;
00649       else if (y > channel_area_->GetBaseHeight())
00650         BaseValue = 0.0f;
00651       else
00652         BaseValue = 1.0f - (float) y / (float) channel_area_->GetBaseHeight();
00653 
00654       if (color_channel_ == color::RED)
00655         rgb_.red = BaseValue;
00656       else if (color_channel_ == color::GREEN)
00657         rgb_.green = BaseValue;
00658       else if (color_channel_ == color::BLUE)
00659         rgb_.blue = BaseValue;
00660 
00661       hsv_ = color::HueSaturationValue(rgb_);
00662     }
00663 
00664     if (m_ColorModel == color::HSV)
00665     {
00666       if (y < 0)
00667         BaseValue = 1.0f;
00668       else if (y > channel_area_->GetBaseHeight())
00669         BaseValue = 0.0f;
00670       else
00671         BaseValue = 1.0f - (float) y / (float) channel_area_->GetBaseHeight();
00672 
00673       if (color_channel_ == color::HUE)
00674       {
00675         hsv_.hue = BaseValue;
00676 
00677         if (hsv_.hue >= 1.0f) hsv_.hue = 0.0f;
00678       }
00679       else if (color_channel_ == color::SATURATION)
00680         hsv_.saturation = BaseValue;
00681       else if (color_channel_ == color::VALUE)
00682         hsv_.value = BaseValue;
00683 
00684       rgb_ = color::RedGreenBlue(hsv_);
00685     }
00686 
00687     redtext->SetText(m_Validator.ToString(255 * rgb_.red));
00688     greentext->SetText(m_Validator.ToString(255 * rgb_.green));
00689     bluetext->SetText(m_Validator.ToString(255 * rgb_.blue));
00690     hue_text_entry_->SetText(m_Validator.ToString(360 * hsv_.hue));
00691     saturation_text_entry_->SetText(m_Validator.ToString(100 * hsv_.saturation));
00692     value_text_entry_->SetText(m_Validator.ToString(100 * hsv_.value));
00693     m_VertMarkerPosition = Point(Clamp<int> (x, 0, channel_area_->GetBaseWidth() - 1), Clamp<int> (y, 0, channel_area_->GetBaseHeight() - 1));
00694 
00695     sigChange.emit(this);
00696     QueueDraw();
00697   }
00698 
00699   void ColorEditor::RecvMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags)
00700   {
00701     QueueDraw();
00702   }
00703 
00704   void ColorEditor::RecvMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags)
00705   {
00706     RecvMouseDown(x, y, button_flags, key_flags);
00707   }
00708 
00709   void ColorEditor::RecvPickerMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags)
00710   {
00711     if (m_ColorModel == color::RGB)
00712     {
00713       if (color_channel_ == color::RED)
00714       {
00715         if (y < 0)
00716           rgb_.green = 1.0f;
00717         else if (y > picker_area_->GetBaseHeight())
00718           rgb_.green = 0.0f;
00719         else
00720           rgb_.green = 1.0f - (float) y / (float) picker_area_->GetBaseHeight();
00721 
00722         if (x < 0)
00723           rgb_.blue = 0.0f;
00724         else if (x > picker_area_->GetBaseWidth())
00725           rgb_.blue = 1.0f;
00726         else
00727           rgb_.blue = (float) x / (float) picker_area_->GetBaseWidth();
00728 
00729       }
00730 
00731       if (color_channel_ == color::GREEN)
00732       {
00733         if (y < 0)
00734           rgb_.red = 1.0f;
00735         else if (y > picker_area_->GetBaseHeight())
00736           rgb_.red = 0.0f;
00737         else
00738           rgb_.red = 1.0f - (float) y / (float) picker_area_->GetBaseHeight();
00739 
00740         if (x < 0)
00741           rgb_.blue = 0.0f;
00742         else if (x > picker_area_->GetBaseWidth())
00743           rgb_.blue = 1.0f;
00744         else
00745           rgb_.blue = (float) x / (float) picker_area_->GetBaseWidth();
00746 
00747       }
00748 
00749       if (color_channel_ == color::BLUE)
00750       {
00751         if (x < 0)
00752           rgb_.red = 0.0f;
00753         else if (x > picker_area_->GetBaseWidth())
00754           rgb_.red = 1.0f;
00755         else
00756           rgb_.red = (float) x / (float) picker_area_->GetBaseWidth();
00757 
00758         if (y < 0)
00759           rgb_.green = 1.0f;
00760         else if (y > picker_area_->GetBaseHeight())
00761           rgb_.green = 0.0f;
00762         else
00763           rgb_.green = 1.0f - (float) y / (float) picker_area_->GetBaseHeight();
00764       }
00765 
00766       hsv_ = color::HueSaturationValue(rgb_);
00767       m_MarkerPosition = Point(Clamp<int> (x, 0, picker_area_->GetBaseWidth() - 1), Clamp<int> (y, 0, picker_area_->GetBaseHeight() - 1));
00768     }
00769 
00770     if (m_ColorModel == color::HSV)
00771     {
00772       if (color_channel_ == color::HUE)
00773       {
00774         if (y < 0)
00775           hsv_.value = 1.0f;
00776         else if (y > picker_area_->GetBaseHeight())
00777           hsv_.value = 0.0f;
00778         else
00779           hsv_.value = 1.0f - (float) y / (float) picker_area_->GetBaseHeight();
00780 
00781         if (x < 0)
00782           hsv_.saturation = 0.0f;
00783         else if (x > picker_area_->GetBaseWidth())
00784           hsv_.saturation = 1.0f;
00785         else
00786           hsv_.saturation = (float) x / (float) picker_area_->GetBaseWidth();
00787 
00788       }
00789 
00790       if (color_channel_ == color::SATURATION)
00791       {
00792         if (y < 0)
00793           hsv_.value = 1.0f;
00794         else if (y > picker_area_->GetBaseHeight())
00795           hsv_.value = 0.0f;
00796         else
00797           hsv_.value = 1.0f - (float) y / (float) picker_area_->GetBaseHeight();
00798 
00799         if (x < 0)
00800           hsv_.hue = 0.0f;
00801         else if (x >= picker_area_->GetBaseWidth())
00802           hsv_.hue = 0.0f;
00803         else
00804           hsv_.hue = (float) x / (float) picker_area_->GetBaseWidth();
00805 
00806       }
00807 
00808       if (color_channel_ == color::VALUE)
00809       {
00810         if (x < 0)
00811           hsv_.hue = 0.0f;
00812         else if (x >= picker_area_->GetBaseWidth())
00813           hsv_.hue = 0.0f;
00814         else
00815           hsv_.hue = (float) x / (float) picker_area_->GetBaseWidth();
00816 
00817         if (y < 0)
00818           hsv_.saturation = 1.0f;
00819         else if (y > picker_area_->GetBaseHeight())
00820           hsv_.saturation = 0.0f;
00821         else
00822           hsv_.saturation = 1.0f - (float) y / (float) picker_area_->GetBaseHeight();
00823       }
00824 
00825       rgb_ = color::RedGreenBlue(hsv_);
00826       m_MarkerPosition = Point(Clamp<int> (x, 0, picker_area_->GetBaseWidth() - 1), Clamp<int> (y, 0, picker_area_->GetBaseHeight() - 1));
00827     }
00828 
00829 
00830     redtext->SetText(m_Validator.ToString(255 * rgb_.red));
00831     greentext->SetText(m_Validator.ToString(255 * rgb_.green));
00832     bluetext->SetText(m_Validator.ToString(255 * rgb_.blue));
00833     hue_text_entry_->SetText(m_Validator.ToString(360 * hsv_.hue));
00834     saturation_text_entry_->SetText(m_Validator.ToString(100 * hsv_.saturation));
00835     value_text_entry_->SetText(m_Validator.ToString(100 * hsv_.value));
00836 
00837     sigChange.emit(this);
00838     QueueDraw();
00839   }
00840 
00841   void ColorEditor::RecvPickerMouseUp(int x, int y, unsigned long button_flags, unsigned long key_flags)
00842   {
00843     QueueDraw();
00844   }
00845 
00846   void ColorEditor::RecvPickerMouseDrag(int x, int y, int dx, int dy, unsigned long button_flags, unsigned long key_flags)
00847   {
00848     RecvPickerMouseDown(x, y, button_flags, key_flags);
00849   }
00850 
00851   void ColorEditor::RecvCheckColorModel0(AbstractButton *button, color::Model color_mode, color::Channel color_channel)
00852   {
00853     RecvCheckColorModel(true, color_mode, color_channel);
00854   }
00855 
00856   void ColorEditor::RecvCheckColorModel(bool b, color::Model color_mode, color::Channel color_channel)
00857   {
00858     if (b)
00859     {
00860       if ((color_mode == color::HSV) && (m_ColorModel == color::RGB))
00861       {
00862         hsv_ = color::HueSaturationValue(rgb_);
00863       }
00864 
00865       if ((color_mode == color::RGB) && (m_ColorModel == color::HSV))
00866       {
00867         rgb_ = color::RedGreenBlue(hsv_);
00868       }
00869 
00870       m_ColorModel = color_mode;
00871       color_channel_ = color_channel;
00872     }
00873 
00874     if (b && (color_mode == color::RGB))
00875     {
00876       int x = 0;
00877       int y = 0;
00878       int z = 1;
00879 
00880       if (color_channel_ == color::RED)
00881       {
00882         z = (1.0f - rgb_.red) * picker_area_->GetBaseHeight();
00883         y = (1.0f - rgb_.green) * picker_area_->GetBaseHeight();
00884         x = rgb_.blue * picker_area_->GetBaseWidth();
00885       }
00886 
00887       if (color_channel_ == color::GREEN)
00888       {
00889         z = (1.0f - rgb_.green) * picker_area_->GetBaseHeight();
00890         y = (1.0f - rgb_.red) * picker_area_->GetBaseHeight();
00891         x = rgb_.blue * picker_area_->GetBaseWidth();
00892       }
00893 
00894       if (color_channel_ == color::BLUE)
00895       {
00896         z = (1.0f - rgb_.blue) * picker_area_->GetBaseHeight();
00897         y = (1.0f - rgb_.green) * picker_area_->GetBaseHeight();
00898         x = rgb_.red * picker_area_->GetBaseWidth();
00899       }
00900 
00901       m_VertMarkerPosition = Point(Clamp<int> (0, 0, channel_area_->GetBaseWidth() - 1), Clamp<int> (z, 0, channel_area_->GetBaseHeight() - 1));
00902       m_MarkerPosition = Point(Clamp<int> (x, 0, picker_area_->GetBaseWidth() - 1), Clamp<int> (y, 0, picker_area_->GetBaseHeight() - 1));
00903 
00904       redtext->SetText(m_Validator.ToString(255 * rgb_.red));
00905       greentext->SetText(m_Validator.ToString(255 * rgb_.green));
00906       bluetext->SetText(m_Validator.ToString(255 * rgb_.blue));
00907     }
00908 
00909     if (b && (color_mode == color::HSV))
00910     {
00911       int x = 0;
00912       int y = 0;
00913       int z = 1;
00914 
00915       if (color_channel_ == color::HUE)
00916       {
00917         z = (1.0f - hsv_.hue) * picker_area_->GetBaseHeight();
00918         y = (1.0f - hsv_.value) * picker_area_->GetBaseHeight();
00919         x = hsv_.saturation * picker_area_->GetBaseWidth();
00920       }
00921 
00922       if (color_channel_ == color::SATURATION)
00923       {
00924         z = (1.0f - hsv_.saturation) * picker_area_->GetBaseHeight();
00925         y = (1.0f - hsv_.value) * picker_area_->GetBaseHeight();
00926         x = hsv_.hue * picker_area_->GetBaseWidth();
00927       }
00928 
00929       if (color_channel_ == color::VALUE)
00930       {
00931         z = (1.0f - hsv_.value) * picker_area_->GetBaseHeight();
00932         y = (1.0f - hsv_.saturation) * picker_area_->GetBaseHeight();
00933         x = hsv_.hue * picker_area_->GetBaseWidth();
00934       }
00935 
00936       m_VertMarkerPosition = Point(Clamp<int> (0, 0, channel_area_->GetBaseWidth() - 1), Clamp<int> (z, 0, channel_area_->GetBaseHeight() - 1));
00937       m_MarkerPosition = Point(Clamp<int> (x, 0, picker_area_->GetBaseWidth() - 1), Clamp<int> (y, 0, picker_area_->GetBaseHeight() - 1));
00938 
00939       hue_text_entry_->SetText(m_Validator.ToString(360 * hsv_.hue));
00940       saturation_text_entry_->SetText(m_Validator.ToString(100 * hsv_.saturation));
00941       value_text_entry_->SetText(m_Validator.ToString(100 * hsv_.value));
00942     }
00943 
00944     QueueDraw();
00945   }
00946 
00947   Color ColorEditor::GetRGBColor() const
00948   {
00949     return Color(rgb_);
00950   }
00951 
00952   void ColorEditor::SetRGB(Color const& rgb)
00953   {
00954     SetRGB(rgb.red, rgb.green, rgb.blue );
00955   }
00956 
00957   void ColorEditor::SetRGB(double r, double g, double b)
00958   {
00959     rgb_ = color::RedGreenBlue(Clamp<double>(r, 0.0, 1.0),
00960                                Clamp<double>(g, 0.0, 1.0),
00961                                Clamp<double> (b, 0.0, 1.0));
00962     hsv_ = color::HueSaturationValue(rgb_);
00963     RecvCheckColorModel(true, m_ColorModel, color_channel_);
00964     sigChange.emit(this);
00965   }
00966 
00967   void ColorEditor::SetHSV(double h, double s, double v)
00968   {
00969     hsv_ = color::HueSaturationValue(Clamp<double>(h, 0.0, 1.0),
00970                                      Clamp<double>(s, 0.0, 1.0),
00971                                      Clamp<double>(v, 0.0, 1.0));
00972     rgb_ = color::RedGreenBlue(hsv_);
00973     RecvCheckColorModel(true, m_ColorModel, color_channel_);
00974     sigChange.emit(this);
00975   }
00976 
00977   void ColorEditor::SetRed(double red)
00978   {
00979     SetRGB(red, rgb_.green, rgb_.blue);
00980   }
00981 
00982   void ColorEditor::SetGreen(double green)
00983   {
00984     SetRGB(rgb_.red, green, rgb_.blue);
00985   }
00986 
00987   void ColorEditor::SetBlue(double blue)
00988   {
00989     SetRGB(rgb_.red, rgb_.green, blue);
00990   }
00991 
00992   void ColorEditor::SetHue(double hue)
00993   {
00994     SetHSV(hue, hsv_.saturation, hsv_.value);
00995   }
00996 
00997   void ColorEditor::SetSaturation(double saturation)
00998   {
00999     SetHSV(hsv_.hue, saturation, hsv_.value);
01000   }
01001 
01002   void ColorEditor::SetValue(double value)
01003   {
01004     SetHSV(hsv_.hue, hsv_.saturation, value);
01005   }
01006 
01007   void ColorEditor::SetColorModel(color::Model colormodel,
01008                                   color::Channel colorchannel)
01009   {
01010     if (colormodel == color::HSV)
01011     {
01012       if ((colorchannel != color::HUE) &&
01013            (colorchannel != color::SATURATION) &&
01014            (colorchannel != color::VALUE))
01015       {
01016         nuxDebugMsg("[ColorEditor::SetColorModel] The color model(HSV) and the color channel don't match.");
01017         return;
01018       }
01019     }
01020 
01021     if (colormodel == color::RGB)
01022     {
01023       if ((colorchannel != color::RED) &&
01024            (colorchannel != color::GREEN) &&
01025            (colorchannel != color::BLUE))
01026       {
01027         nuxDebugMsg("[ColorEditor::SetColorModel] The color model(RGB) and the color channel don't match.");
01028         return;
01029       }
01030     }
01031 
01032     m_ColorModel = colormodel;
01033     color_channel_ = colorchannel;
01034     RecvCheckColorModel(true, m_ColorModel, color_channel_);
01035 
01036     /*FIXME - disabled because we lost radiogroup 
01037     if (color_channel_ == color::RED)
01038       radiogroup->ActivateButton(redcheck);
01039     else if (color_channel_ == color::GREEN)
01040       radiogroup->ActivateButton(greencheck);
01041     else if (color_channel_ == color::BLUE)
01042       radiogroup->ActivateButton(bluecheck);
01043     else if (color_channel_ == color::HUE)
01044       radiogroup->ActivateButton(huecheck);
01045     else if (color_channel_ == color::SATURATION)
01046       radiogroup->ActivateButton(saturationcheck);
01047     else if (color_channel_ == color::VALUE)
01048       radiogroup->ActivateButton(valuecheck);
01049     */
01050 
01051   }
01052 
01053   color::Model ColorEditor::GetColorModel() const
01054   {
01055     return m_ColorModel;
01056   }
01057 
01058   color::Channel ColorEditor::GetColorChannel() const
01059   {
01060     return color_channel_;
01061   }
01062 
01063   bool ColorEditor::AcceptKeyNavFocus()
01064   {
01065     return false;
01066   }
01067 }