[Kst] branches/work/kst/portto4/kst/src/libkstapp

Barth Netterfield netterfield at astro.utoronto.ca
Mon May 30 20:16:16 CEST 2011


SVN commit 1234248 by netterfield:

Clicking in the plot axis brings up the plot dialog in the appropriate tab:
  -clicking in the label region selects the label tab
  -clicking in the xaxis number region selects the Xaxis tab
  -clicking in the yaxis number region selects the Yaxis tab

Q: should this be click or double-click?  It is currently click.



 M  +23 -2     plotitem.cpp  
 M  +3 -1      plotitem.h  
 M  +8 -8      plotitemdialog.cpp  
 M  +5 -0      plotitemdialog.h  


--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.cpp #1234247:1234248
@@ -376,8 +376,15 @@
 }
 
 
-void PlotItem::edit() {
+void PlotItem::edit(PlotClickEditRegion region) {
   PlotItemDialog *editDialog = new PlotItemDialog(this, kstApp->mainWindow());
+  if (region == LABEL) {
+    editDialog->selectLabelsPage();
+  } else if (region == XAXIS) {
+    editDialog->selectXAxisPage();
+  } else if (region == YAXIS) {
+    editDialog->selectYAxisPage();
+  }
   editDialog->show();
 }
 
@@ -2776,7 +2783,21 @@
       setTiedZoom(!isTiedZoom(), !isTiedZoom());
       ViewItem::mousePressEvent(event);
     } else if (view()->viewMode() == View::Data) {
-      edit();
+      PlotClickEditRegion region = CONTENT;
+      if (event->pos().x() - rect().left() < leftLabelMargin()) {
+        region = LABEL;
+      } else if (event->pos().y() - rect().top()< topLabelMargin()) {
+        region = LABEL;
+      } else if (rect().right()-event->pos().x() < rightLabelMargin()) {
+        region = LABEL;
+      } else if (rect().bottom()-event->pos().y() < bottomLabelMargin()) {
+        region = LABEL;
+      } else if (rect().bottom()-event->pos().y() < bottomMarginSize()) {
+        region = XAXIS;
+      } else if (event->pos().x() - rect().left() < leftMarginSize()) {
+        region = YAXIS;
+      }
+      edit(region);
     } else {
       ViewItem::mousePressEvent(event);
     }
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.h #1234247:1234248
@@ -125,6 +125,8 @@
     PlotItem(View *parent);
     virtual ~PlotItem();
 
+    enum PlotClickEditRegion {CONTENT, LABEL, XAXIS, YAXIS};
+
     virtual QString plotName() const; //from PlotItemInterface
     virtual QString plotSizeLimitedName(const QWidget *widget) const;  //from PlotItemInterface
 
@@ -322,7 +324,7 @@
 
     void setPlotBordersDirty(bool dirty = true);
 
-    virtual void edit();
+    virtual void edit(PlotClickEditRegion region=CONTENT);
     void plotMaximize();
     void redrawPlot();
     void setPlotRectsDirty();
--- branches/work/kst/portto4/kst/src/libkstapp/plotitemdialog.cpp #1234247:1234248
@@ -87,18 +87,18 @@
   connect(_rangeTab, SIGNAL(apply()), this, SLOT(rangeChanged()));
 
   _xAxisTab = new AxisTab(this);
-  DialogPage *xAxisPage = new DialogPage(this);
-  xAxisPage->setPageTitle(tr("X-Axis"));
-  xAxisPage->addDialogTab(_xAxisTab);
-  addDialogPage(xAxisPage, true);
+  _xAxisPage = new DialogPage(this);
+  _xAxisPage->setPageTitle(tr("X-Axis"));
+  _xAxisPage->addDialogTab(_xAxisTab);
+  addDialogPage(_xAxisPage, true);
   connect(_xAxisTab, SIGNAL(apply()), this, SLOT(xAxisChanged()));
 
   _yAxisTab = new AxisTab(this);
   _yAxisTab->setAsYAxis();
-  DialogPage *yAxisPage = new DialogPage(this);
-  yAxisPage->setPageTitle(tr("Y-Axis"));
-  yAxisPage->addDialogTab(_yAxisTab);
-  addDialogPage(yAxisPage, true);
+  _yAxisPage = new DialogPage(this);
+  _yAxisPage->setPageTitle(tr("Y-Axis"));
+  _yAxisPage->addDialogTab(_yAxisTab);
+  addDialogPage(_yAxisPage, true);
   connect(_yAxisTab, SIGNAL(apply()), this, SLOT(yAxisChanged()));
 
   _xMarkersTab = new MarkersTab(this);
--- branches/work/kst/portto4/kst/src/libkstapp/plotitemdialog.h #1234247:1234248
@@ -39,6 +39,9 @@
     explicit PlotItemDialog(PlotItem *item, QWidget *parent = 0);
     virtual ~PlotItemDialog();
 
+    void selectLabelsPage() {selectDialogPage((DialogPage*)_labelPage);}
+    void selectXAxisPage() {selectDialogPage(_xAxisPage);}
+    void selectYAxisPage() {selectDialogPage(_yAxisPage);}
   private Q_SLOTS:
     void contentChanged();
     //void relationChanged();
@@ -78,6 +81,8 @@
 
     ContentTab *_contentTab;
     AxisTab *_xAxisTab;
+    DialogPage *_xAxisPage;
+    DialogPage *_yAxisPage;
     AxisTab *_yAxisTab;
     RangeTab *_rangeTab;
     MarkersTab *_xMarkersTab;


More information about the Kst mailing list