From 9b4aa89f1ac229ac288cab742fb446a034af4969 Mon Sep 17 00:00:00 2001 From: J-F Martel Date: Wed, 1 Jul 2020 08:35:52 -0400 Subject: [PATCH] Resize pour l'utilisation en remote desktop. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TODO: Rendre ça configurable... --- sources/GlobalDefine.h | 4 +- sources/GuiElements/LogViewPage.cpp | 105 +++++++++++++++++----------- sources/GuiElements/LogViewPage.h | 5 +- sources/MainPanel.cpp | 8 +-- 4 files changed, 74 insertions(+), 48 deletions(-) diff --git a/sources/GlobalDefine.h b/sources/GlobalDefine.h index aeb96ef..f5f72df 100644 --- a/sources/GlobalDefine.h +++ b/sources/GlobalDefine.h @@ -28,8 +28,8 @@ #define GLOBAL_DEFINE //Screen resolution. -#define SCREEN_RES_WIDTH 1600 -#define SCREEN_RES_HEIGHT 768 +#define SCREEN_RES_WIDTH 1200 +#define SCREEN_RES_HEIGHT 700 //Train parameters #define MR_BOGIE_LENGTH 1.52 //meters diff --git a/sources/GuiElements/LogViewPage.cpp b/sources/GuiElements/LogViewPage.cpp index 76f2585..0a444ac 100644 --- a/sources/GuiElements/LogViewPage.cpp +++ b/sources/GuiElements/LogViewPage.cpp @@ -36,7 +36,7 @@ #include -CLogViewPage::CLogViewPage(QGraphicsWidget *Parent) +CLogViewPage::CLogViewPage(QGraphicsWidget *Parent, qreal LogViewPageWidth) { QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); setParentItem(Parent); @@ -75,15 +75,19 @@ CLogViewPage::CLogViewPage(QGraphicsWidget *Parent) qreal PlotsHeight = ((GRAPH_ZONE_HEIGHT - 60) / (ZT1_DISCREET_PLOTTABLE_NB_PARAM + ZT1_ANALOG_PLOTTABLE_NB_PARAM)); PlotsHeight -= (20 + (10/(ZT1_DISCREET_PLOTTABLE_NB_PARAM + ZT1_ANALOG_PLOTTABLE_NB_PARAM))) ; //space between plots int CurPlot = 0; + mGraphZoneWidth = LogViewPageWidth - GRAPH_ZONE_X_OFFSET; + qDebug("Size = %f",mGraphZoneWidth); for(int param = 0; param < ZT1_DISCREET_PLOTTABLE_NB_PARAM; param++) { mZT1DiscreetPlots[param].mParamID = param; mZT1DiscreetPlots[param].mDataSet = new QList; CGraphItem * NewGraph = new CGraphItem(this); + //NewGraph->setPos(GRAPH_ZONE_X_OFFSET,param * (40 + 20)+10); NewGraph->setPos(GRAPH_ZONE_X_OFFSET,CurPlot++ * (PlotsHeight + 20) + 10); - NewGraph->resize(GRAPH_ZONE_WIDTH,PlotsHeight); + // NewGraph->resize(GRAPH_ZONE_WIDTH,PlotsHeight); + NewGraph->resize(mGraphZoneWidth,PlotsHeight); mZT1DiscreetPlots[param].mPlotGaph = NewGraph; mZT1DiscreetPlots[param].mPlotGaph->SetData(mZT1DiscreetPlots[param].mDataSet); @@ -105,7 +109,8 @@ CLogViewPage::CLogViewPage(QGraphicsWidget *Parent) CAnalogGraphItem *NewGraph = new CAnalogGraphItem(this); // NewGraph->setPos(GRAPH_ZONE_X_OFFSET,(param+DISCREET_PLOTTABLE_NB_PARAM)*(40+20)+10); NewGraph->setPos(GRAPH_ZONE_X_OFFSET,CurPlot++ * (PlotsHeight + 20) + 10); - NewGraph->resize(GRAPH_ZONE_WIDTH,PlotsHeight); + //NewGraph->resize(GRAPH_ZONE_WIDTH,PlotsHeight); + NewGraph->resize(mGraphZoneWidth,PlotsHeight); mZT1AnalogPlots[param].mPlotGaph = NewGraph; mZT1AnalogPlots[param].mPlotGaph->SetData(mZT1AnalogPlots[param].mDataSet); @@ -115,7 +120,8 @@ CLogViewPage::CLogViewPage(QGraphicsWidget *Parent) mZT1AnalogPlots[ZT1_ANALOG_PLOTTABLE_TRAIN_SPEED_PARAM].mPlotGaph->SetLabel("Vitesse",GRAPH_ZONE_X_OFFSET); mZT1AnalogPlots[ZT1_ANALOG_PLOTTABLE_PGCOMBINED_PARAM].mPlotGaph->SetLabel("Détection",GRAPH_ZONE_X_OFFSET); mZT1AnalogPlots[ZT1_ANALOG_PLOTTABLE_SDF_DATA_PARAM].mPlotGaph->SetLabel("SDF",GRAPH_ZONE_X_OFFSET); - mZT1AnalogPlots[ZT1_ANALOG_PLOTTABLE_SDF_DATA_PARAM].mPlotGaph->resize(GRAPH_ZONE_WIDTH,PlotsHeight*2); + // mZT1AnalogPlots[ZT1_ANALOG_PLOTTABLE_SDF_DATA_PARAM].mPlotGaph->resize(GRAPH_ZONE_WIDTH,PlotsHeight*2); + mZT1AnalogPlots[ZT1_ANALOG_PLOTTABLE_SDF_DATA_PARAM].mPlotGaph->resize(mGraphZoneWidth,PlotsHeight*2); //Setup ZT2 Plots PlotsHeight = ((GRAPH_ZONE_HEIGHT - 60) / (ZT2_DISCREET_PLOTTABLE_NB_PARAM + ZT2_ANALOG_PLOTTABLE_NB_PARAM)); @@ -146,9 +152,11 @@ CLogViewPage::CLogViewPage(QGraphicsWidget *Parent) mVCursor->resize(3,GRAPH_ZONE_HEIGHT); mVCursor->setZValue(2); - mHCursor = new CHorizontalGraphCursorWidget(GRAPH_ZONE_WIDTH,this); + // mHCursor = new CHorizontalGraphCursorWidget(GRAPH_ZONE_WIDTH,this); + mHCursor = new CHorizontalGraphCursorWidget(mGraphZoneWidth,this); mHCursor->setPos(0,0); - mHCursor->resize(GRAPH_ZONE_WIDTH,3); + //mHCursor->resize(GRAPH_ZONE_WIDTH,3); + mHCursor->resize(mGraphZoneWidth,3); mHCursor->setZValue(2); // mCursorPosTxt = new QGraphicsTextItem(this); @@ -157,22 +165,22 @@ CLogViewPage::CLogViewPage(QGraphicsWidget *Parent) mCursorsZoomButton = new CTextButtonWidget("Zoom curseurs"); mCursorsZoomButton->setParentItem(this); - mCursorsZoomButton->setPos(10,700); + mCursorsZoomButton->setPos(10,700-100); connect(mCursorsZoomButton,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*))); mZoomInButton = new CTextButtonWidget(" +",0,25,25); mZoomInButton->setParentItem(this); - mZoomInButton->setPos(95,730); + mZoomInButton->setPos(95,730-100); connect(mZoomInButton,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*))); mZoomOutButton = new CTextButtonWidget(" -",0,25,25); mZoomOutButton->setParentItem(this); - mZoomOutButton->setPos(10,730); + mZoomOutButton->setPos(10,730-100); connect(mZoomOutButton,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*))); mZoomResetButton = new CTextButtonWidget(" R",0,25,25); mZoomResetButton->setParentItem(this); - mZoomResetButton->setPos(50,730); + mZoomResetButton->setPos(50,730-100); connect(mZoomResetButton,SIGNAL(TxtButtonClicked(CTextButtonWidget*)),this,SLOT(ButtonClicked(CTextButtonWidget*))); mStaticCursor1 = new CVerticalGraphCursorWidget(GRAPH_ZONE_HEIGHT,this); @@ -188,39 +196,46 @@ CLogViewPage::CLogViewPage(QGraphicsWidget *Parent) mStaticCursor2->hide(); mStaticCursorDeltaTimeTxt = new QGraphicsTextItem(this); - mStaticCursorDeltaTimeTxt->setPos(130,700); + mStaticCursorDeltaTimeTxt->setPos(130,700-100); mStaticCursorDeltaTimeTxt->setPlainText("Delta curseurs: ?"); mCursor1TimeTxt = new QGraphicsTextItem(this); - mCursor1TimeTxt->setPlainText("Position curseur 1 : ?"); - mCursor1TimeTxt->setPos(130,720); + mCursor1TimeTxt->setPlainText("Curs. 1 : ?"); + mCursor1TimeTxt->setPos(130,720-100); mCursor2TimeTxt = new QGraphicsTextItem(this); - mCursor2TimeTxt->setPlainText("Position curseur 2 : ?"); - mCursor2TimeTxt->setPos(130,740); + mCursor2TimeTxt->setPlainText("Curs. 2 : ?"); + mCursor2TimeTxt->setPos(130,740-100); mPassageStats1Txt = new QGraphicsTextItem(this); - mPassageStats1Txt->setPos(350,700); + mPassageStats1Txt->setPos(250,700-100); mPassageStats1Txt->setPlainText("Date & heure: \nStation : \nPosition : "); mPassageStats2Txt = new QGraphicsTextItem(this); - mPassageStats2Txt->setPos(600,700); + mPassageStats2Txt->setPos(500,700-100); mPassageStats2Txt->setPlainText("Vitesse Max : Mph\nVitesse Min: Mph\nSeuil PG : "); - mRuler = new CGraphRulerWidget(GRAPH_ZONE_WIDTH,this); + +// mRuler = new CGraphRulerWidget(GRAPH_ZONE_WIDTH,this); + mRuler = new CGraphRulerWidget(mGraphZoneWidth,this); mRuler->setZValue(1); - mRuler->setPos(GRAPH_ZONE_X_OFFSET,670); - mRuler->resize(GRAPH_ZONE_WIDTH,20); + mRuler->setPos(GRAPH_ZONE_X_OFFSET,670-100); +// mRuler->resize(GRAPH_ZONE_WIDTH,20); + mRuler->resize(mGraphZoneWidth,20); - mRankRuler = new CRankRulerWidget(GRAPH_ZONE_WIDTH,this); +// mRankRuler = new CRankRulerWidget(GRAPH_ZONE_WIDTH,this); + mRankRuler = new CRankRulerWidget(mGraphZoneWidth,this); mRankRuler->setZValue(1); - mRankRuler->resize(GRAPH_ZONE_WIDTH,10); - mRankRuler->setPos(GRAPH_ZONE_X_OFFSET,655); +// mRankRuler->resize(GRAPH_ZONE_WIDTH,10); + mRankRuler->resize(mGraphZoneWidth,10); + mRankRuler->setPos(GRAPH_ZONE_X_OFFSET,655-100); mRankRuler->SetLabel("Rang:",GRAPH_ZONE_X_OFFSET); - mEventRuler = new CEventRulerWidget(GRAPH_ZONE_WIDTH,this); +// mEventRuler = new CEventRulerWidget(GRAPH_ZONE_WIDTH,this); + mEventRuler = new CEventRulerWidget(mGraphZoneWidth,this); mEventRuler->setZValue(1); - mEventRuler->resize(GRAPH_ZONE_WIDTH,10); - mEventRuler->setPos(GRAPH_ZONE_X_OFFSET,640); +// mEventRuler->resize(GRAPH_ZONE_WIDTH,10); + mEventRuler = new CEventRulerWidget(mGraphZoneWidth,this); + mEventRuler->setPos(GRAPH_ZONE_X_OFFSET,640-100); mEventRuler->SetLabel("Décl:",GRAPH_ZONE_X_OFFSET); mScrollAnimationTimer.start(); @@ -626,7 +641,8 @@ void CLogViewPage::SetLogData(CLogElement *element) mTotalTimeSpan = mMaxTime - mMinTime; mCurTimeSpan = mStopTime - mStartTime; - mCurPixelTickValue = (qreal)GRAPH_ZONE_WIDTH/(qreal)mCurTimeSpan; //pixels per microsecs +// mCurPixelTickValue = (qreal)GRAPH_ZONE_WIDTH/(qreal)mCurTimeSpan; //pixels per microsecs + mCurPixelTickValue = mGraphZoneWidth/(qreal)mCurTimeSpan; //pixels per microsecs mCursorPos = mStartTime; mPassageStats1Txt->setPlainText(QString().sprintf("Date & heure: %s\nStation : %s\nPosition : %s",mPassageDateTime.toUtf8().data(),mPassageStation.toUtf8().data()," ")); @@ -753,7 +769,8 @@ void CLogViewPage::ZoomIn(bool CenterOnCursor) //Convert time to pixels (in the new timespan) quint64 AbsoluteTime = CursorTime - StartTime; - qreal PixelsPernSecs = (qreal)GRAPH_ZONE_WIDTH/(NewSpan); +// qreal PixelsPernSecs = (qreal)GRAPH_ZONE_WIDTH/(NewSpan); + qreal PixelsPernSecs = mGraphZoneWidth/(NewSpan); qreal Pixel = AbsoluteTime * PixelsPernSecs; Pixel += GRAPH_ZONE_X_OFFSET; @@ -762,7 +779,8 @@ void CLogViewPage::ZoomIn(bool CenterOnCursor) qreal DeltaX = Pixel - mCursorPos; //convert this to an amount of time - qint64 DeltaTime = ((qint64)DeltaX * NewSpan)/GRAPH_ZONE_WIDTH; +// qint64 DeltaTime = ((qint64)DeltaX * NewSpan)/GRAPH_ZONE_WIDTH; + qint64 DeltaTime = ((qint64)DeltaX * NewSpan)/mGraphZoneWidth; //Shift the timespan to center the zoom on the cursor. StartTime += DeltaTime; @@ -815,7 +833,8 @@ void CLogViewPage::ZoomOut(bool CenterOnCursor) //Convert time to pixels (in the new timespan) quint64 AbsoluteTime = CursorTime - StartTime; - qreal PixelsPernSecs = (qreal)GRAPH_ZONE_WIDTH/(NewSpan); + //qreal PixelsPernSecs = (qreal)GRAPH_ZONE_WIDTH/(NewSpan); + qreal PixelsPernSecs = mGraphZoneWidth/(NewSpan); qreal Pixel = AbsoluteTime * PixelsPernSecs; Pixel += GRAPH_ZONE_X_OFFSET; @@ -824,7 +843,8 @@ void CLogViewPage::ZoomOut(bool CenterOnCursor) qreal DeltaX = Pixel - mCursorPos; //convert this to an amount of time - qint64 DeltaTime = ((qint64)DeltaX * NewSpan)/GRAPH_ZONE_WIDTH; +// qint64 DeltaTime = ((qint64)DeltaX * NewSpan)/GRAPH_ZONE_WIDTH; + qint64 DeltaTime = ((qint64)DeltaX * NewSpan)/mGraphZoneWidth; //Shift the timespan to center the zoom on the cursor. StartTime += DeltaTime; @@ -874,7 +894,7 @@ void CLogViewPage::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) mStaticCursor1->SetCursor(); mStaticCursor1->show(); UpdateStaticCursorsDeltaTime(); - mCursor1TimeTxt->setPlainText(QString().sprintf("Position curseur 1 : %d ms",(int)(mStaticCursor1->GetTime()/1000000))); + mCursor1TimeTxt->setPlainText(QString().sprintf("Curs. 1 : %d ms",(int)(mStaticCursor1->GetTime()/1000000))); } } if(event->button() == Qt::RightButton) @@ -883,7 +903,7 @@ void CLogViewPage::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) mStaticCursor2->SetTime(GetTimeForPixel(event->pos().x())); mStaticCursor2->SetCursor(); mStaticCursor2->show(); - mCursor2TimeTxt->setPlainText(QString().sprintf("Position curseur 2 : %d ms",(int)(mStaticCursor2->GetTime()/1000000))); + mCursor2TimeTxt->setPlainText(QString().sprintf("Curs. 2 : %d ms",(int)(mStaticCursor2->GetTime()/1000000))); UpdateStaticCursorsDeltaTime(); } @@ -898,7 +918,8 @@ void CLogViewPage::mouseMoveEvent(QGraphicsSceneMouseEvent *event) //qreal Drag = 50; if(Drag != 0) { - qreal TickValue = (qreal)GRAPH_ZONE_WIDTH/(qreal)mCurTimeSpan; +// qreal TickValue = (qreal)GRAPH_ZONE_WIDTH/(qreal)mCurTimeSpan; + qreal TickValue = mGraphZoneWidth/(qreal)mCurTimeSpan; qreal temp = TickValue/Drag; //quint64 usecsDrag = 1/(mCurPixelTickValue/Drag); qint64 usecsDrag = 1/temp; @@ -1049,7 +1070,8 @@ void CLogViewPage::hoverMoveEvent(QGraphicsSceneHoverEvent *event) qreal CLogViewPage::GetPixelForTime(quint64 Time) { quint64 AbsoluteTime = Time - mStartTime; - qreal PixelsPernSecs = (qreal)GRAPH_ZONE_WIDTH/(mStopTime - mStartTime); + //qreal PixelsPernSecs = (qreal)GRAPH_ZONE_WIDTH/(mStopTime - mStartTime); + qreal PixelsPernSecs = mGraphZoneWidth/(mStopTime - mStartTime); qreal Pixel = AbsoluteTime * PixelsPernSecs; return Pixel+GRAPH_ZONE_X_OFFSET; @@ -1058,7 +1080,8 @@ qreal CLogViewPage::GetPixelForTime(quint64 Time) quint64 CLogViewPage::GetTimeForPixel(qreal PixelPos) { PixelPos -= GRAPH_ZONE_X_OFFSET; - qreal nSecsPerPixels = (mStopTime - mStartTime)/GRAPH_ZONE_WIDTH; + //qreal nSecsPerPixels = (mStopTime - mStartTime)/GRAPH_ZONE_WIDTH; + qreal nSecsPerPixels = (mStopTime - mStartTime)/mGraphZoneWidth; quint64 AbsoluteTimeForPixel = PixelPos*nSecsPerPixels; quint64 Time = mStartTime + AbsoluteTimeForPixel; @@ -1083,7 +1106,8 @@ unsigned int CLogViewPage::ShowSpan(quint64 TimePos1, quint64 TimePos2) } mCurTimeSpan = mStopTime - mStartTime; - mCurPixelTickValue = (qreal)GRAPH_ZONE_WIDTH/(qreal)mCurTimeSpan; //pixels per microsecs + //mCurPixelTickValue = (qreal)GRAPH_ZONE_WIDTH/(qreal)mCurTimeSpan; //pixels per microsecs + mCurPixelTickValue = mGraphZoneWidth/(qreal)mCurTimeSpan; //pixels per microsecs if(mViewType == ZT1_LOG_TYPE) { @@ -1156,9 +1180,10 @@ unsigned int CLogViewPage::AdjustMouseCursorPos(qreal PosX, qreal PosY) mCursorPos = PosX; if(mCursorPos < GRAPH_ZONE_X_OFFSET) mCursorPos = GRAPH_ZONE_X_OFFSET; - else if(mCursorPos > GRAPH_ZONE_WIDTH + GRAPH_ZONE_X_OFFSET) - mCursorPos = GRAPH_ZONE_WIDTH + GRAPH_ZONE_X_OFFSET; - +// else if(mCursorPos > GRAPH_ZONE_WIDTH + GRAPH_ZONE_X_OFFSET) +// mCursorPos = GRAPH_ZONE_WIDTH + GRAPH_ZONE_X_OFFSET; + else if(mCursorPos > mGraphZoneWidth + GRAPH_ZONE_X_OFFSET) + mCursorPos = mGraphZoneWidth + GRAPH_ZONE_X_OFFSET; qreal HCursorPos = PosY; if(HCursorPos > GRAPH_ZONE_HEIGHT) HCursorPos = GRAPH_ZONE_HEIGHT; diff --git a/sources/GuiElements/LogViewPage.h b/sources/GuiElements/LogViewPage.h index 72f339d..697e19d 100644 --- a/sources/GuiElements/LogViewPage.h +++ b/sources/GuiElements/LogViewPage.h @@ -47,7 +47,7 @@ #include "QElapsedTimer" #define GRAPH_ZONE_WIDTH 880//900 -#define GRAPH_ZONE_HEIGHT 650//700 +#define GRAPH_ZONE_HEIGHT 600//700 #define GRAPH_ZONE_X_OFFSET 70 //50 #define MIN_TIMESPAN 1000 //1 millisecond @@ -123,7 +123,7 @@ class CLogViewPage : public CGuiPage { Q_OBJECT public: - CLogViewPage(QGraphicsWidget *Parent = 0); + CLogViewPage(QGraphicsWidget *Parent = 0, qreal LogViewPageWidth = 800); ~CLogViewPage(); COutilZT *mProgramHandle; @@ -167,6 +167,7 @@ private: QGraphicsTextItem *mStaticCursorDeltaTimeTxt, *mCursor1TimeTxt, *mCursor2TimeTxt; QGraphicsTextItem *mPassageStats1Txt,*mPassageStats2Txt; QString mPassageDateTime, mPassageStation; + qreal mGraphZoneWidth; CGraphRulerWidget *mRuler; CRankRulerWidget *mRankRuler; diff --git a/sources/MainPanel.cpp b/sources/MainPanel.cpp index a7656ef..268e043 100644 --- a/sources/MainPanel.cpp +++ b/sources/MainPanel.cpp @@ -90,10 +90,10 @@ Panel::Panel() //////////////////////// setMouseTracking(true); - + qreal LogViewPageWidth(650); mMainPage = new CMainPage(); - mDatabaseModeLogViewPage = new CLogViewPage(); + mDatabaseModeLogViewPage = new CLogViewPage(0,LogViewPageWidth); mDatabaseModeLogListPage = new CLogsListPage(); mOptionsPage = new COptionsPage(); mNetworkZTListPage = new CNetworkZTListPage(); @@ -101,7 +101,7 @@ Panel::Panel() mRemoteZTPage = new CRemoteZTPage(); mZTLogViewerPage = new CZTLogViewerPage(0,false); mNetworkModeLogListPage = new CLogsListPage(); - mNetworkModeLogViewPage = new CLogViewPage(); + mNetworkModeLogViewPage = new CLogViewPage(0,LogViewPageWidth); mProgressBarPage = new CProgressBarPage(); mRemoteZTCtrlPage = new CRemoteZTCtrlPage(); mDatabaseMgrPage = new CDatabaseMgrPage(); @@ -131,7 +131,7 @@ Panel::Panel() mMainPage->setZValue(0); mMainPage->resize(10,SCREEN_RES_HEIGHT); - const static int LogViewPageWidth(750); + mDatabaseModeLogViewPage->setPos(SCREEN_RES_WIDTH-LogViewPageWidth,0); mDatabaseModeLogViewPage->resize(LogViewPageWidth/*980*/,SCREEN_RES_HEIGHT); mDatabaseModeLogViewPage->setZValue(0);