GraphicsViewPreferences.js 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /**
  2. * Copyright (c) 2011-2018 by Andrew Mustun. All rights reserved.
  3. *
  4. * This file is part of the QCAD project.
  5. *
  6. * QCAD 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 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * QCAD 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 QCAD.
  18. */
  19. function GraphicsViewPreferences() {
  20. }
  21. GraphicsViewPreferences.getPreferencesCategory = function() {
  22. return [qsTr("Graphics View"), qsTr("Appearance")];
  23. };
  24. GraphicsViewPreferences.initPreferences = function(pageWidget, calledByPrefDialog, document) {
  25. var widgets = getWidgets(pageWidget);
  26. // remove item "Default":
  27. widgets["ZeroWeightWeight"].removeItem(0);
  28. // remove item "0.00":
  29. widgets["ZeroWeightWeight"].removeItem(0);
  30. var cbCapStyle = widgets["PenCapStyle"];
  31. cbCapStyle.visible = false;
  32. var lCapStyle = widgets["PenCapStyle_Label"];
  33. lCapStyle.visible = false;
  34. // cbCapStyle.addItem(qsTr("Round Cap"), Qt.RoundCap.valueOf());
  35. // cbCapStyle.addItem(qsTr("Flat Cap"), Qt.FlatCap.valueOf());
  36. // cbCapStyle.addItem(qsTr("Square Cap"), Qt.SquareCap.valueOf());
  37. widgets["Threads"].setItemText(0, widgets["Threads"].itemText(0) + " (" + Math.min(RS.getIdealThreadCount(), 6) + ")");
  38. widgets["DefaultLineweight"].setLineweight(RLineweight.Weight000);
  39. };
  40. GraphicsViewPreferences.applyPreferences = function(doc, mdiChild) {
  41. if (isNull(doc) || isNull(mdiChild)) {
  42. return;
  43. }
  44. var numThreads = RSettings.getIntValue("GraphicsView/Threads", Math.min(RS.getIdealThreadCount(), 6));
  45. //EAction.handleUserMessage(qsTr("Threads:") + " " + numThreads);
  46. var di = mdiChild.getDocumentInterface();
  47. var scenes = di.getGraphicsScenes();
  48. for (var si = 0; si<scenes.length; ++si) {
  49. var scene = scenes[si];
  50. var views = scene.getGraphicsViews();
  51. for (var vi = 0; vi<views.length; ++vi) {
  52. var view = views[vi];
  53. // setting bg color to invalid will automatically update it:
  54. if (!view.isPrintPreview()) {
  55. view.setBackgroundColor(new QColor());
  56. }
  57. if (isFunction(view.setNumThreads)) {
  58. view.setNumThreads(numThreads);
  59. }
  60. view.regenerate(false);
  61. }
  62. }
  63. };