KOffice – TDE office suite
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

kis_wetness_visualisation_filter.cc 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * kis_wetness_visualisation_filter.cc -- Part of Chalk
  3. *
  4. * Copyright (c) 2005 Bart Coppens <kde@bartcoppens.be>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. #include <kdebug.h>
  21. #include <tdelocale.h>
  22. #include "kis_meta_registry.h"
  23. #include <kis_view.h>
  24. #include <kis_image.h>
  25. #include <kis_colorspace_factory_registry.h>
  26. #include <kis_factory.h>
  27. #include "kis_wet_colorspace.h"
  28. #include <kis_debug_areas.h>
  29. #include "kis_wetness_visualisation_filter.h"
  30. WetnessVisualisationFilter::WetnessVisualisationFilter(KisView* view)
  31. : m_view(view), m_action(0) {
  32. connect(&m_timer, TQT_SIGNAL(timeout()), this, TQT_SLOT(slotTimeout()));
  33. }
  34. // XXX this needs to work on a per-layer basis!
  35. void WetnessVisualisationFilter::setAction(TDEToggleAction* action) {
  36. m_action = action;
  37. if (!m_action)
  38. return;
  39. KisWetColorSpace* cs = dynamic_cast<KisWetColorSpace*>(
  40. KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("WET", ""),"") );
  41. Q_ASSERT(cs);
  42. m_action->setChecked(cs->paintWetness());
  43. }
  44. void WetnessVisualisationFilter::slotActivated() {
  45. kdDebug(DBG_AREA_CMS) << "activated" << endl;
  46. if (!m_action) {
  47. kdDebug(DBG_AREA_CMS) << "no action" << endl;
  48. return;
  49. }
  50. KisWetColorSpace* cs = dynamic_cast<KisWetColorSpace*>(
  51. KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("WET", ""),"") );
  52. Q_ASSERT(cs);
  53. if (!m_action->isChecked()) {
  54. m_timer.stop();
  55. cs->setPaintWetness(false);
  56. } else {
  57. m_timer.start(500);
  58. cs->setPaintWetness(true);
  59. }
  60. }
  61. void WetnessVisualisationFilter::slotTimeout() {
  62. KisWetColorSpace* cs = dynamic_cast<KisWetColorSpace*>(
  63. KisMetaRegistry::instance()->csRegistry()->getColorSpace(KisID("WET", ""),"") );
  64. Q_ASSERT(cs);
  65. if (!cs) return;
  66. cs->resetPhase();
  67. }
  68. #include "kis_wetness_visualisation_filter.moc"