[Recolor] Moving on: Class Hierarchy
Hello, I started off with the final coding sub-phase for the mid-term yesterday. The whole ColorSelector class and the ColorWheelSelector class and their inheritance is confusing me. I need to get the ColorWheelSelector to access the GimpColorWheel member _wheel of ColorWheelSelector. How do I get hold of that object ?
I tried this snippet, but it seems to be in effective !
*SPColorSelector *csel =SP_COLOR_SELECTOR(g_object_get_data((GObject*)psel->selector, "color-selector"));* *ColorNotebook *nb = dynamic_cast<ColorNotebook*>(csel->base);* * * *ColorWheelSelector *wsel = dynamic_cast<ColorWheelSelector*>(SP_IS_COLOR_WHEEL_SELECTOR(nb->getCurrentSelector())); * * * *GimpColorWheel *wheel = wsel->getGimpWheel() ;* *gimp_wheel_func ( wheel ); *
Also, I need to get ColorWheelSelector because to my understanding, changing the colors from the ColorWheelSelector class object shall be a good idea. Please correct me if I am wrong in my thinking. For the final working model I will have to cut off the selection signals from the ColorWheelSelector object so that the entire selection's color isn't changed when I edit the colors on the GimpColorWheel.
I hope I am clear with my doubt on the design of the interface. Its mostly 'Where to place the interface that makes the final changes'.
-- Arshdeep Singh Third Year, Computer Engineering Delhi Technological University Ph: +91-9654115614 https://sites.google.com/site/adsingh1729/home
2013/7/23 Arshdeep Singh <moduli16@...400...>:
ColorWheelSelector *wsel = dynamic_cast<ColorWheelSelector*>(SP_IS_COLOR_WHEEL_SELECTOR(nb->getCurrentSelector()));
SP_IS_COLOR_WHEEL_SELECTOR() returns a boolean which is true when the object is of the type SPColorWheelSelector. You need to remove this call. The return type of getCurrentSelector() is ColorSelector*, and you can dynamic_cast this to ColorWheelSelector. If you get NULL, it means the type is different.
ColorWheelSelector *wsel = dynamic_cast<ColorWheelSelector*>(nb->getCurrentSelector()); if (wsel) { // the current selector is indeed a color wheel } else { // the current selector is not a color wheel }
Note that SPColorWheelSelector is a GObject and different from ColorWheelSelector. This obfuscation was introduced by Abhishek Sharma during GSoC 2010 and is still not fixed.
Regards, Krzysztof
participants (2)
-
Arshdeep Singh
-
Krzysztof Kosiński