mirror of
https://github.com/jkriege2/JKQtPlotter.git
synced 2024-12-25 10:01:38 +08:00
improvements to linking plots (synchronization can be done by JKQtBasePlotter::synchronizeToMaster()
This commit is contained in:
parent
8ced68f619
commit
66c469dc61
@ -3154,22 +3154,77 @@ void JKQtBasePlotter::setBorder(int left, int right, int top, int bottom){
|
|||||||
if (emitPlotSignals) emit plotUpdated();
|
if (emitPlotSignals) emit plotUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
void JKQtBasePlotter::synchronizeToMaster(JKQtBasePlotter* master, bool synchronizeWidth, bool synchronizeHeight) {
|
void JKQtBasePlotter::synchronizeToMaster(JKQtBasePlotter* master, bool synchronizeWidth, bool synchronizeHeight, bool synchronizeZoomingMasterToSlave, bool synchronizeZoomingSlaveToMaster) {
|
||||||
if (!master) {
|
if (!master) {
|
||||||
resetMasterSynchronization();
|
resetMasterSynchronization();
|
||||||
}
|
}
|
||||||
masterPlotter=master;
|
masterPlotter=master;
|
||||||
|
if (masterSynchronizeHeight!=synchronizeHeight && masterSynchronizeHeight) {
|
||||||
|
disconnect(masterPlotter, SIGNAL(zoomChangedLocally(double,double,double,double,JKQtBasePlotter*)),
|
||||||
|
this, SLOT(synchronizeYAxis(double,double,double,double,JKQtBasePlotter*)));
|
||||||
|
disconnect(this, SIGNAL(zoomChangedLocally(double,double,double,double,JKQtBasePlotter*)),
|
||||||
|
masterPlotter, SLOT(synchronizeYAxis(double,double,double,double,JKQtBasePlotter*)));
|
||||||
|
}
|
||||||
|
if (masterSynchronizeWidth!=synchronizeWidth && masterSynchronizeWidth) {
|
||||||
|
disconnect(masterPlotter, SIGNAL(zoomChangedLocally(double,double,double,double,JKQtBasePlotter*)),
|
||||||
|
this, SLOT(synchronizeXAxis(double,double,double,double,JKQtBasePlotter*)));
|
||||||
|
disconnect(this, SIGNAL(zoomChangedLocally(double,double,double,double,JKQtBasePlotter*)),
|
||||||
|
masterPlotter, SLOT(synchronizeXAxis(double,double,double,double,JKQtBasePlotter*)));
|
||||||
|
}
|
||||||
masterSynchronizeHeight=synchronizeHeight;
|
masterSynchronizeHeight=synchronizeHeight;
|
||||||
masterSynchronizeWidth=synchronizeWidth;
|
masterSynchronizeWidth=synchronizeWidth;
|
||||||
|
|
||||||
|
if (masterSynchronizeWidth) {
|
||||||
|
if (synchronizeZoomingMasterToSlave) {
|
||||||
|
connect(master, SIGNAL(zoomChangedLocally(double,double,double,double,JKQtBasePlotter*)),
|
||||||
|
this, SLOT(synchronizeXAxis(double,double,double,double,JKQtBasePlotter*)));
|
||||||
|
}
|
||||||
|
if (synchronizeZoomingSlaveToMaster) {
|
||||||
|
connect(this, SIGNAL(zoomChangedLocally(double,double,double,double,JKQtBasePlotter*)),
|
||||||
|
master, SLOT(synchronizeXAxis(double,double,double,double,JKQtBasePlotter*)));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (masterSynchronizeWidth) {
|
||||||
|
if (synchronizeHeight) {
|
||||||
|
connect(master, SIGNAL(zoomChangedLocally(double,double,double,double,JKQtBasePlotter*)),
|
||||||
|
this, SLOT(synchronizeYAxis(double,double,double,double,JKQtBasePlotter*)));
|
||||||
|
}
|
||||||
|
if (synchronizeZoomingSlaveToMaster) {
|
||||||
|
connect(this, SIGNAL(zoomChangedLocally(double,double,double,double,JKQtBasePlotter*)),
|
||||||
|
master, SLOT(synchronizeYAxis(double,double,double,double,JKQtBasePlotter*)));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void JKQtBasePlotter::resetMasterSynchronization() {
|
void JKQtBasePlotter::resetMasterSynchronization() {
|
||||||
masterPlotter=nullptr;
|
masterPlotter=nullptr;
|
||||||
masterSynchronizeHeight=false;
|
masterSynchronizeHeight=false;
|
||||||
masterSynchronizeWidth=false;
|
masterSynchronizeWidth=false;
|
||||||
|
|
||||||
|
disconnect(masterPlotter, SIGNAL(zoomChangedLocally(double,double,double,double,JKQtBasePlotter*)),
|
||||||
|
this, SLOT(synchronizeXAxis(double,double,double,double,JKQtBasePlotter*)));
|
||||||
|
disconnect(this, SIGNAL(zoomChangedLocally(double,double,double,double,JKQtBasePlotter*)),
|
||||||
|
masterPlotter, SLOT(synchronizeXAxis(double,double,double,double,JKQtBasePlotter*)));
|
||||||
|
disconnect(masterPlotter, SIGNAL(zoomChangedLocally(double,double,double,double,JKQtBasePlotter*)),
|
||||||
|
this, SLOT(synchronizeYAxis(double,double,double,double,JKQtBasePlotter*)));
|
||||||
|
disconnect(this, SIGNAL(zoomChangedLocally(double,double,double,double,JKQtBasePlotter*)),
|
||||||
|
masterPlotter, SLOT(synchronizeYAxis(double,double,double,double,JKQtBasePlotter*)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void JKQtBasePlotter::synchronizeXAxis(double newxmin, double newxmax, double /*newymin*/, double /*newymax*/, JKQtBasePlotter * /*sender*/) {
|
||||||
|
setX(newxmin, newxmax);
|
||||||
|
}
|
||||||
|
|
||||||
|
void JKQtBasePlotter::synchronizeYAxis(double /*newxmin*/, double /*newxmax*/, double newymin, double newymax, JKQtBasePlotter * /*sender*/) {
|
||||||
|
setY(newymin, newymax);
|
||||||
|
}
|
||||||
|
|
||||||
|
void JKQtBasePlotter::synchronizeXYAxis(double newxmin, double newxmax, double newymin, double newymax, JKQtBasePlotter * /*sender*/) {
|
||||||
|
setXY(newxmin, newxmax, newymin, newymax);
|
||||||
|
}
|
||||||
|
|
||||||
size_t JKQtBasePlotter::addGraph(size_t xColumn, size_t yColumn, QString title, JKQTPgraphPlotstyle graphStyle) {
|
size_t JKQtBasePlotter::addGraph(size_t xColumn, size_t yColumn, QString title, JKQTPgraphPlotstyle graphStyle) {
|
||||||
if (graphStyle==JKQTPimpulsesHorizontal) {
|
if (graphStyle==JKQTPimpulsesHorizontal) {
|
||||||
|
@ -623,6 +623,12 @@ class LIB_EXPORT JKQtBasePlotter: public QObject {
|
|||||||
void getDataColumnsByUserComboBoxSelected(const QString& name);
|
void getDataColumnsByUserComboBoxSelected(const QString& name);
|
||||||
void getDataColumnsByUserItemChanged(QListWidgetItem* widgetitem);
|
void getDataColumnsByUserItemChanged(QListWidgetItem* widgetitem);
|
||||||
void showPlotData();
|
void showPlotData();
|
||||||
|
/** \brief may be connected to zoomChangedLocally() of a different plot and synchronizes the local x-axis to the other x-axis */
|
||||||
|
void synchronizeXAxis(double newxmin, double newxmax, double newymin, double newymax, JKQtBasePlotter* sender);
|
||||||
|
/** \brief may be connected to zoomChangedLocally() of a different plot and synchronizes the local y-axis to the other y-axis */
|
||||||
|
void synchronizeYAxis(double newxmin, double newxmax, double newymin, double newymax, JKQtBasePlotter* sender);
|
||||||
|
/** \brief may be connected to zoomChangedLocally() of a different plot and synchronizes the local x- and y-axis to the other x- and y-axis */
|
||||||
|
void synchronizeXYAxis(double newxmin, double newxmax, double newymin, double newymax, JKQtBasePlotter* sender);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
@ -1312,8 +1318,10 @@ class LIB_EXPORT JKQtBasePlotter: public QObject {
|
|||||||
\param master the plotter widget to synchronize to
|
\param master the plotter widget to synchronize to
|
||||||
\param synchronizeWidth do you want the plot width to be synchronized?
|
\param synchronizeWidth do you want the plot width to be synchronized?
|
||||||
\param synchronizeHeight do you want the plot height to be synchronized?
|
\param synchronizeHeight do you want the plot height to be synchronized?
|
||||||
|
\param synchronizeZoomingMasterToSlave if set, also zooming in the master leads to a modification of the linked axes in the slave
|
||||||
|
\param synchronizeZoomingSlaveToMaster if set, also zooming in the slave leads to a modification of the linked axes in the master
|
||||||
*/
|
*/
|
||||||
void synchronizeToMaster(JKQtBasePlotter* master, bool synchronizeWidth, bool synchronizeHeight);
|
void synchronizeToMaster(JKQtBasePlotter* master, bool synchronizeWidth, bool synchronizeHeight, bool synchronizeZoomingMasterToSlave=false, bool synchronizeZoomingSlaveToMaster=false);
|
||||||
|
|
||||||
/** \brief switches any synchronization off, that has been created by synchronizeToMaster() */
|
/** \brief switches any synchronization off, that has been created by synchronizeToMaster() */
|
||||||
void resetMasterSynchronization();
|
void resetMasterSynchronization();
|
||||||
|
Loading…
Reference in New Issue
Block a user