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_composite_op.cc 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*
  2. * Copyright (c) 2005 Adrian Page <adrian@pagenet.plus.com>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. */
  18. #include <tdelocale.h>
  19. #include "kis_composite_op.h"
  20. //KisIDCompositeOpMap
  21. std::map<KisID, CompositeOp> KisCompositeOp::s_idOpMap;
  22. KisCompositeOp::KisCompositeOp()
  23. {
  24. m_valid = false;
  25. }
  26. KisCompositeOp::KisCompositeOp(const TQString& id)
  27. {
  28. if (s_idOpMap.empty()) {
  29. fillMap();
  30. }
  31. KisIDCompositeOpMap::const_iterator it;
  32. m_valid = false;
  33. for (it = s_idOpMap.begin(); it != s_idOpMap.end(); ++it) {
  34. const KisID& kisId = (*it).first;
  35. if (kisId.id() == id) {
  36. m_id = (*it).first;
  37. m_op = (*it).second;
  38. m_valid = true;
  39. break;
  40. }
  41. }
  42. }
  43. KisCompositeOp::KisCompositeOp(CompositeOp compositeOp)
  44. {
  45. if (s_idOpMap.empty()) {
  46. fillMap();
  47. }
  48. KisIDCompositeOpMap::const_iterator it;
  49. m_valid = false;
  50. for (it = s_idOpMap.begin(); it != s_idOpMap.end(); ++it) {
  51. CompositeOp compOp = (*it).second;
  52. if (compOp == compositeOp) {
  53. m_id = (*it).first;
  54. m_op = compositeOp;
  55. m_valid = true;
  56. break;
  57. }
  58. }
  59. }
  60. bool KisCompositeOp::operator==(const KisCompositeOp& other) const
  61. {
  62. if (isValid() && other.isValid()) {
  63. return op() == other.op();
  64. }
  65. return false;
  66. }
  67. bool KisCompositeOp::operator!=(const KisCompositeOp& other) const
  68. {
  69. return !(*this == other);
  70. }
  71. void KisCompositeOp::fillMap()
  72. {
  73. s_idOpMap[KisID("normal", i18n("Normal"))] = COMPOSITE_OVER;
  74. s_idOpMap[KisID("alphadarken", i18n("Alpha Darken"))] = COMPOSITE_ALPHA_DARKEN;
  75. s_idOpMap[KisID("in", i18n("In"))] = COMPOSITE_IN;
  76. s_idOpMap[KisID("out", i18n("Out"))] = COMPOSITE_OUT;
  77. s_idOpMap[KisID("atop", i18n("Atop"))] = COMPOSITE_ATOP;
  78. s_idOpMap[KisID("xor", i18n("Xor"))] = COMPOSITE_XOR;
  79. s_idOpMap[KisID("plus", i18n("Plus"))] = COMPOSITE_PLUS;
  80. s_idOpMap[KisID("minus", i18n("Minus"))] = COMPOSITE_MINUS;
  81. s_idOpMap[KisID("add", i18n("Add"))] = COMPOSITE_ADD;
  82. s_idOpMap[KisID("subtract", i18n("Subtract"))] = COMPOSITE_SUBTRACT;
  83. s_idOpMap[KisID("diff", i18n("Diff"))] = COMPOSITE_DIFF;
  84. s_idOpMap[KisID("multiply", i18n("Multiply"))] = COMPOSITE_MULT;
  85. s_idOpMap[KisID("divide", i18n("Divide"))] = COMPOSITE_DIVIDE;
  86. s_idOpMap[KisID("dodge", i18n("Dodge"))] = COMPOSITE_DODGE;
  87. s_idOpMap[KisID("burn", i18n("Burn"))] = COMPOSITE_BURN;
  88. s_idOpMap[KisID("bumpmap", i18n("Bumpmap"))] = COMPOSITE_BUMPMAP;
  89. s_idOpMap[KisID("copy", i18n("Copy"))] = COMPOSITE_COPY;
  90. s_idOpMap[KisID("copyred", i18n("Copy Red"))] = COMPOSITE_COPY_RED;
  91. s_idOpMap[KisID("copygreen", i18n("Copy Green"))] = COMPOSITE_COPY_GREEN;
  92. s_idOpMap[KisID("copyblue", i18n("Copy Blue"))] = COMPOSITE_COPY_BLUE;
  93. s_idOpMap[KisID("copyopacity", i18n("Copy Opacity"))] = COMPOSITE_COPY_OPACITY;
  94. s_idOpMap[KisID("clear", i18n("Clear"))] = COMPOSITE_CLEAR;
  95. s_idOpMap[KisID("dissolve", i18n("Dissolve"))] = COMPOSITE_DISSOLVE;
  96. s_idOpMap[KisID("displace", i18n("Displace"))] = COMPOSITE_DISPLACE;
  97. #if 0
  98. s_idOpMap[KisID("modulate", i18n("Modulate"))] = COMPOSITE_MODULATE;
  99. s_idOpMap[KisID("threshold", i18n("Threshold"))] = COMPOSITE_THRESHOLD;
  100. #endif
  101. s_idOpMap[KisID("nocomposition",i18n("No Composition"))] = COMPOSITE_NO;
  102. s_idOpMap[KisID("darken", i18n("Darken"))] = COMPOSITE_DARKEN;
  103. s_idOpMap[KisID("lighten", i18n("Lighten"))] = COMPOSITE_LIGHTEN;
  104. s_idOpMap[KisID("hue", i18n("Hue"))] = COMPOSITE_HUE;
  105. s_idOpMap[KisID("saturation", i18n("Saturation"))] = COMPOSITE_SATURATION;
  106. s_idOpMap[KisID("value", i18n("Value"))] = COMPOSITE_VALUE;
  107. s_idOpMap[KisID("color", i18n("Color"))] = COMPOSITE_COLOR;
  108. s_idOpMap[KisID("colorize", i18n("Colorize"))] = COMPOSITE_COLORIZE;
  109. s_idOpMap[KisID("luminize", i18n("Luminize"))] = COMPOSITE_LUMINIZE;
  110. s_idOpMap[KisID("screen", i18n("Screen"))] = COMPOSITE_SCREEN;
  111. s_idOpMap[KisID("overlay", i18n("Overlay"))] = COMPOSITE_OVERLAY;
  112. s_idOpMap[KisID("copycyan", i18n("Copy Cyan"))] = COMPOSITE_COPY_CYAN;
  113. s_idOpMap[KisID("copymagenta", i18n("Copy Magenta"))] = COMPOSITE_COPY_MAGENTA;
  114. s_idOpMap[KisID("copyyellow", i18n("Copy Yellow"))] = COMPOSITE_COPY_YELLOW;
  115. s_idOpMap[KisID("copyblack", i18n("Copy Black"))] = COMPOSITE_COPY_BLACK;
  116. s_idOpMap[KisID("erase", i18n("Erase"))] = COMPOSITE_ERASE;
  117. s_idOpMap[KisID("undefined", i18n("Undefined"))] = COMPOSITE_UNDEF;
  118. }