v_net_connectivity.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. """
  2. ***************************************************************************
  3. v_net_connectivity.py
  4. ---------------------
  5. Date : December 2015
  6. Copyright : (C) 2015 by Médéric Ribreux
  7. Email : medspx at medspx dot fr
  8. ***************************************************************************
  9. * *
  10. * This program is free software; you can redistribute it and/or modify *
  11. * it under the terms of the GNU General Public License as published by *
  12. * the Free Software Foundation; either version 2 of the License, or *
  13. * (at your option) any later version. *
  14. * *
  15. ***************************************************************************
  16. """
  17. __author__ = 'Médéric Ribreux'
  18. __date__ = 'December 2015'
  19. __copyright__ = '(C) 2015, Médéric Ribreux'
  20. from .v_net import incorporatePoints, variableOutput
  21. def checkParameterValuesBeforeExecuting(alg, parameters, context):
  22. """ Verify if we have the right parameters """
  23. params = ['where', 'cats']
  24. values = []
  25. for param in params:
  26. for i in range(1, 3):
  27. values.append(
  28. alg.parameterAsString(
  29. parameters,
  30. 'set{}_{}'.format(i, param),
  31. context
  32. )
  33. )
  34. if (values[0] or values[2]) and (values[1] or values[3]):
  35. return True, None
  36. return False, alg.tr('You need to set at least setX_where or setX_cats parameters for each set!')
  37. def processCommand(alg, parameters, context, feedback):
  38. incorporatePoints(alg, parameters, context, feedback)
  39. def processOutputs(alg, parameters, context, feedback):
  40. outputParameter = {'output': ['output', 'point', 2, True]}
  41. variableOutput(alg, outputParameter, parameters, context)