-
Notifications
You must be signed in to change notification settings - Fork 2
/
VisoarMapPieces.py
115 lines (96 loc) · 5.14 KB
/
VisoarMapPieces.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
from VisoarSettings import *
from PyQt5.QtWebEngineWidgets import QWebEngineView
from OpenVisus import *
from OpenVisus.gui import *
from PyQt5.QtGui import QFont,QPainter,QPen
from PyQt5.QtCore import QUrl, Qt, QSize, QDir, QRect
from PyQt5.QtWidgets import QApplication, QHBoxLayout, QLineEdit,QLabel, QLineEdit, QTextEdit, QGridLayout
from PyQt5.QtWidgets import QMainWindow, QPushButton, QVBoxLayout,QSplashScreen,QProxyStyle, QStyle, QAbstractButton
from PyQt5.QtWidgets import QWidget, QMessageBox, QGroupBox, QShortcut,QSizePolicy,QPlainTextEdit,QDialog, QFileDialog
from PyQt5.QtWidgets import QTableWidget,QTableWidgetItem
from gradient import *
import pyqtgraph
class ViSOARGradientMapViewWidget(QDialog):
def __init__(self, parent,viewer ):
super(QDialog, self).__init__(parent)
self.parent = parent
self.viewer =viewer
#self.MODE = MODE
self.setGeometry(30, 30, 600, 200)
self.gradient = Gradient()
# self.gradient.setGradient([(1, QColor.fromRgbF(0, .4, 0.2)),
# (.75, QColor.fromRgbF(0, .4, 0.2)),
# (0.5, QColor.fromRgbF(0, .83, 0.94)),
# (0.25, QColor.fromRgbF(.008, .14, .286)),
# (0, QColor.fromRgbF(.019, .019, .56))])
# self.gradient.setGradient([(1, QColor.fromRgbF(.2, .4, 0)),
# (.75, QColor.fromRgbF(.2, .4, 0)),
# (0.5, QColor.fromRgbF(.94, .83, 0)),
# (0.25, QColor.fromRgbF(.286, .14, .008)),
# (0, QColor.fromRgbF(.56, .019, .019) ) ])
self.gradient.setGradient([(1, QColor.fromRgbF(.2, .4, 0)),
(.75, QColor.fromRgbF(.2, .4, 0)),
(0.5, QColor.fromRgbF(0.94, 0.65 ,0.27)),
(0.25, QColor.fromRgbF(0.74, 0.34 ,0.04)),
(0, QColor.fromRgbF(.56, .019, .019) ) ])
self.gradient.setGeometry(0,0,300,100)
# self.timeline = QTimeLine(500 )
# self.timeline.setFrameRange(-1, 1)
#gradient.setGradient([(0, 'purple'), (.25, 'purple'), (0.5, 'red'), (0.75, 'yellow'),
# (1, 'green'), ])
self.mapPiecesLayout = QVBoxLayout()
self.mapPiecesLayout.addWidget(self.gradient)
self.outputGradient = createPushButton('Output Colors',
lambda: self.applyNewScript())
self.outputGradient.setStyleSheet(NOBACKGROUND_PUSH_BUTTON)
self.outputGradient.setStyleSheet(' color: #045951;')
self.mapPiecesLayout.addWidget(self.outputGradient)
# self.mapPiecesLayout.addWidget(self.timeline)
self.SHOW_HISTOGRAM = False
if (self.SHOW_HISTOGRAM):
self.imv = pyqtgraph.ImageView()
self.mapPiecesLayout.addWidget(self.imv)
self.setLayout(self.mapPiecesLayout)
# self.pen = QPen( QColor(0, 0, 0)) # set lineColor
# self.pen.setWidth(3) # set lineWidth
# self.brush = QBrush( QColor(255, 255, 255, 255)) # set fillColor
# self.polygon = self.createPoly(8, 150, 0) # polygon with n points, radius, angle of the first point
def applyNewScript(self):
MODE = self.parent.comboBoxATab.currentText()
if MODE == 'R G B':
script = self.gradient.makeNewScriptRGB()
elif MODE == 'R NIR (Sentera NDVI)':
script = self.gradient.makeNewScriptMAPIR()
print('Error applyNewScript: NOT YET IMPLEMENTED: Sentera script')
elif MODE == 'MapIR only (OCNIR)':
script = self.gradient.makeNewScriptMAPIR()
elif MODE == 'RedEdge NIR (Sentera NDRE)':
script = self.gradient.makeNewScriptMAPIR()
print('Error applyNewScript: NOT YET IMPLEMENTED:RedEdge script')
else:
script = self.gradient.makeNewScriptRGB()
#MODE="NDVI"
# if (MODE == "RGB"):
# script = self.gradient.makeNewScriptRGB()
# elif (MODE == 'AGROCAM'):
# script = self.gradient.makeNewScriptAgrocam()
# else:
# script = self.gradient.makeNewScriptMAPIR()
self.parent.runThisScript(script, self.viewer)
# def createPoly(self, n, r, s):
# polygon = QPolygonF()
# w = 360 / n # angle per step
# for i in range(n): # add the points of polygon
# t = w * i + s
# x = r * math.cos(math.radians(t))
# y = r * math.sin(math.radians(t))
# polygon.append( QPointF(self.width() / 2 + x, self.height() / 2 + y))
#
# return polygon
#
#
# def paintEvent(self, event):
# painter = QPainter(self)
# painter.setPen(self.pen)
# painter.setBrush(self.brush)
# painter.drawPolygon(self.polygon)