Dev
This commit is contained in:
@@ -15,7 +15,8 @@ CCableTestBench::~CCableTestBench()
|
||||
|
||||
int CCableTestBench::Start()
|
||||
{
|
||||
w->showMaximized();
|
||||
// w->showMaximized();
|
||||
w->show();
|
||||
|
||||
mMainPageHandle = w->mMainPage;
|
||||
mVisualInspPageHandle = w->mVisualInspPage;
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
#ifndef CABLETESTBENCHDEFS_H
|
||||
#define CABLETESTBENCHDEFS_H
|
||||
|
||||
|
||||
class CConnectorDefs
|
||||
{
|
||||
public:
|
||||
enum eConnectorType
|
||||
{
|
||||
UNKNOWN_CONNECTOR_TYPE,
|
||||
INPUT_6_PINS_CONNECTOR_TYPE,
|
||||
INPUT_14_PINS_CONNECTOR_TYPE,
|
||||
INPUT_24_PINS_CONNECTOR_TYPE,
|
||||
INPUT_72_PINS_CONNECTOR_TYPE,
|
||||
INPUT_90_PINS_CONNECTOR_TYPE,
|
||||
INPUT_108_PINS_CONNECTOR_TYPE,
|
||||
INPUT_120_PINS_CONNECTOR_TYPE,
|
||||
OUTPUT_6_PINS_CONNECTOR_TYPE,
|
||||
OUTPUT_14_PINS_CONNECTOR_TYPE,
|
||||
OUTPUT_24_PINS_CONNECTOR_TYPE,
|
||||
OUTPUT_72_PINS_CONNECTOR_TYPE,
|
||||
OUTPUT_108_PINS_CONNECTOR_TYPE
|
||||
};
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // CABLETESTBENCHDEFS_H
|
||||
@@ -18,8 +18,8 @@
|
||||
<rect>
|
||||
<x>850</x>
|
||||
<y>20</y>
|
||||
<width>501</width>
|
||||
<height>501</height>
|
||||
<width>376</width>
|
||||
<height>537</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
@@ -42,7 +42,7 @@
|
||||
<number>3</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="">
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>60</x>
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
#include "ConnectorClickZoneWidget.h"
|
||||
#include <QPainter>
|
||||
#include <QColor>
|
||||
|
||||
CConnectorClickZoneWidget::CConnectorClickZoneWidget(CConnectorDefs::eConnectorType ConType, QWidget *parent) :
|
||||
QWidget(parent),
|
||||
mConType(ConType)
|
||||
{
|
||||
mConSelected = false;
|
||||
mSelectionColor = Qt::red;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CConnectorClickZoneWidget::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
if(mConSelected == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QPainter painter(this);
|
||||
QPen pen;
|
||||
|
||||
pen.setStyle(Qt::SolidLine);
|
||||
pen.setWidth(10);
|
||||
pen.setBrush(mSelectionColor);
|
||||
painter.setPen(pen);
|
||||
|
||||
painter.drawRect(QRect(0,0,geometry().width(),geometry().height()));
|
||||
|
||||
}
|
||||
|
||||
void CConnectorClickZoneWidget::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
|
||||
// if(mConSelected == false)
|
||||
// {
|
||||
// mConSelected = true;
|
||||
// }
|
||||
// else if(mConSelected == true)
|
||||
// {
|
||||
// mConSelected = false;
|
||||
// }
|
||||
|
||||
// repaint();
|
||||
emit ConnectorZoneClicked(this);
|
||||
}
|
||||
|
||||
void CConnectorClickZoneWidget::resizeEvent(QResizeEvent *)
|
||||
{
|
||||
}
|
||||
|
||||
void CConnectorClickZoneWidget::SelectConnector(bool Select, QColor color)
|
||||
{
|
||||
mConSelected = Select;
|
||||
mSelectionColor = color;
|
||||
repaint();
|
||||
}
|
||||
|
||||
void CConnectorClickZoneWidget::ClearConnectorSelection()
|
||||
{
|
||||
SelectConnector(false);
|
||||
}
|
||||
|
||||
CConnectorDefs::eConnectorType CConnectorClickZoneWidget::GetConnectorType()
|
||||
{
|
||||
return mConType;
|
||||
}
|
||||
|
||||
bool CConnectorClickZoneWidget::IsConSelected()
|
||||
{
|
||||
return mConSelected;
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
#ifndef CONNECTORCLICKZONEWIDGET_H
|
||||
#define CONNECTORCLICKZONEWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "CableTestBenchDefs.h"
|
||||
|
||||
|
||||
class QColor;
|
||||
|
||||
class CConnectorClickZoneWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CConnectorClickZoneWidget(CConnectorDefs::eConnectorType ConType, QWidget *parent = 0);
|
||||
void paintEvent(QPaintEvent *);
|
||||
void mouseReleaseEvent(QMouseEvent *);
|
||||
void resizeEvent(QResizeEvent *);
|
||||
|
||||
void SelectConnector(bool Select = true, QColor color = Qt::red);
|
||||
void ClearConnectorSelection();
|
||||
|
||||
CConnectorDefs::eConnectorType GetConnectorType();
|
||||
bool IsConSelected();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
CConnectorDefs::eConnectorType mConType;
|
||||
bool mConSelected;
|
||||
QColor mSelectionColor;
|
||||
|
||||
signals:
|
||||
void ConnectorZoneClicked(CConnectorClickZoneWidget *ConType);
|
||||
public slots:
|
||||
|
||||
};
|
||||
|
||||
#endif // CONNECTORCLICKZONEWIDGET_H
|
||||
@@ -1,16 +1,237 @@
|
||||
#include "ConnectorSelectWidget.h"
|
||||
#include <QPainter>
|
||||
#include "CableTestBenchDefs.h"
|
||||
|
||||
CConnectorSelectWidget::CConnectorSelectWidget(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
{
|
||||
mConnectorLayoutPixmap = new QPixmap("./images/connecteurs.png");
|
||||
mCurSelConnector = CConnectorDefs::UNKNOWN_CONNECTOR_TYPE;
|
||||
|
||||
|
||||
//Create click zones for all input connectors
|
||||
CConnectorClickZoneWidget *InputClickZoneHandle;
|
||||
|
||||
//6 pins
|
||||
InputClickZoneHandle = new CConnectorClickZoneWidget(CConnectorDefs::INPUT_6_PINS_CONNECTOR_TYPE,this);
|
||||
InputClickZoneHandle->setGeometry(7,149,53,54);
|
||||
InputClickZoneHandle->show();
|
||||
InputClickZoneHandle->raise();
|
||||
connect(InputClickZoneHandle,SIGNAL(ConnectorZoneClicked(CConnectorClickZoneWidget*)),this,SLOT(InputConnectorZoneClicked(CConnectorClickZoneWidget*)));
|
||||
mInputClickZoneList.append(InputClickZoneHandle);
|
||||
|
||||
//14 pins
|
||||
InputClickZoneHandle = new CConnectorClickZoneWidget(CConnectorDefs::INPUT_14_PINS_CONNECTOR_TYPE,this);
|
||||
InputClickZoneHandle->setGeometry(7,23,53,54);
|
||||
InputClickZoneHandle->show();
|
||||
InputClickZoneHandle->raise();
|
||||
connect(InputClickZoneHandle,SIGNAL(ConnectorZoneClicked(CConnectorClickZoneWidget*)),this,SLOT(InputConnectorZoneClicked(CConnectorClickZoneWidget*)));
|
||||
mInputClickZoneList.append(InputClickZoneHandle);
|
||||
|
||||
//24 pins
|
||||
InputClickZoneHandle = new CConnectorClickZoneWidget(CConnectorDefs::INPUT_24_PINS_CONNECTOR_TYPE,this);
|
||||
InputClickZoneHandle->setGeometry(92,23,48,86);
|
||||
InputClickZoneHandle->show();
|
||||
InputClickZoneHandle->raise();
|
||||
connect(InputClickZoneHandle,SIGNAL(ConnectorZoneClicked(CConnectorClickZoneWidget*)),this,SLOT(InputConnectorZoneClicked(CConnectorClickZoneWidget*)));
|
||||
mInputClickZoneList.append(InputClickZoneHandle);
|
||||
|
||||
//72 pins
|
||||
InputClickZoneHandle = new CConnectorClickZoneWidget(CConnectorDefs::INPUT_72_PINS_CONNECTOR_TYPE,this);
|
||||
InputClickZoneHandle->setGeometry(92,149,47,120);
|
||||
InputClickZoneHandle->show();
|
||||
InputClickZoneHandle->raise();
|
||||
connect(InputClickZoneHandle,SIGNAL(ConnectorZoneClicked(CConnectorClickZoneWidget*)),this,SLOT(InputConnectorZoneClicked(CConnectorClickZoneWidget*)));
|
||||
mInputClickZoneList.append(InputClickZoneHandle);
|
||||
|
||||
//90 pins
|
||||
InputClickZoneHandle = new CConnectorClickZoneWidget(CConnectorDefs::INPUT_90_PINS_CONNECTOR_TYPE,this);
|
||||
InputClickZoneHandle->setGeometry(17,286,33,73);
|
||||
InputClickZoneHandle->show();
|
||||
InputClickZoneHandle->raise();
|
||||
connect(InputClickZoneHandle,SIGNAL(ConnectorZoneClicked(CConnectorClickZoneWidget*)),this,SLOT(InputConnectorZoneClicked(CConnectorClickZoneWidget*)));
|
||||
mInputClickZoneList.append(InputClickZoneHandle);
|
||||
|
||||
//108 pins
|
||||
InputClickZoneHandle = new CConnectorClickZoneWidget(CConnectorDefs::INPUT_108_PINS_CONNECTOR_TYPE,this);
|
||||
InputClickZoneHandle->setGeometry(92,308,47,149);
|
||||
InputClickZoneHandle->show();
|
||||
InputClickZoneHandle->raise();
|
||||
connect(InputClickZoneHandle,SIGNAL(ConnectorZoneClicked(CConnectorClickZoneWidget*)),this,SLOT(InputConnectorZoneClicked(CConnectorClickZoneWidget*)));
|
||||
mInputClickZoneList.append(InputClickZoneHandle);
|
||||
|
||||
//120 pins
|
||||
InputClickZoneHandle = new CConnectorClickZoneWidget(CConnectorDefs::INPUT_120_PINS_CONNECTOR_TYPE,this);
|
||||
InputClickZoneHandle->setGeometry(13,382,42,74);
|
||||
InputClickZoneHandle->show();
|
||||
InputClickZoneHandle->raise();
|
||||
connect(InputClickZoneHandle,SIGNAL(ConnectorZoneClicked(CConnectorClickZoneWidget*)),this,SLOT(InputConnectorZoneClicked(CConnectorClickZoneWidget*)));
|
||||
mInputClickZoneList.append(InputClickZoneHandle);
|
||||
|
||||
//Create selection zones for all output connectors
|
||||
CConnectorClickZoneWidget *OutputSelectZoneHandle;
|
||||
|
||||
//6 pins
|
||||
OutputSelectZoneHandle = new CConnectorClickZoneWidget(CConnectorDefs::OUTPUT_6_PINS_CONNECTOR_TYPE,this);
|
||||
OutputSelectZoneHandle->setGeometry(329,149,38,38);
|
||||
OutputSelectZoneHandle->show();
|
||||
OutputSelectZoneHandle->raise();
|
||||
mOutputSelectZoneList.append(OutputSelectZoneHandle);
|
||||
|
||||
//14 pins
|
||||
OutputSelectZoneHandle = new CConnectorClickZoneWidget(CConnectorDefs::OUTPUT_14_PINS_CONNECTOR_TYPE,this);
|
||||
OutputSelectZoneHandle->setGeometry(327,23,41,42);
|
||||
OutputSelectZoneHandle->show();
|
||||
OutputSelectZoneHandle->raise();
|
||||
mOutputSelectZoneList.append(OutputSelectZoneHandle);
|
||||
|
||||
//24 pins
|
||||
OutputSelectZoneHandle = new CConnectorClickZoneWidget(CConnectorDefs::OUTPUT_24_PINS_CONNECTOR_TYPE,this);
|
||||
OutputSelectZoneHandle->setGeometry(235,23,48,86);
|
||||
OutputSelectZoneHandle->show();
|
||||
OutputSelectZoneHandle->raise();
|
||||
mOutputSelectZoneList.append(OutputSelectZoneHandle);
|
||||
|
||||
//72 pins
|
||||
OutputSelectZoneHandle = new CConnectorClickZoneWidget(CConnectorDefs::OUTPUT_72_PINS_CONNECTOR_TYPE,this);
|
||||
OutputSelectZoneHandle->setGeometry(235,149,46,121);
|
||||
OutputSelectZoneHandle->show();
|
||||
OutputSelectZoneHandle->raise();
|
||||
mOutputSelectZoneList.append(OutputSelectZoneHandle);
|
||||
|
||||
//108 pins
|
||||
OutputSelectZoneHandle = new CConnectorClickZoneWidget(CConnectorDefs::OUTPUT_108_PINS_CONNECTOR_TYPE,this);
|
||||
OutputSelectZoneHandle->setGeometry(235,308,47,148);
|
||||
OutputSelectZoneHandle->show();
|
||||
OutputSelectZoneHandle->raise();
|
||||
mOutputSelectZoneList.append(OutputSelectZoneHandle);
|
||||
|
||||
}
|
||||
|
||||
void CConnectorSelectWidget::paintEvent(QPaintEvent *)
|
||||
void CConnectorSelectWidget::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
QPainter painter(this);
|
||||
|
||||
painter.drawPixmap(this->rect(),mConnectorLayoutPixmap->scaled(this->size()));
|
||||
painter.drawPixmap(0,0,*mConnectorLayoutPixmap);
|
||||
|
||||
QPen pen;
|
||||
|
||||
// pen.setStyle(Qt::SolidLine);
|
||||
// pen.setWidth(10);
|
||||
// pen.setBrush(Qt::red);
|
||||
// painter.setPen(pen);
|
||||
|
||||
//painter.drawRect(this->geometry());
|
||||
// painter.drawRect(QRect(7,149,53,54));
|
||||
|
||||
}
|
||||
|
||||
void CConnectorSelectWidget::InputConnectorZoneClicked(CConnectorClickZoneWidget *ConClickZone)
|
||||
{
|
||||
qDebug("Connector zone clicked: %d",ConClickZone->GetConnectorType());
|
||||
|
||||
if(ConClickZone->IsConSelected() == true)
|
||||
{
|
||||
ClearAllConnectorsSelections();
|
||||
mCurSelConnector = CConnectorDefs::UNKNOWN_CONNECTOR_TYPE;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
CConnectorClickZoneWidget *OutputSelZone = 0;
|
||||
switch(ConClickZone->GetConnectorType())
|
||||
{
|
||||
case CConnectorDefs::INPUT_6_PINS_CONNECTOR_TYPE:
|
||||
{
|
||||
OutputSelZone = FindOutputSelectionZone(CConnectorDefs::OUTPUT_6_PINS_CONNECTOR_TYPE);
|
||||
|
||||
break;
|
||||
}
|
||||
case CConnectorDefs::INPUT_14_PINS_CONNECTOR_TYPE:
|
||||
{
|
||||
OutputSelZone = FindOutputSelectionZone(CConnectorDefs::OUTPUT_14_PINS_CONNECTOR_TYPE);
|
||||
break;
|
||||
}
|
||||
case CConnectorDefs::INPUT_24_PINS_CONNECTOR_TYPE:
|
||||
{
|
||||
OutputSelZone = FindOutputSelectionZone(CConnectorDefs::OUTPUT_24_PINS_CONNECTOR_TYPE);
|
||||
break;
|
||||
}
|
||||
case CConnectorDefs::INPUT_72_PINS_CONNECTOR_TYPE:
|
||||
{
|
||||
OutputSelZone = FindOutputSelectionZone(CConnectorDefs::OUTPUT_72_PINS_CONNECTOR_TYPE);
|
||||
break;
|
||||
}
|
||||
case CConnectorDefs::INPUT_90_PINS_CONNECTOR_TYPE:
|
||||
case CConnectorDefs::INPUT_108_PINS_CONNECTOR_TYPE:
|
||||
case CConnectorDefs::INPUT_120_PINS_CONNECTOR_TYPE:
|
||||
{
|
||||
OutputSelZone = FindOutputSelectionZone(CConnectorDefs::OUTPUT_108_PINS_CONNECTOR_TYPE);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(OutputSelZone != 0)
|
||||
{
|
||||
OutputSelZone->SelectConnector(true,Qt::darkGreen);
|
||||
}
|
||||
ConClickZone->SelectConnector();
|
||||
}
|
||||
}
|
||||
|
||||
CConnectorSelectWidget::~CConnectorSelectWidget()
|
||||
{
|
||||
qDebug("Destroyed");
|
||||
for(int i = 0; i < mInputClickZoneList.size(); i++)
|
||||
{
|
||||
delete mInputClickZoneList.at(i);
|
||||
}
|
||||
mInputClickZoneList.clear();
|
||||
|
||||
for(int i = 0; i < mOutputSelectZoneList.size(); i++)
|
||||
{
|
||||
delete mOutputSelectZoneList.at(i);
|
||||
}
|
||||
mOutputSelectZoneList.clear();
|
||||
}
|
||||
|
||||
int CConnectorSelectWidget::ClearAllOutputConSelections()
|
||||
{
|
||||
for(int i = 0; i < mOutputSelectZoneList.size(); i++)
|
||||
{
|
||||
mOutputSelectZoneList.at(i)->ClearConnectorSelection();
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int CConnectorSelectWidget::ClearAllInputConSelections()
|
||||
{
|
||||
for(int i = 0; i < mInputClickZoneList.size(); i++)
|
||||
{
|
||||
mInputClickZoneList.at(i)->ClearConnectorSelection();
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int CConnectorSelectWidget::ClearAllConnectorsSelections()
|
||||
{
|
||||
ClearAllOutputConSelections();
|
||||
ClearAllInputConSelections();
|
||||
}
|
||||
|
||||
CConnectorClickZoneWidget* CConnectorSelectWidget::FindOutputSelectionZone(CConnectorDefs::eConnectorType type)
|
||||
{
|
||||
for(int i = 0; i < mOutputSelectZoneList.size(); i++)
|
||||
{
|
||||
if(mOutputSelectZoneList.at(i)->GetConnectorType() == type)
|
||||
{
|
||||
return mOutputSelectZoneList.at(i);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2,20 +2,38 @@
|
||||
#ifndef CCONNECTORSELECTWIDGET_H
|
||||
#define CCONNECTORSELECTWIDGET_H
|
||||
|
||||
#include "GlobalDefine.h"
|
||||
#include <QWidget>
|
||||
#include "ConnectorClickZoneWidget.h"
|
||||
#include <QList>
|
||||
|
||||
class CConnectorSelectWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CConnectorSelectWidget(QWidget *parent = 0);
|
||||
virtual ~CConnectorSelectWidget();
|
||||
void paintEvent(QPaintEvent *);
|
||||
|
||||
QPixmap *mConnectorLayoutPixmap;
|
||||
|
||||
QList<CConnectorClickZoneWidget*> mInputClickZoneList;
|
||||
QList<CConnectorClickZoneWidget*> mOutputSelectZoneList;
|
||||
|
||||
int ClearAllOutputConSelections();
|
||||
int ClearAllInputConSelections();
|
||||
int ClearAllConnectorsSelections();
|
||||
|
||||
CConnectorClickZoneWidget* FindOutputSelectionZone(CConnectorDefs::eConnectorType type);
|
||||
|
||||
|
||||
private:
|
||||
CConnectorDefs::eConnectorType mCurSelConnector;
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
void InputConnectorZoneClicked(CConnectorClickZoneWidget *ConType);
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user