| 1 |
2 |
peteralieb |
package edu.byu.cc.plieber.fpgaenet.modmod;
|
| 2 |
|
|
import com.trolltech.qt.gui.*;
|
| 3 |
|
|
import com.trolltech.qt.QSignalEmitter.Signal1;
|
| 4 |
|
|
import com.trolltech.qt.core.Qt;
|
| 5 |
|
|
|
| 6 |
|
|
public class ChannelConfigurationWidget extends QWidget {
|
| 7 |
|
|
|
| 8 |
|
|
public static void main(String[] args) {
|
| 9 |
|
|
QApplication.initialize(args);
|
| 10 |
|
|
|
| 11 |
|
|
ChannelConfigurationWidget testChannelConfigurationWidget = new ChannelConfigurationWidget(null);
|
| 12 |
|
|
testChannelConfigurationWidget.show();
|
| 13 |
|
|
|
| 14 |
|
|
QApplication.exec();
|
| 15 |
|
|
}
|
| 16 |
|
|
|
| 17 |
|
|
AvailableModule lblChif;
|
| 18 |
|
|
QLabel lblLEDDIP;
|
| 19 |
|
|
QLabel lblClockControl;
|
| 20 |
|
|
QLabel lblICAP;
|
| 21 |
|
|
|
| 22 |
|
|
public ChannelConfigurationWidget(QWidget parent){
|
| 23 |
|
|
super(parent);
|
| 24 |
|
|
//QLabel background = new QLabel(this);
|
| 25 |
|
|
//background.setPixmap(new QPixmap("classpath:edu/byu/cc/plieber/fpgaenet/modmod/g/configProto.png"));
|
| 26 |
|
|
//QBoxLayout layout = new QVBoxLayout();
|
| 27 |
|
|
//this.setLayout(layout);
|
| 28 |
|
|
//layout.addWidget(background);
|
| 29 |
|
|
//setAcceptDrops(true);
|
| 30 |
|
|
setMinimumSize(570, 110);
|
| 31 |
|
|
ChannelConfiguredSignal = new Signal1<ConfigurationChannel>();
|
| 32 |
|
|
ModuleRemovedSignal = new Signal1<AvailableModule>();
|
| 33 |
|
|
ModuleSelectedSignal = new Signal1<AvailableModule>();
|
| 34 |
|
|
lblChif = new AvailableModule("Channel\nInterface", this);
|
| 35 |
|
|
lblChif.move(5, 25);
|
| 36 |
|
|
lblChif.setAvailable(false);
|
| 37 |
|
|
lblChif.setLineWidth(4);
|
| 38 |
|
|
lblLEDDIP = new QLabel("LED/DIP\nControl");
|
| 39 |
|
|
lblLEDDIP.setFrameShape(QFrame.Shape.Panel);
|
| 40 |
|
|
lblLEDDIP.setMinimumSize(80, 80);
|
| 41 |
|
|
lblLEDDIP.setMaximumSize(80, 80);
|
| 42 |
|
|
lblLEDDIP.setAlignment(Qt.AlignmentFlag.AlignCenter);
|
| 43 |
|
|
lblLEDDIP.setParent(this);
|
| 44 |
|
|
lblLEDDIP.move(85, 25);
|
| 45 |
|
|
lblClockControl = new QLabel("Clock\nControl");
|
| 46 |
|
|
lblClockControl.setFrameShape(QFrame.Shape.Panel);
|
| 47 |
|
|
lblClockControl.setMinimumSize(80, 80);
|
| 48 |
|
|
lblClockControl.setMaximumSize(80, 80);
|
| 49 |
|
|
lblClockControl.setAlignment(Qt.AlignmentFlag.AlignCenter);
|
| 50 |
|
|
lblClockControl.setParent(this);
|
| 51 |
|
|
lblClockControl.move(165, 25);
|
| 52 |
|
|
lblICAP = new QLabel("ICAP Control");
|
| 53 |
|
|
lblICAP.setFrameShape(QFrame.Shape.Panel);
|
| 54 |
|
|
lblICAP.setMinimumSize(160, 80);
|
| 55 |
|
|
lblICAP.setMaximumSize(160, 80);
|
| 56 |
|
|
lblICAP.setAlignment(Qt.AlignmentFlag.AlignCenter);
|
| 57 |
|
|
lblICAP.setParent(this);
|
| 58 |
|
|
lblICAP.move(245, 25);
|
| 59 |
|
|
ConfigurationChannel cc = new ConfigurationChannel(5);
|
| 60 |
|
|
cc.ChannelConfiguredSignal.connect(this, "channelConfiguredHandler(ConfigurationChannel)");
|
| 61 |
|
|
cc.ModuleRemovedSignal.connect(this, "moduleRemovedHandler(AvailableModule)");
|
| 62 |
|
|
cc.ModuleSelectedSignal.connect(this, "moduleSelectedHandler(AvailableModule)");
|
| 63 |
|
|
this.ModuleSelectedSignal.connect(cc, "moduleSelectedHandler(AvailableModule)");
|
| 64 |
|
|
cc.setParent(this);
|
| 65 |
|
|
cc.move(405, 25);
|
| 66 |
|
|
cc = new ConfigurationChannel(6);
|
| 67 |
|
|
cc.ChannelConfiguredSignal.connect(this, "channelConfiguredHandler(ConfigurationChannel)");
|
| 68 |
|
|
cc.ModuleRemovedSignal.connect(this, "moduleRemovedHandler(AvailableModule)");
|
| 69 |
|
|
cc.ModuleSelectedSignal.connect(this, "moduleSelectedHandler(AvailableModule)");
|
| 70 |
|
|
this.ModuleSelectedSignal.connect(cc, "moduleSelectedHandler(AvailableModule)");
|
| 71 |
|
|
cc.setParent(this);
|
| 72 |
|
|
cc.move(485, 25);
|
| 73 |
|
|
}
|
| 74 |
|
|
|
| 75 |
|
|
@Override
|
| 76 |
|
|
protected void paintEvent(QPaintEvent event) {
|
| 77 |
|
|
QPainter painter = new QPainter(this);
|
| 78 |
|
|
drawBackground(painter);
|
| 79 |
|
|
}
|
| 80 |
|
|
|
| 81 |
|
|
private void drawBackground(QPainter painter) {
|
| 82 |
|
|
painter.setPen(new QPen(QColor.black, 4));
|
| 83 |
|
|
painter.drawLine(45, 15, 525, 15);
|
| 84 |
|
|
for (int i=45; i<=525; i+=80) {
|
| 85 |
|
|
painter.drawLine(i, 15, i, 25);
|
| 86 |
|
|
}
|
| 87 |
|
|
}
|
| 88 |
|
|
|
| 89 |
|
|
@Override
|
| 90 |
|
|
protected void resizeEvent(QResizeEvent arg__1) {
|
| 91 |
|
|
lblChif.move(45 - lblChif.width()/2, 65 - lblChif.height()/2);
|
| 92 |
|
|
super.resizeEvent(arg__1);
|
| 93 |
|
|
}
|
| 94 |
|
|
|
| 95 |
|
|
public Signal1<ConfigurationChannel> ChannelConfiguredSignal;
|
| 96 |
|
|
public Signal1<AvailableModule> ModuleRemovedSignal;
|
| 97 |
|
|
public Signal1<AvailableModule> ModuleSelectedSignal;
|
| 98 |
|
|
|
| 99 |
|
|
@SuppressWarnings("unused")
|
| 100 |
|
|
private void channelConfiguredHandler(ConfigurationChannel cc) {
|
| 101 |
|
|
ChannelConfiguredSignal.emit(cc);
|
| 102 |
|
|
}
|
| 103 |
|
|
|
| 104 |
|
|
@SuppressWarnings("unused")
|
| 105 |
|
|
private void moduleRemovedHandler(AvailableModule am) {
|
| 106 |
|
|
ModuleRemovedSignal.emit(am);
|
| 107 |
|
|
}
|
| 108 |
|
|
|
| 109 |
|
|
@SuppressWarnings("unused")
|
| 110 |
|
|
private void moduleSelectedHandler(AvailableModule am) {
|
| 111 |
|
|
ModuleSelectedSignal.emit(am);
|
| 112 |
|
|
}
|
| 113 |
|
|
}
|