diff --git a/Code/Mantid/MantidPlot/CMakeLists.txt b/Code/Mantid/MantidPlot/CMakeLists.txt index f85a96662121a01e7768fb9c06a4fe8d9c73e75a..4b87d308cf2b205e676154c91d0d9eb8295a2b09 100644 --- a/Code/Mantid/MantidPlot/CMakeLists.txt +++ b/Code/Mantid/MantidPlot/CMakeLists.txt @@ -13,8 +13,6 @@ set ( QTIPLOT_SRCS src/ApplicationWindow.cpp src/Bar.cpp src/BoxCurve.cpp src/CanvasPicker.cpp - src/ColorBox.cpp - src/ColorButton.cpp src/ColorMapDialog.cpp src/ColorMapEditor.cpp src/Cone3D.cpp @@ -137,6 +135,11 @@ set ( QTIPLOT_SRCS src/ApplicationWindow.cpp src/plot2D/ScaleEngine.cpp src/analysis/fft2D.cpp src/zlib123/minigzip.c + # Have added all of current qtiplot 'lib' to repository + # but only including what we want to use here + src/lib/src/ColorBox.cpp + src/lib/src/ColorButton.cpp + src/lib/3rdparty/qtcolorpicker/src/qtcolorpicker.cpp ) set ( MANTID_SRCS src/Mantid/AbstractMantidLog.cpp @@ -218,8 +221,6 @@ set ( QTIPLOT_HDRS src/ApplicationWindow.h src/Bar.h src/BoxCurve.h src/CanvasPicker.h - src/ColorBox.h - src/ColorButton.h src/ColorMapDialog.h src/ColorMapEditor.h src/Cone3D.h @@ -348,6 +349,9 @@ set ( QTIPLOT_HDRS src/ApplicationWindow.h src/analysis/fft2D.h src/origin/OPJFile.h src/plot2D/ScaleEngine.h + src/lib/include/ColorBox.h + src/lib/include/ColorButton.h + src/lib/3rdparty/qtcolorpicker/src/qtcolorpicker.h ) set ( MANTID_HDRS src/Mantid/AbstractMantidLog.h @@ -512,8 +516,8 @@ set ( QTIPLOT_MOC_FILES src/ApplicationWindow.h src/AssociationsDialog.h src/AxesDialog.h src/CanvasPicker.h - src/ColorBox.h - src/ColorButton.h + #src/ColorBox.h + #src/ColorButton.h src/ColorMapDialog.h src/ColorMapEditor.h src/ConfigDialog.h @@ -611,6 +615,9 @@ set ( QTIPLOT_MOC_FILES src/ApplicationWindow.h src/TextFormatButtons.h src/TitlePicker.h src/TranslateCurveTool.h + src/lib/include/ColorBox.h + src/lib/include/ColorButton.h + src/lib/3rdparty/qtcolorpicker/src/qtcolorpicker.h ) set ( MANTID_MOC_FILES src/Mantid/AlgMonitor.h @@ -650,7 +657,7 @@ set ( MANTID_MOC_FILES src/Mantid/AlgMonitor.h src/Mantid/InstrumentWidget/InstrumentWindowRenderTab.h src/Mantid/InstrumentWidget/InstrumentWindowPickTab.h src/Mantid/InstrumentWidget/ColorMapWidget.h - src/Mantid/InstrumentWidget/MantidGLWidget.h + src/Mantid/InstrumentWidget/MantidGLWidget.h src/Mantid/InstrumentWidget/OneCurvePlot.h src/Mantid/InstrumentWidget/CollapsiblePanel.h ) @@ -664,6 +671,12 @@ set ( UI_FILES src/Mantid/FirstTimeSetup.ui ) qt4_wrap_cpp ( MOCCED_FILES ${QTIPLOT_MOC_FILES} ${MANTID_MOC_FILES} ) +# Call separate function on third-party code that expects moc output to have certain name +qt4_generate_moc ( src/lib/3rdparty/qtcolorpicker/src/qtcolorpicker.cpp + ${CMAKE_CURRENT_BINARY_DIR}/qtcolorpicker.moc ) +set_source_files_properties ( ${CMAKE_CURRENT_BINARY_DIR}/qtcolorpicker.moc + PROPERTIES HEADER_FILE_ONLY true ) +set ( MOCCED_FILES ${MOCCED_FILES} ${CMAKE_CURRENT_BINARY_DIR}/qtcolorpicker.moc ) qt4_wrap_ui ( UI_HDRS ${UI_FILES} ) # The generated ui headers will go here: @@ -695,6 +708,8 @@ add_definitions ( -DSCRIPTING_PYTHON ) add_definitions ( -DQSCINTILLA_DLL ) # Will only have an effect on Windows (as is desired) include_directories ( src ) +include_directories ( src/lib/include ) +include_directories ( src/lib/3rdparty/qtcolorpicker/src ) set ( SRC_FILES ${QTIPLOT_SRCS} ${MANTID_SRCS} ${SIP_SRC} ) set ( INC_FILES ${QTIPLOT_HDRS} ${MANTID_HDRS} ) diff --git a/Code/Mantid/MantidPlot/src/ApplicationWindow.cpp b/Code/Mantid/MantidPlot/src/ApplicationWindow.cpp index 9634fe36afe47adfb0c54a55650f004239a328de..ebfaab1af2c608ee74240492517624ec7b634214 100644 --- a/Code/Mantid/MantidPlot/src/ApplicationWindow.cpp +++ b/Code/Mantid/MantidPlot/src/ApplicationWindow.cpp @@ -1309,6 +1309,7 @@ void ApplicationWindow::plotMenuAboutToShow() plot2DMenu->addAction(actionPlotLP); QMenu *specialPlotMenu = plot2DMenu->addMenu (tr("Special Line/Symb&ol")); + specialPlotMenu->addAction(actionWaterfallPlot); specialPlotMenu->addAction(actionPlotVerticalDropLines); specialPlotMenu->addAction(actionPlotSpline); specialPlotMenu->addAction(actionPlotVertSteps); @@ -6540,6 +6541,7 @@ void ApplicationWindow::showColMenu(int c) plot.addAction(QIcon(getQPixmap("pPlot_xpm")),tr("&Scatter"), this, SLOT(plotP())); plot.addAction(QIcon(getQPixmap("lpPlot_xpm")),tr("Line + S&ymbol"), this,SLOT(plotLP())); + specialPlot.addAction(actionWaterfallPlot); specialPlot.addAction(QIcon(getQPixmap("dropLines_xpm")),tr("Vertical &Drop Lines"), this, SLOT(plotVerticalDropLines())); specialPlot.addAction(QIcon(getQPixmap("spline_xpm")),tr("&Spline"), this, SLOT(plotSpline())); specialPlot.addAction(QIcon(getQPixmap("vert_steps_xpm")),tr("&Vertical Steps"), this, SLOT(plotVertSteps())); @@ -8031,6 +8033,8 @@ void ApplicationWindow::pasteSelection() g->copy(lastCopiedLayer); QPoint pos = plot->mapFromGlobal(QCursor::pos()); plot->setGraphGeometry(pos.x(), pos.y()-20, lastCopiedLayer->width(), lastCopiedLayer->height()); + if (g->isWaterfallPlot()) + g->updateDataCurves(); QApplication::restoreOverrideCursor(); } else { @@ -10393,6 +10397,9 @@ void ApplicationWindow::autoArrangeLayers() plot->setMargins(5, 5, 5, 5); plot->setSpacing(5, 5); plot->arrangeLayers(true, false); + + if (plot->isWaterfallPlot()) + plot->updateWaterfalls(); } void ApplicationWindow::addLayer() @@ -12780,6 +12787,10 @@ void ApplicationWindow::createActions() actionAdvancedSearch = new QAction("Advanced Search",this); actionAdvancedSearch->setToolTip(tr("Catalog Advanced Search")); connect(actionAdvancedSearch, SIGNAL(activated()), this, SLOT(ICatAdvancedSearch())); + + actionWaterfallPlot = new QAction(QIcon(":/waterfall_plot.png"), tr("&Waterfall Plot"), this); + connect(actionWaterfallPlot, SIGNAL(activated()), this, SLOT(waterfallPlot())); + } void ApplicationWindow::translateActionsStrings() @@ -13397,6 +13408,8 @@ void ApplicationWindow::translateActionsStrings() actionFitFrame->setToolTip( tr( "Fit frame to window" ) ); actionFitFrame->setStatusTip( tr( "Fit frame to window" ) ); + actionWaterfallPlot->setMenuText(tr("&Waterfall Plot")); + actionWaterfallPlot->setToolTip(tr("Waterfall Plot")); } @@ -16744,3 +16757,43 @@ void ApplicationWindow::executeloadAlgorithm(const QString& algName,const QStri mantidUI->executeloadAlgorithm(algName,fileName,wsName); } +MultiLayer* ApplicationWindow::waterfallPlot() +{ + Table *t = (Table *)activeWindow(TableWindow); + if (!t) + return 0; + + return waterfallPlot(t, t->selectedYColumns()); +} + +MultiLayer* ApplicationWindow::waterfallPlot(Table *t, const QStringList& list) +{ + if (!t) + return 0; + + if(list.count() < 1){ + QMessageBox::warning(this, tr("QtiPlot - Plot error"),tr("Please select a Y column to plot!")); + return 0; + } + + MultiLayer* ml = new MultiLayer(this); + + Graph *g = ml->activeGraph();//Layer(); + setPreferences(g); + g->enableAxis(QwtPlot::xTop, false); + g->enableAxis(QwtPlot::yRight, false); + g->setCanvasFrame(0); + g->setTitle(QString::null); + g->setMargin(0); + g->setFrame(0); + g->addCurves(t, list, Graph::Line); + g->setWaterfallOffset(10, 20); + + initMultilayerPlot(ml); + ml->arrangeLayers(false, true); + ml->setWaterfallLayout(); + + // TODO: RJT put back in. g->newLegend()->move(QPoint(g->x() + g->canvas()->x() + 5, 5)); + + return ml; +} diff --git a/Code/Mantid/MantidPlot/src/ApplicationWindow.h b/Code/Mantid/MantidPlot/src/ApplicationWindow.h index 15a5774173efb026a34e9c30372bdfb6d9e52524..0025b31cbbb091ca7bffb3f4a8e41dab6906fe24 100644 --- a/Code/Mantid/MantidPlot/src/ApplicationWindow.h +++ b/Code/Mantid/MantidPlot/src/ApplicationWindow.h @@ -247,6 +247,8 @@ public slots: MultiLayer* multilayerPlot(const QString& caption, int layers = 1, int rows = 1, int cols = 1); //! used by the plot wizard MultiLayer* multilayerPlot(const QStringList& colList); + MultiLayer* waterfallPlot(); + MultiLayer* waterfallPlot(Table *t, const QStringList& list); void connectMultilayerPlot(MultiLayer *g); void addLayer(); void deleteLayer(); @@ -261,7 +263,7 @@ public slots: //! Rearrange the layersin order to fit to the size of the plot window void autoArrangeLayers(); - void initMultilayerPlot(MultiLayer* g, const QString& name); + void initMultilayerPlot(MultiLayer* g, const QString& name = QString()); void polishGraph(Graph *g, int style); void plot2VerticalLayers(); void plot2HorizontalLayers(); @@ -1362,6 +1364,8 @@ private: QAction *actionShowUndoStack; QActionGroup *coord, *floorstyle, *grids, *plotstyle, *dataTools; QAction *actionMagnify; + QAction *actionWaterfallPlot; + //mantid log level control QAction *actionLogLevelError, *actionLogLevelWarning, *actionLogLevelNotice, *actionLogLevelInformation, *actionLogLevelDebug; QActionGroup *logLevelGroup; diff --git a/Code/Mantid/MantidPlot/src/ColorBox.cpp b/Code/Mantid/MantidPlot/src/ColorBox.cpp deleted file mode 100644 index b53e884be61386829ed7d54c0446031863e20536..0000000000000000000000000000000000000000 --- a/Code/Mantid/MantidPlot/src/ColorBox.cpp +++ /dev/null @@ -1,226 +0,0 @@ -/*************************************************************************** - File : ColorBox.cpp - Project : QtiPlot - -------------------------------------------------------------------- - Copyright : (C) 2006-2007 by Ion Vasilief, Alex Kargovsky, Tilman Hoener zu Siederdissen - Email (use @ for *) : ion_vasilief*yahoo.fr, kargovsky*yumr.phys.msu.su, thzs*gmx.net - Description : A combo box to select a standard color - - ***************************************************************************/ - -/*************************************************************************** - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin Street, Fifth Floor, * - * Boston, MA 02110-1301 USA * - * * - ***************************************************************************/ -#include "ColorBox.h" - -#include <QPixmap> -#include <QPainter> -#include <algorithm> - -const QColor ColorBox::colors[] = { - QColor(Qt::black), - QColor(Qt::red), - QColor(Qt::green), - QColor(Qt::blue), - QColor(Qt::cyan), - QColor(Qt::magenta), - QColor(Qt::yellow), - QColor(Qt::darkYellow), - QColor(Qt::darkBlue), - QColor(Qt::darkMagenta), - QColor(Qt::darkRed), - QColor(Qt::darkGreen), - QColor(Qt::darkCyan), - QColor("#0000A0"), - QColor("#FF8000"), - QColor("#8000FF"), - QColor("#FF0080"), - QColor(Qt::white), - QColor(Qt::lightGray), - QColor(Qt::gray), - QColor("#FFFF80"), - QColor("#80FFFF"), - QColor("#FF80FF"), - QColor(Qt::darkGray), -}; - -ColorBox::ColorBox(QWidget *parent) : QComboBox(parent) -{ - setEditable(false); - init(); -} - -void ColorBox::init() -{ - QPixmap icon = QPixmap(28, 16); - QRect r = QRect(0, 0, 27, 15); - - icon.fill ( colors[0] ); - this->addItem(icon, tr( "black" ) ); - - QPainter p; - p.begin(&icon); - p.setBrush(QBrush(colors[1])); - p.drawRect(r); - this->addItem(icon, tr( "red" ) ); - - p.setBrush(QBrush(colors[2])); - p.drawRect(r); - this->addItem(icon, tr( "green" ) ); - - p.setBrush(QBrush(colors[3])); - p.drawRect(r); - this->addItem(icon, tr( "blue" ) ); - - p.setBrush(QBrush(colors[4])); - p.drawRect(r); - this->addItem(icon, tr( "cyan" ) ); - - p.setBrush(QBrush(colors[5])); - p.drawRect(r); - this->addItem(icon, tr( "magenta" ) ); - - p.setBrush(QBrush(colors[6])); - p.drawRect(r); - this->addItem(icon, tr( "yellow" ) ); - - p.setBrush(QBrush(colors[7])); - p.drawRect(r); - this->addItem(icon, tr( "dark yellow" ) ); - - p.setBrush(QBrush(colors[8])); - p.drawRect(r); - this->addItem(icon, tr( "navy" ) ); - - p.setBrush(QBrush(colors[9])); - p.drawRect(r); - this->addItem(icon, tr( "purple" ) ); - - p.setBrush(QBrush(colors[10])); - p.drawRect(r); - this->addItem(icon, tr( "wine" ) ); - - p.setBrush(QBrush(colors[11])); - p.drawRect(r); - this->addItem(icon, tr( "olive" ) ); - - p.setBrush(QBrush(colors[12])); - p.drawRect(r); - this->addItem(icon, tr( "dark cyan" ) ); - - p.setBrush(QBrush(colors[13])); - p.drawRect(r); - this->addItem(icon, tr( "royal" ) ); - - p.setBrush(QBrush(colors[14])); - p.drawRect(r); - this->addItem(icon, tr( "orange" ) ); - - p.setBrush(QBrush(colors[15])); - p.drawRect(r); - this->addItem(icon, tr( "violet" ) ); - - p.setBrush(QBrush(colors[16])); - p.drawRect(r); - this->addItem(icon, tr( "pink" ) ); - - p.setBrush(QBrush(colors[17])); - p.drawRect(r); - this->addItem(icon,tr( "white" ) ); - - p.setBrush(QBrush(colors[18])); - p.drawRect(r); - this->addItem(icon, tr( "light gray" ) ); - - p.setBrush(QBrush(colors[19])); - p.drawRect(r); - this->addItem(icon, tr( "gray" ) ); - - p.setBrush(QBrush(colors[20])); - p.drawRect(r); - this->addItem(icon, tr( "light yellow" ) ); - - p.setBrush(QBrush(colors[21])); - p.drawRect(r); - this->addItem(icon, tr( "light cyan" ) ); - - p.setBrush(QBrush(colors[22])); - p.drawRect(r); - this->addItem(icon, tr( "light magenta" ) ); - - p.setBrush(QBrush(colors[23])); - p.drawRect(r); - this->addItem(icon, tr( "dark gray" ) ); - p.end(); -} - -void ColorBox::setColor(const QColor& c) -{ - for(int i = 0; i < colors_count;++i) - { - if (colors[i] == c) - { - setCurrentIndex(int(i)); - } - } -} - -QColor ColorBox::color() const -{ - int i = this->currentIndex(); - if (i < colors_count) - return colors[this->currentIndex()]; - else - return QColor(Qt::black); // default color is black. -} - -int ColorBox::colorIndex(const QColor& c) -{ - for(int i = 0; i < colors_count;++i) - { - if (colors[i] == c) - { - return int(i); - } - } - return 0; -} - -QColor ColorBox::color(int colorIndex) -{ - if (colorIndex < colors_count) - return colors[colorIndex]; - else - return QColor(Qt::black); // default color is black. -} - -bool ColorBox::isValidColor(const QColor& color) -{ - for (int i = 0; i < colors_count; i++) - { - if (color == colors[i]) - return true; - } - return false; -} - -int ColorBox::numPredefinedColors() -{ - return colors_count; -} - diff --git a/Code/Mantid/MantidPlot/src/Graph.cpp b/Code/Mantid/MantidPlot/src/Graph.cpp index 0cb4e398467e3aa47b310fef267b10b665f07815..115c8651bfc8b10ae7c09e42827381d0b1274083 100644 --- a/Code/Mantid/MantidPlot/src/Graph.cpp +++ b/Code/Mantid/MantidPlot/src/Graph.cpp @@ -111,6 +111,10 @@ Graph::Graph(int x, int y, int width, int height, QWidget* parent, Qt::WFlags f) { setWindowFlags(f); n_curves=0; + + d_waterfall_offset_x = 0; + d_waterfall_offset_y = 0; + d_active_tool = NULL; d_selected_text = NULL; d_legend = NULL; // no legend for an empty graph @@ -2749,6 +2753,15 @@ int Graph::curveIndex(QwtPlotCurve *c) const return plotItemIndex(c); } +DataCurve * Graph::dataCurve(int index) +{ + PlotCurve *c = dynamic_cast<PlotCurve*>(curve(index)); + if (c && c->type() != Function) + return (DataCurve*)c; + + return 0; +} + int Graph::range(int index, double *start, double *end) { if (d_range_selector && d_range_selector->selectedCurve() == curve(index)) { @@ -4415,6 +4428,9 @@ void Graph::showGrid(int axis) void Graph::copy(Graph* g) { + d_waterfall_offset_x = g->waterfallXOffset(); + d_waterfall_offset_y = g->waterfallYOffset(); + Plot *plot = g->plotWidget(); d_plot->setMargin(plot->margin()); setBackgroundColor(plot->paletteBackgroundColor()); @@ -5502,3 +5518,119 @@ void Graph::enablePanningMagnifier(bool on) } } +void Graph::setWaterfallXOffset(int offset) +{ + if (offset == d_waterfall_offset_x) + return; + + d_waterfall_offset_x = offset; + updateDataCurves(); + emit modifiedGraph(); +} + +void Graph::setWaterfallYOffset(int offset) +{ + if (offset == d_waterfall_offset_y) + return; + + d_waterfall_offset_y = offset; + updateDataCurves(); + emit modifiedGraph(); +} + +void Graph::setWaterfallOffset(int x, int y, bool update) +{ + d_waterfall_offset_x = x; + d_waterfall_offset_y = y; + + if (update){ + updateDataCurves(); + emit modifiedGraph(); + } +} + +void Graph::updateWaterfallFill(bool on) +{ + int n = d_plot->curvesList().size(); //d_curves.size(); + if (!n) + return; + + for (int i = 0; i < n; i++){ + PlotCurve *cv = (PlotCurve *)curve(i); + if (!cv) + continue; + + if (on && multiLayer()) + cv->setBrush(QBrush(multiLayer()->waterfallFillColor())); + else + cv->setBrush(QBrush()); + } + replot(); + emit modifiedGraph(); +} + +void Graph::setWaterfallSideLines(bool on) +{ + // TODO: Make this work + //int n = d_curves.size(); + //if (!n) + // return; + + //if (curve(0)->sideLinesEnabled() == on) + // return; + + //for (int i = 0; i < n; i++){ + // PlotCurve *cv = (PlotCurve *)curve(i); + // if (cv) + // cv->enableSideLines(on); + //} + //replot(); + //emit modifiedGraph(); +} + +void Graph::setWaterfallFillColor(const QColor& c) +{ + int n = d_plot->curvesList().size(); //d_curves.size(); + if (!n) + return; + + for (int i = 0; i < n; i++){ + PlotCurve *cv = (PlotCurve *)curve(i); + if (cv) + cv->setBrush(QBrush(c)); + } + replot(); + emit modifiedGraph(); +} + +void Graph::reverseCurveOrder() +{ + // No-op at the mo. TODO: Implement + return; + //if (d_plot->curvesList().isEmpty()) //d_curves.isEmpty()) + // return; + + //QList<QwtPlotItem *> lst; + //int n = d_plot->curvesList().size(); //d_curves.size(); + //for (int i = 0; i < n; i++) + // lst << d_curves[n - i - 1]; + + //setCurvesList(lst); + //emit modifiedGraph(); +} + +void Graph::updateDataCurves() +{ + int n = d_plot->curvesList().size(); //d_curves.size(); + if (!n) + return; + + QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); + for (int i = 0; i < n; i++){ + DataCurve *c = dataCurve(i); + if (c) + c->loadData(); + } + replot(); + QApplication::restoreOverrideCursor(); +} diff --git a/Code/Mantid/MantidPlot/src/Graph.h b/Code/Mantid/MantidPlot/src/Graph.h index 29f478efade17187caedb925c765e4851afbf71d..a147610681280f4f61478f6fdc026f04acf7ce87 100644 --- a/Code/Mantid/MantidPlot/src/Graph.h +++ b/Code/Mantid/MantidPlot/src/Graph.h @@ -244,6 +244,7 @@ public slots: int curveIndex(QwtPlotCurve *c) const; //! map curve title to index int curveIndex(const QString &title){return plotItemsList().findIndex(title);} + DataCurve* dataCurve(int index); //! get curve by index QwtPlotCurve* curve(int index); //! get curve by name @@ -711,6 +712,21 @@ public slots: void notifyFontChange(const QFont& f){emit currentFontChanged(f);}; void enableTextEditor(); + //! \name Waterfall + //@{ + bool isWaterfallPlot(){return d_waterfall_offset_x != 0 || d_waterfall_offset_y != 0;}; + int waterfallXOffset(){return d_waterfall_offset_x;}; + int waterfallYOffset(){return d_waterfall_offset_y;}; + void setWaterfallOffset(int x, int y, bool update = false); + void setWaterfallXOffset(int); + void setWaterfallYOffset(int); + void setWaterfallSideLines(bool on = true); + void setWaterfallFillColor(const QColor&); + void updateWaterfallFill(bool on); + //@} + void updateDataCurves(); + void reverseCurveOrder(); + signals: void selectedGraph (Graph*); void closedGraph(); @@ -811,5 +827,8 @@ private: bool m_errors; // to keep fixed axes QSet<int> m_fixed_axes; + + int d_waterfall_offset_x, d_waterfall_offset_y; + }; #endif // GRAPH_H diff --git a/Code/Mantid/MantidPlot/src/Mantid/MantidUI.cpp b/Code/Mantid/MantidPlot/src/Mantid/MantidUI.cpp index aa6d8175da4142b189868832e9db5a555b40a8fa..8454f6f98dea37ba89ff0c75e274385c88317e80 100644 --- a/Code/Mantid/MantidPlot/src/Mantid/MantidUI.cpp +++ b/Code/Mantid/MantidPlot/src/Mantid/MantidUI.cpp @@ -13,7 +13,6 @@ #include "../Spectrogram.h" #include "../pixmaps.h" #include "../ScriptingWindow.h" -#include "../ColorBox.h" #include "MantidKernel/Property.h" #include "MantidKernel/DateAndTime.h" diff --git a/Code/Mantid/MantidPlot/src/MultiLayer.cpp b/Code/Mantid/MantidPlot/src/MultiLayer.cpp index db56a8718597e81518136733675fe7289183c4f3..2268040c41102c565d30133e18693418c82014c9 100644 --- a/Code/Mantid/MantidPlot/src/MultiLayer.cpp +++ b/Code/Mantid/MantidPlot/src/MultiLayer.cpp @@ -37,6 +37,9 @@ #include <QPainter> #include <QPicture> #include <QClipboard> +#include <QCheckBox> +#include <QGroupBox> +#include <QSpinBox> #if QT_VERSION >= 0x040300 #include <QSvgGenerator> @@ -53,6 +56,7 @@ #include "LegendWidget.h" #include "SelectionMoveResizer.h" #include "ApplicationWindow.h" +#include <ColorButton.h> #include "Mantid/MantidDock.h" #include "Mantid/MantidCurve.h" @@ -100,12 +104,16 @@ MultiLayer::MultiLayer(ApplicationWindow* parent, int layers, int rows, int cols hor_align(HCenter), vert_align(VCenter), d_scale_on_print(true), - d_print_cropmarks(false) + d_print_cropmarks(false), + d_is_waterfall_plot(false), +d_waterfall_fill_color(Qt::black) { layerButtonsBox = new QHBoxLayout(); + waterfallBox = new QHBoxLayout(); buttonsLine = new QHBoxLayout(); buttonsLine->addLayout(layerButtonsBox); buttonsLine->addStretch(); + buttonsLine->addLayout(waterfallBox); canvas = new QWidget(); @@ -287,6 +295,9 @@ void MultiLayer::resizeLayers (QResizeEvent *re) } } + if (d_is_waterfall_plot) + updateWaterfalls(); + emit modifiedPlot(); repaint(); QApplication::restoreOverrideCursor(); @@ -1224,6 +1235,10 @@ void MultiLayer::copy(MultiLayer* ml) g2->setIgnoreResizeEvents(g->ignoresResizeEvents()); g2->setAutoscaleFonts(g->autoscaleFonts()); } + + if (ml->isWaterfallPlot()) + setWaterfallLayout(true); + show(); } @@ -1323,3 +1338,158 @@ void MultiLayer::maybeNeedToClose() if (shouldClose) close(); } } + +void MultiLayer::setWaterfallLayout(bool on) +{ + if (graphsList.isEmpty()) + return; + + d_is_waterfall_plot = on; + + if (on){ + createWaterfallBox(); + updateWaterfalls(); + } else { + for (int i = 0; i < waterfallBox->count(); i++){ + QLayoutItem *item = waterfallBox->itemAt(i); + if (item){ + waterfallBox->removeItem(item); + delete item; + } + } + } +} + +void MultiLayer::createWaterfallBox() +{ + QPushButton *btn = new QPushButton(tr("Offset Amount...")); + connect (btn, SIGNAL(clicked()), this, SLOT(showWaterfallOffsetDialog())); + + waterfallBox->addWidget(btn); + btn = new QPushButton(tr("Reverse Order")); + connect (btn, SIGNAL(clicked()), this, SLOT(reverseWaterfallOrder())); + + waterfallBox->addWidget(btn); + btn = new QPushButton(tr("Fill Area...")); + connect (btn, SIGNAL(clicked()), this, SLOT(showWaterfallFillDialog())); + waterfallBox->addWidget(btn); +} + +void MultiLayer::updateWaterfalls() +{ + if (!d_is_waterfall_plot || graphsList.isEmpty()) + return; + + foreach(Graph *g, graphsList){ + if (g->isWaterfallPlot()) + g->updateDataCurves(); + } +} + +void MultiLayer::showWaterfallOffsetDialog() +{ + if (graphsList.isEmpty() || !active_graph) + return; + if (active_graph->curvesList().isEmpty()) + return; + + QDialog *offsetDialog = new QDialog(this); + offsetDialog->setWindowTitle(tr("Offset Dialog")); + + QGroupBox *gb1 = new QGroupBox(); + QGridLayout *hl1 = new QGridLayout(gb1); + + hl1->addWidget(new QLabel(tr("Total Y Offset (%)")), 0, 0); + QSpinBox *yOffsetBox = new QSpinBox(); + yOffsetBox->setRange(-INT_MAX, INT_MAX); + yOffsetBox->setValue(active_graph->waterfallYOffset()); + hl1->addWidget(yOffsetBox, 0, 1); + + hl1->addWidget(new QLabel(tr("Total X Offset (%)")), 1, 0); + QSpinBox *xOffsetBox = new QSpinBox(); + xOffsetBox->setRange(-INT_MAX, INT_MAX); + xOffsetBox->setValue(active_graph->waterfallXOffset()); + hl1->addWidget(xOffsetBox, 1, 1); + hl1->setRowStretch(2, 1); + + connect(yOffsetBox, SIGNAL(valueChanged(int)), active_graph, SLOT(setWaterfallYOffset(int))); + connect(xOffsetBox, SIGNAL(valueChanged(int)), active_graph, SLOT(setWaterfallXOffset(int))); + + QPushButton *applyBtn = new QPushButton(tr("&Apply")); + connect(applyBtn, SIGNAL(clicked()), this, SLOT(updateWaterfalls())); + + QPushButton *closeBtn = new QPushButton(tr("&Close")); + connect(closeBtn, SIGNAL(clicked()), offsetDialog, SLOT(reject())); + + QHBoxLayout *hl2 = new QHBoxLayout(); + hl2->addStretch(); + hl2->addWidget(applyBtn); + hl2->addWidget(closeBtn); + + QVBoxLayout *vl = new QVBoxLayout(offsetDialog); + vl->addWidget(gb1); + vl->addLayout(hl2); + offsetDialog->exec(); +} + +void MultiLayer::reverseWaterfallOrder() +{ + if (graphsList.isEmpty() || !active_graph) + return; + + active_graph->reverseCurveOrder(); + active_graph->updateDataCurves(); + emit modifiedWindow(this); +} + +void MultiLayer::showWaterfallFillDialog() +{ + if (graphsList.isEmpty() || !active_graph) + return; + if (active_graph->curvesList().isEmpty()) + return; + + QDialog *waterfallFillDialog = new QDialog(this); + waterfallFillDialog->setWindowTitle(tr("Fill Curves")); + + QGroupBox *gb1 = new QGroupBox(tr("Enable Fill")); + gb1->setCheckable(true); + + QGridLayout *hl1 = new QGridLayout(gb1); + hl1->addWidget(new QLabel(tr("Fill with Color")), 0, 0); + ColorButton *fillColorBox = new ColorButton(); + hl1->addWidget(fillColorBox, 0, 1); + + QCheckBox *sideLinesBox = new QCheckBox(tr("Side Lines")); + //sideLinesBox->setChecked(active_graph->curve(0)->sideLinesEnabled()); + hl1->addWidget(sideLinesBox, 1, 0); + hl1->setRowStretch(2, 1); + + QBrush brush = active_graph->curve(0)->brush(); + fillColorBox->setColor(brush.style() != Qt::NoBrush ? brush.color() : d_waterfall_fill_color); + gb1->setChecked(brush.style() != Qt::NoBrush); + + connect(gb1, SIGNAL(toggled(bool)), active_graph, SLOT(updateWaterfallFill(bool))); + connect(fillColorBox, SIGNAL(colorChanged(const QColor&)), this, SLOT(setWaterfallFillColor(const QColor&))); + connect(sideLinesBox, SIGNAL(toggled(bool)), active_graph, SLOT(setWaterfallSideLines(bool))); + + QPushButton *closeBtn = new QPushButton(tr("&Close")); + connect(closeBtn, SIGNAL(clicked()), waterfallFillDialog, SLOT(reject())); + + QHBoxLayout *hl2 = new QHBoxLayout(); + hl2->addStretch(); + hl2->addWidget(closeBtn); + + QVBoxLayout *vl = new QVBoxLayout(waterfallFillDialog); + vl->addWidget(gb1); + vl->addLayout(hl2); + waterfallFillDialog->exec(); +} + +void MultiLayer::setWaterfallFillColor(const QColor& c) +{ + d_waterfall_fill_color = c; + if (active_graph) + active_graph->setWaterfallFillColor(c); +} + diff --git a/Code/Mantid/MantidPlot/src/MultiLayer.h b/Code/Mantid/MantidPlot/src/MultiLayer.h index 151bf198beeb20d2b046625f282d3b7e3cc61246..5164e36fcd082653a1851d1a4fa56171250e2a72 100644 --- a/Code/Mantid/MantidPlot/src/MultiLayer.h +++ b/Code/Mantid/MantidPlot/src/MultiLayer.h @@ -86,6 +86,8 @@ public: /// Set whether the MultiLayer should close itself when it becomes empty void setCloseOnEmpty(bool yes=true){d_close_on_empty = yes;} + void setWaterfallLayout(bool on = true); + public slots: Graph* addLayer(int x = 0, int y = 0, int width = 0, int height = 0); void setLayersNumber(int n); @@ -158,6 +160,17 @@ public slots: void maybeNeedToClose(); + //! \name Waterfall Plots + //@{ + void showWaterfallOffsetDialog(); + void reverseWaterfallOrder(); + void showWaterfallFillDialog(); + void updateWaterfalls(); + bool isWaterfallPlot(){return d_is_waterfall_plot;} + QColor waterfallFillColor(){return d_waterfall_fill_color;} + void setWaterfallFillColor(const QColor& c); + //@} + signals: void showTextDialog(); void showPlotDialog(int); @@ -196,6 +209,8 @@ private: void removeLayerSelectionFrame(); + void createWaterfallBox(); + Graph* active_graph; //! Used for resizing of layers. int d_cols, d_rows, graph_width, graph_height, colsSpace, rowsSpace; @@ -205,12 +220,16 @@ private: QList<LayerButton *> buttonsList; QList<Graph *> graphsList; - QHBoxLayout *layerButtonsBox; + QHBoxLayout *layerButtonsBox, *waterfallBox; QHBoxLayout *buttonsLine; QWidget *canvas; QPointer<SelectionMoveResizer> d_layers_selector; bool d_close_on_empty;/// true makes Multilayer close itself if it becomes empty + + bool d_is_waterfall_plot; + QColor d_waterfall_fill_color; + }; //! Button with layer number diff --git a/Code/Mantid/MantidPlot/src/PlotCurve.cpp b/Code/Mantid/MantidPlot/src/PlotCurve.cpp index fc8a27004436703a3a2a5559bff1a192985a99c3..d9d26fd4686852959df9d6c605ff918ef6530eaf 100644 --- a/Code/Mantid/MantidPlot/src/PlotCurve.cpp +++ b/Code/Mantid/MantidPlot/src/PlotCurve.cpp @@ -35,6 +35,7 @@ #include <QMessageBox> #include <QPainter> #include <qwt_symbol.h> +#include <qwt_plot_canvas.h> QString PlotCurve::saveCurveLayout() { @@ -307,6 +308,10 @@ void DataCurve::loadData() QStringList xLabels, yLabels;// store text labels + int xAxis = QwtPlot::xBottom; + if (d_type == Graph::HorizontalBars) + xAxis = QwtPlot::yLeft; + QTime time0; QDateTime date0; QString date_time_fmt = d_table->columnFormat(xcol); @@ -361,8 +366,38 @@ void DataCurve::loadData() } } - X.resize(size); - Y.resize(size); + X.resize(size); + Y.resize(size); + + if (g->isWaterfallPlot()){ + int index = g->curveIndex(this); + int curves = g->curves();//Count(); + DataCurve *c = g->dataCurve(0); + if (index > 0 && c){ + double xmin = c->minXValue(); + double dx = index*g->waterfallXOffset()*0.01*plot->canvas()->width()/(double)(curves - 1); + //double dx = index*g->waterfallXOffset()*0.01*g->canvas()->width()/(double)(curves - 1); + d_x_offset = plot->invTransform(xAxis, plot->transform(xAxis, xmin) + dx) - xmin; + + double ymin = c->minYValue(); + double dy = index*g->waterfallYOffset()*0.01*plot->canvas()->height()/(double)(curves - 1); + //double dy = index*g->waterfallYOffset()*0.01*g->canvas()->height()/(double)(curves - 1); + d_y_offset = ymin - plot->invTransform(yAxis(), plot->transform(yAxis(), ymin) + dy); + + setZ(-index); + setBaseline(d_y_offset); + + for (int i = 0; i < size; i++){ + X[i] = X[i] + d_x_offset; + Y[i] = Y[i] + d_y_offset; + } + } else { + setZ(0); + setBaseline(0.0); + } + //if (g->grid()) + // g->grid()->setZ(-g->curveCount() - 1); + } if (!size){ remove(); diff --git a/Code/Mantid/MantidPlot/src/lib/3rdparty/qtcolorpicker/LGPL_EXCEPTION.txt b/Code/Mantid/MantidPlot/src/lib/3rdparty/qtcolorpicker/LGPL_EXCEPTION.txt new file mode 100644 index 0000000000000000000000000000000000000000..0b56ff1efe1680fba679a4f4355ef855037f4e8e --- /dev/null +++ b/Code/Mantid/MantidPlot/src/lib/3rdparty/qtcolorpicker/LGPL_EXCEPTION.txt @@ -0,0 +1,10 @@ +Nokia Qt LGPL Exception version 1.0 + +As a special exception to the GNU Lesser General Public License +version 2.1, the object code form of a "work that uses the Library" +may incorporate material from a header file that is part of the +Library. You may distribute such object code under terms of your +choice, provided that the incorporated material (i) does not exceed +more than 5% of the total size of the Library; and (ii) is limited to +numerical parameters, data structure layouts, accessors, macros, +inline functions and templates. diff --git a/Code/Mantid/MantidPlot/src/lib/3rdparty/qtcolorpicker/LICENSE.GPL3 b/Code/Mantid/MantidPlot/src/lib/3rdparty/qtcolorpicker/LICENSE.GPL3 new file mode 100644 index 0000000000000000000000000000000000000000..94a9ed024d3859793618152ea559a168bbcbb5e2 --- /dev/null +++ b/Code/Mantid/MantidPlot/src/lib/3rdparty/qtcolorpicker/LICENSE.GPL3 @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + <program> Copyright (C) <year> <name of author> + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +<http://www.gnu.org/licenses/>. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +<http://www.gnu.org/philosophy/why-not-lgpl.html>. diff --git a/Code/Mantid/MantidPlot/src/lib/3rdparty/qtcolorpicker/LICENSE.LGPL b/Code/Mantid/MantidPlot/src/lib/3rdparty/qtcolorpicker/LICENSE.LGPL new file mode 100644 index 0000000000000000000000000000000000000000..5ab7695ab8cabe0c5c8a814bb0ab1e8066578fbb --- /dev/null +++ b/Code/Mantid/MantidPlot/src/lib/3rdparty/qtcolorpicker/LICENSE.LGPL @@ -0,0 +1,504 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + <one line to give the library's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + <signature of Ty Coon>, 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + diff --git a/Code/Mantid/MantidPlot/src/lib/3rdparty/qtcolorpicker/README.TXT b/Code/Mantid/MantidPlot/src/lib/3rdparty/qtcolorpicker/README.TXT new file mode 100644 index 0000000000000000000000000000000000000000..440d1287e5e1c97904b476d676f8db07e305ad5c --- /dev/null +++ b/Code/Mantid/MantidPlot/src/lib/3rdparty/qtcolorpicker/README.TXT @@ -0,0 +1,7 @@ +Color Picker v2.6 + +A widget that lets the user select colors from a grid of +predefined colors. + + + diff --git a/Code/Mantid/MantidPlot/src/lib/3rdparty/qtcolorpicker/src/qtcolorpicker.cpp b/Code/Mantid/MantidPlot/src/lib/3rdparty/qtcolorpicker/src/qtcolorpicker.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2a4fff1e79b8c1f3586271bdf5e20200bb117b5a --- /dev/null +++ b/Code/Mantid/MantidPlot/src/lib/3rdparty/qtcolorpicker/src/qtcolorpicker.cpp @@ -0,0 +1,1144 @@ +/**************************************************************************** +** +** This file is part of a Qt Solutions component. +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Qt Software Information (qt-info@nokia.com) +** +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Solutions Commercial License Agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** Please note Third Party Software included with Qt Solutions may impose +** additional restrictions and it is the user's responsibility to ensure +** that they have met the licensing requirements of the GPL, LGPL, or Qt +** Solutions Commercial license and the relevant license of the Third +** Party Software they are using. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +****************************************************************************/ + +#include <QtGui/QApplication> +#include <QtGui/QDesktopWidget> +#include <QtGui/QPainter> +#include <QtGui/QPushButton> +#include <QtGui/QColorDialog> +#include <QtCore/QMap> +#include <QtGui/QLayout> +#include <QtGui/QStyle> +#include <QtGui/QLabel> +#include <QtGui/QToolTip> +#include <QtGui/QPixmap> +#include <QtGui/QFocusEvent> +#include <QtGui/QPaintEvent> +#include <QtGui/QGridLayout> +#include <QtGui/QHideEvent> +#include <QtGui/QKeyEvent> +#include <QtGui/QShowEvent> +#include <QtGui/QMouseEvent> +#include <math.h> + +#include "qtcolorpicker.h" + +/*! \class QtColorPicker + + \brief The QtColorPicker class provides a widget for selecting + colors from a popup color grid. + + Users can invoke the color picker by clicking on it, or by + navigating to it and pressing Space. They can use the mouse or + arrow keys to navigate between colors on the grid, and select a + color by clicking or by pressing Enter or Space. The + colorChanged() signal is emitted whenever the color picker's color + changes. + + The widget also supports negative selection: Users can click and + hold the mouse button on the QtColorPicker widget, then move the + mouse over the color grid and release the mouse button over the + color they wish to select. + + The color grid shows a customized selection of colors. An optional + ellipsis "..." button (signifying "more") can be added at the + bottom of the grid; if the user presses this, a QColorDialog pops + up and lets them choose any color they like. This button is made + available by using setColorDialogEnabled(). + + When a color is selected, the QtColorPicker widget shows the color + and its name. If the name cannot be determined, the translatable + name "Custom" is used. + + The QtColorPicker object is optionally initialized with the number + of columns in the color grid. Colors are then added left to right, + top to bottom using insertColor(). If the number of columns is not + set, QtColorPicker calculates the number of columns and rows that + will make the grid as square as possible. + + \code + DrawWidget::DrawWidget(QWidget *parent, const char *name) + { + QtColorPicker *picker = new QtColorPicker(this); + picker->insertColor(red, "Red")); + picker->insertColor(QColor("green"), "Green")); + picker->insertColor(QColor(0, 0, 255), "Blue")); + picker->insertColor(white); + + connect(colors, SIGNAL(colorChanged(const QColor &)), SLOT(setCurrentColor(const QColor &))); + } + \endcode + + An alternative to adding colors manually is to initialize the grid + with QColorDialog's standard colors using setStandardColors(). + + QtColorPicker also provides a the static function getColor(), + which pops up the grid of standard colors at any given point. + + \img colorpicker1.png + \img colorpicker2.png + + \sa QColorDialog +*/ + +/*! \fn QtColorPicker::colorChanged(const QColor &color) + + This signal is emitted when the QtColorPicker's color is changed. + \a color is the new color. + + To obtain the color's name, use text(). +*/ + +/* + A class that acts very much like a QPushButton. It's not styled, + so we can expect the exact same look, feel and geometry + everywhere. Also, this button always emits clicked on + mouseRelease, even if the mouse button was not pressed inside the + widget. +*/ +class ColorPickerButton : public QFrame +{ + Q_OBJECT + +public: + ColorPickerButton(QWidget *parent); + +signals: + void clicked(); + +protected: + void mousePressEvent(QMouseEvent *e); + void mouseMoveEvent(QMouseEvent *e); + void mouseReleaseEvent(QMouseEvent *e); + void keyPressEvent(QKeyEvent *e); + void keyReleaseEvent(QKeyEvent *e); + void paintEvent(QPaintEvent *e); + void focusInEvent(QFocusEvent *e); + void focusOutEvent(QFocusEvent *e); +}; + +/* + This class represents each "color" or item in the color grid. +*/ +class ColorPickerItem : public QFrame +{ + Q_OBJECT + +public: + ColorPickerItem(const QColor &color = Qt::white, const QString &text = QString::null, + QWidget *parent = 0); + ~ColorPickerItem(); + + QColor color() const; + QString text() const; + + void setSelected(bool); + bool isSelected() const; +signals: + void clicked(); + void selected(); + +public slots: + void setColor(const QColor &color, const QString &text = QString()); + +protected: + void mousePressEvent(QMouseEvent *e); + void mouseReleaseEvent(QMouseEvent *e); + void mouseMoveEvent(QMouseEvent *e); + void paintEvent(QPaintEvent *e); + +private: + QColor c; + QString t; + bool sel; +}; + +/* + +*/ +class ColorPickerPopup : public QFrame +{ + Q_OBJECT + +public: + ColorPickerPopup(int width, bool withColorDialog, + QWidget *parent = 0); + ~ColorPickerPopup(); + + void insertColor(const QColor &col, const QString &text, int index); + void exec(); + + void setExecFlag(); + + QColor lastSelected() const; + + ColorPickerItem *find(const QColor &col) const; + QColor color(int index) const; + +signals: + void selected(const QColor &); + void hid(); + +public slots: + void getColorFromDialog(); + +protected slots: + void updateSelected(); + +protected: + void keyPressEvent(QKeyEvent *e); + void showEvent(QShowEvent *e); + void hideEvent(QHideEvent *e); + void mouseReleaseEvent(QMouseEvent *e); + + void regenerateGrid(); + +private: + QMap<int, QMap<int, QWidget *> > widgetAt; + QList<ColorPickerItem *> items; + QGridLayout *grid; + ColorPickerButton *moreButton; + QEventLoop *eventLoop; + + int lastPos; + int cols; + QColor lastSel; +}; + +/*! + Constructs a QtColorPicker widget. The popup will display a grid + with \a cols columns, or if \a cols is -1, the number of columns + will be calculated automatically. + + If \a enableColorDialog is true, the popup will also have a "More" + button (signified by an ellipsis "...") that presents a + QColorDialog when clicked. + + After constructing a QtColorPicker, call insertColor() to add + individual colors to the popup grid, or call setStandardColors() + to add all the standard colors in one go. + + The \a parent argument is passed to QFrame's constructor. + + \sa QFrame +*/ +QtColorPicker::QtColorPicker(QWidget *parent, + int cols, bool enableColorDialog) + : QPushButton(parent), popup(0), withColorDialog(enableColorDialog) +{ + setFocusPolicy(Qt::StrongFocus); + setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed); + setAutoDefault(false); + setAutoFillBackground(true); + setCheckable(true); + + // Set text + setText(tr("Black")); + firstInserted = false; + + // Create and set icon + col = Qt::black; + dirty = true; + + // Create color grid popup and connect to it. + popup = new ColorPickerPopup(cols, withColorDialog, this); + connect(popup, SIGNAL(selected(const QColor &)), + SLOT(setCurrentColor(const QColor &))); + connect(popup, SIGNAL(hid()), SLOT(popupClosed())); + + // Connect this push button's pressed() signal. + connect(this, SIGNAL(toggled(bool)), SLOT(buttonPressed(bool))); +} + +/*! + Destructs the QtColorPicker. +*/ +QtColorPicker::~QtColorPicker() +{ +} + +/*! \internal + + Pops up the color grid, and makes sure the status of + QtColorPicker's button is right. +*/ +void QtColorPicker::buttonPressed(bool toggled) +{ + if (!toggled) + return; + + const QRect desktop = QApplication::desktop()->geometry(); + // Make sure the popup is inside the desktop. + QPoint pos = mapToGlobal(rect().bottomLeft()); + if (pos.x() < desktop.left()) + pos.setX(desktop.left()); + if (pos.y() < desktop.top()) + pos.setY(desktop.top()); + + if ((pos.x() + popup->sizeHint().width()) > desktop.width()) + pos.setX(desktop.width() - popup->sizeHint().width()); + if ((pos.y() + popup->sizeHint().height()) > desktop.bottom()) + pos.setY(desktop.bottom() - popup->sizeHint().height()); + popup->move(pos); + + if (ColorPickerItem *item = popup->find(col)) + item->setSelected(true); + + // Remove focus from this widget, preventing the focus rect + // from showing when the popup is shown. Order an update to + // make sure the focus rect is cleared. + clearFocus(); + update(); + + // Allow keyboard navigation as soon as the popup shows. + popup->setFocus(); + + // Execute the popup. The popup will enter the event loop. + popup->show(); +} + +/*! + \internal +*/ +void QtColorPicker::paintEvent(QPaintEvent *e) +{ + if (dirty) { + int iconSize = style()->pixelMetric(QStyle::PM_SmallIconSize); + QPixmap pix(iconSize, iconSize); + pix.fill(palette().button().color()); + + QPainter p(&pix); + + int w = pix.width(); // width of cell in pixels + int h = pix.height(); // height of cell in pixels + p.setPen(QPen(Qt::gray)); + p.setBrush(col); + p.drawRect(2, 2, w - 5, h - 5); + setIcon(QIcon(pix)); + + dirty = false; + } + QPushButton::paintEvent(e); +} + +/*! \internal + + Makes sure the button isn't pressed when the popup hides. +*/ +void QtColorPicker::popupClosed() +{ + setChecked(false); + setFocus(); +} + +/*! + Returns the currently selected color. + + \sa text() +*/ +QColor QtColorPicker::currentColor() const +{ + return col; +} + +/*! + Returns the color at position \a index. +*/ +QColor QtColorPicker::color(int index) const +{ + return popup->color(index); +} + +/*! + Adds the 17 predefined colors from the Qt namespace. + + (The names given to the colors, "Black", "White", "Red", etc., are + all translatable.) + + \sa insertColor() +*/ +void QtColorPicker::setStandardColors() +{ + insertColor(Qt::black, tr("Black")); + insertColor(Qt::white, tr("White")); + insertColor(Qt::red, tr("Red")); + insertColor(Qt::darkRed, tr("Dark red")); + insertColor(Qt::green, tr("Green")); + insertColor(Qt::darkGreen, tr("Dark green")); + insertColor(Qt::blue, tr("Blue")); + insertColor(Qt::darkBlue, tr("Dark blue")); + insertColor(Qt::cyan, tr("Cyan")); + insertColor(Qt::darkCyan, tr("Dark cyan")); + insertColor(Qt::magenta, tr("Magenta")); + insertColor(Qt::darkMagenta, tr("Dark magenta")); + insertColor(Qt::yellow, tr("Yellow")); + insertColor(Qt::darkYellow, tr("Dark yellow")); + insertColor(Qt::gray, tr("Gray")); + insertColor(Qt::darkGray, tr("Dark gray")); + insertColor(Qt::lightGray, tr("Light gray")); +} + + +/*! + Makes \a color current. If \a color is not already in the color grid, it + is inserted with the text "Custom". + + This function emits the colorChanged() signal if the new color is + valid, and different from the old one. +*/ +void QtColorPicker::setCurrentColor(const QColor &color) +{ + if (col == color || !color.isValid()) + return; + + ColorPickerItem *item = popup->find(color); + if (!item) { + insertColor(color, tr("Custom")); + item = popup->find(color); + } + + col = color; + setText(item->text()); + + dirty = true; + + popup->hide(); + repaint(); + + item->setSelected(true); + emit colorChanged(color); +} + +/*! + Adds the color \a color with the name \a text to the color grid, + at position \a index. If index is -1, the color is assigned + automatically assigned a position, starting from left to right, + top to bottom. +*/ +void QtColorPicker::insertColor(const QColor &color, const QString &text, int index) +{ + popup->insertColor(color, text, index); + if (!firstInserted) { + col = color; + setText(text); + firstInserted = true; + } +} + +/*! \property QtColorPicker::colorDialog + \brief Whether the ellipsis "..." (more) button is available. + + If this property is set to TRUE, the color grid popup will include + a "More" button (signified by an ellipsis, "...") which pops up a + QColorDialog when clicked. The user will then be able to select + any custom color they like. +*/ +void QtColorPicker::setColorDialogEnabled(bool enabled) +{ + withColorDialog = enabled; +} +bool QtColorPicker::colorDialogEnabled() const +{ + return withColorDialog; +} + +/*! + Pops up a color grid with Qt default colors at \a point, using + global coordinates. If \a allowCustomColors is true, there will + also be a button on the popup that invokes QColorDialog. + + For example: + + \code + void Drawer::mouseReleaseEvent(QMouseEvent *e) + { + if (e->button() & RightButton) { + QColor color = QtColorPicker::getColor(mapToGlobal(e->pos())); + } + } + \endcode +*/ +QColor QtColorPicker::getColor(const QPoint &point, bool allowCustomColors) +{ + ColorPickerPopup popup(-1, allowCustomColors); + + popup.insertColor(Qt::black, tr("Black"), 0); + popup.insertColor(Qt::white, tr("White"), 1); + popup.insertColor(Qt::red, tr("Red"), 2); + popup.insertColor(Qt::darkRed, tr("Dark red"), 3); + popup.insertColor(Qt::green, tr("Green"), 4); + popup.insertColor(Qt::darkGreen, tr("Dark green"), 5); + popup.insertColor(Qt::blue, tr("Blue"), 6); + popup.insertColor(Qt::darkBlue, tr("Dark blue"), 7); + popup.insertColor(Qt::cyan, tr("Cyan"), 8); + popup.insertColor(Qt::darkCyan, tr("Dark cyan"), 9); + popup.insertColor(Qt::magenta, tr("Magenta"), 10); + popup.insertColor(Qt::darkMagenta, tr("Dark magenta"), 11); + popup.insertColor(Qt::yellow, tr("Yellow"), 12); + popup.insertColor(Qt::darkYellow, tr("Dark yellow"), 13); + popup.insertColor(Qt::gray, tr("Gray"), 14); + popup.insertColor(Qt::darkGray, tr("Dark gray"), 15); + popup.insertColor(Qt::lightGray, tr("Light gray"), 16); + + popup.move(point); + popup.exec(); + return popup.lastSelected(); +} + +/*! \internal + + Constructs the popup widget. +*/ +ColorPickerPopup::ColorPickerPopup(int width, bool withColorDialog, + QWidget *parent) + : QFrame(parent, Qt::Popup) +{ + setFrameStyle(QFrame::StyledPanel); + setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); + + setFocusPolicy(Qt::StrongFocus); + setMouseTracking(true); + cols = width; + + if (withColorDialog) { + moreButton = new ColorPickerButton(this); + moreButton->setFixedWidth(24); + moreButton->setFixedHeight(21); + moreButton->setFrameRect(QRect(2, 2, 20, 17)); + connect(moreButton, SIGNAL(clicked()), SLOT(getColorFromDialog())); + } else { + moreButton = 0; + } + + eventLoop = 0; + grid = 0; + regenerateGrid(); +} + + +/*! \internal + + Destructs the popup widget. +*/ +ColorPickerPopup::~ColorPickerPopup() +{ + if (eventLoop) + eventLoop->exit(); +} + +/*! \internal + + If there is an item whole color is equal to \a col, returns a + pointer to this item; otherwise returns 0. +*/ +ColorPickerItem *ColorPickerPopup::find(const QColor &col) const +{ + for (int i = 0; i < items.size(); ++i) { + if (items.at(i) && items.at(i)->color() == col) + return items.at(i); + } + + return 0; +} + +/*! \internal + + Adds \a item to the grid. The items are added from top-left to + bottom-right. +*/ +void ColorPickerPopup::insertColor(const QColor &col, const QString &text, int index) +{ + // Don't add colors that we have already. + ColorPickerItem *existingItem = find(col); + ColorPickerItem *lastSelectedItem = find(lastSelected()); + + if (existingItem) { + if (lastSelectedItem && existingItem != lastSelectedItem) + lastSelectedItem->setSelected(false); + existingItem->setFocus(); + existingItem->setSelected(true); + return; + } + + ColorPickerItem *item = new ColorPickerItem(col, text, this); + + if (lastSelectedItem) { + lastSelectedItem->setSelected(false); + } + else { + item->setSelected(true); + lastSel = col; + } + item->setFocus(); + + connect(item, SIGNAL(selected()), SLOT(updateSelected())); + + if (index == -1) + index = items.count(); + + items.insert((unsigned int)index, item); + regenerateGrid(); + + update(); +} + +/*! \internal + +*/ +QColor ColorPickerPopup::color(int index) const +{ + if (index < 0 || index > (int) items.count() - 1) + return QColor(); + + ColorPickerPopup *that = (ColorPickerPopup *)this; + return that->items.at(index)->color(); +} + +/*! \internal + +*/ +void ColorPickerPopup::exec() +{ + show(); + + QEventLoop e; + eventLoop = &e; + (void) e.exec(); + eventLoop = 0; +} + +/*! \internal + +*/ +void ColorPickerPopup::updateSelected() +{ + QLayoutItem *layoutItem; + int i = 0; + while ((layoutItem = grid->itemAt(i)) != 0) { + QWidget *w = layoutItem->widget(); + if (w && w->inherits("ColorPickerItem")) { + ColorPickerItem *litem = reinterpret_cast<ColorPickerItem *>(layoutItem->widget()); + if (litem != sender()) + litem->setSelected(false); + } + ++i; + } + + if (sender() && sender()->inherits("ColorPickerItem")) { + ColorPickerItem *item = (ColorPickerItem *)sender(); + lastSel = item->color(); + emit selected(item->color()); + } + + hide(); +} + +/*! \internal + +*/ +void ColorPickerPopup::mouseReleaseEvent(QMouseEvent *e) +{ + if (!rect().contains(e->pos())) + hide(); +} + +/*! \internal + + Controls keyboard navigation and selection on the color grid. +*/ +void ColorPickerPopup::keyPressEvent(QKeyEvent *e) +{ + int curRow = 0; + int curCol = 0; + + bool foundFocus = false; + for (int j = 0; !foundFocus && j < grid->rowCount(); ++j) { + for (int i = 0; !foundFocus && i < grid->columnCount(); ++i) { + if (widgetAt[j][i] && widgetAt[j][i]->hasFocus()) { + curRow = j; + curCol = i; + foundFocus = true; + break; + } + } + } + + switch (e->key()) { + case Qt::Key_Left: + if (curCol > 0) --curCol; + else if (curRow > 0) { --curRow; curCol = grid->columnCount() - 1; } + break; + case Qt::Key_Right: + if (curCol < grid->columnCount() - 1 && widgetAt[curRow][curCol + 1]) ++curCol; + else if (curRow < grid->rowCount() - 1) { ++curRow; curCol = 0; } + break; + case Qt::Key_Up: + if (curRow > 0) --curRow; + else curCol = 0; + break; + case Qt::Key_Down: + if (curRow < grid->rowCount() - 1) { + QWidget *w = widgetAt[curRow + 1][curCol]; + if (w) { + ++curRow; + } else for (int i = 1; i < grid->columnCount(); ++i) { + if (!widgetAt[curRow + 1][i]) { + curCol = i - 1; + ++curRow; + break; + } + } + } + break; + case Qt::Key_Space: + case Qt::Key_Return: + case Qt::Key_Enter: { + QWidget *w = widgetAt[curRow][curCol]; + if (w && w->inherits("ColorPickerItem")) { + ColorPickerItem *wi = reinterpret_cast<ColorPickerItem *>(w); + wi->setSelected(true); + + QLayoutItem *layoutItem; + int i = 0; + while ((layoutItem = grid->itemAt(i)) != 0) { + QWidget *w = layoutItem->widget(); + if (w && w->inherits("ColorPickerItem")) { + ColorPickerItem *litem + = reinterpret_cast<ColorPickerItem *>(layoutItem->widget()); + if (litem != wi) + litem->setSelected(false); + } + ++i; + } + + lastSel = wi->color(); + emit selected(wi->color()); + hide(); + } else if (w && w->inherits("QPushButton")) { + ColorPickerItem *wi = reinterpret_cast<ColorPickerItem *>(w); + wi->setSelected(true); + + QLayoutItem *layoutItem; + int i = 0; + while ((layoutItem = grid->itemAt(i)) != 0) { + QWidget *w = layoutItem->widget(); + if (w && w->inherits("ColorPickerItem")) { + ColorPickerItem *litem + = reinterpret_cast<ColorPickerItem *>(layoutItem->widget()); + if (litem != wi) + litem->setSelected(false); + } + ++i; + } + + lastSel = wi->color(); + emit selected(wi->color()); + hide(); + } + } + break; + case Qt::Key_Escape: + hide(); + break; + default: + e->ignore(); + break; + } + + widgetAt[curRow][curCol]->setFocus(); +} + +/*! \internal + +*/ +void ColorPickerPopup::hideEvent(QHideEvent *e) +{ + if (eventLoop) { + eventLoop->exit(); + } + + setFocus(); + + emit hid(); + QFrame::hideEvent(e); +} + +/*! \internal + +*/ +QColor ColorPickerPopup::lastSelected() const +{ + return lastSel; +} + +/*! \internal + + Sets focus on the popup to enable keyboard navigation. Draws + focusRect and selection rect. +*/ +void ColorPickerPopup::showEvent(QShowEvent *) +{ + bool foundSelected = false; + for (int i = 0; i < grid->columnCount(); ++i) { + for (int j = 0; j < grid->rowCount(); ++j) { + QWidget *w = widgetAt[j][i]; + if (w && w->inherits("ColorPickerItem")) { + if (((ColorPickerItem *)w)->isSelected()) { + w->setFocus(); + foundSelected = true; + break; + } + } + } + } + + if (!foundSelected) { + if (items.count() == 0) + setFocus(); + else + widgetAt[0][0]->setFocus(); + } +} + +/*! + +*/ +void ColorPickerPopup::regenerateGrid() +{ + widgetAt.clear(); + + int columns = cols; + if (columns == -1) + columns = (int) ceil(sqrt((float) items.count())); + + // When the number of columns grows, the number of rows will + // fall. There's no way to shrink a grid, so we create a new + // one. + if (grid) delete grid; + grid = new QGridLayout(this); + grid->setMargin(1); + grid->setSpacing(0); + + int ccol = 0, crow = 0; + for (int i = 0; i < items.size(); ++i) { + if (items.at(i)) { + widgetAt[crow][ccol] = items.at(i); + grid->addWidget(items.at(i), crow, ccol++); + if (ccol == columns) { + ++crow; + ccol = 0; + } + } + } + + if (moreButton) { + grid->addWidget(moreButton, crow, ccol); + widgetAt[crow][ccol] = moreButton; + } + updateGeometry(); +} + +/*! \internal + + Copies the color dialog's currently selected item and emits + itemSelected(). +*/ +void ColorPickerPopup::getColorFromDialog() +{ + bool ok; + QRgb rgb = QColorDialog::getRgba(lastSel.rgba(), &ok, parentWidget()); + if (!ok) + return; + + QColor col = QColor::fromRgba(rgb); + insertColor(col, tr("Custom"), -1); + lastSel = col; + emit selected(col); +} + +/*! + Constructs a ColorPickerItem whose color is set to \a color, and + whose name is set to \a text. +*/ +ColorPickerItem::ColorPickerItem(const QColor &color, const QString &text, + QWidget *parent) + : QFrame(parent), c(color), t(text), sel(false) +{ + setToolTip(t); + setFixedWidth(24); + setFixedHeight(21); +} + +/*! + Destructs a ColorPickerItem. + */ +ColorPickerItem::~ColorPickerItem() +{ +} + +/*! + Returns the item's color. + + \sa text() +*/ +QColor ColorPickerItem::color() const +{ + return c; +} + +/*! + Returns the item's text. + + \sa color() +*/ +QString ColorPickerItem::text() const +{ + return t; +} + +/*! + +*/ +bool ColorPickerItem::isSelected() const +{ + return sel; +} + +/*! + +*/ +void ColorPickerItem::setSelected(bool selected) +{ + sel = selected; + update(); +} + +/*! + Sets the item's color to \a color, and its name to \a text. +*/ +void ColorPickerItem::setColor(const QColor &color, const QString &text) +{ + c = color; + t = text; + setToolTip(t); + update(); +} + +/*! + +*/ +void ColorPickerItem::mouseMoveEvent(QMouseEvent *) +{ + setFocus(); + update(); +} + +/*! + +*/ +void ColorPickerItem::mouseReleaseEvent(QMouseEvent *) +{ + sel = true; + emit selected(); +} + +/*! + +*/ +void ColorPickerItem::mousePressEvent(QMouseEvent *) +{ + setFocus(); + update(); +} + +/*! + +*/ +void ColorPickerItem::paintEvent(QPaintEvent *) +{ + QPainter p(this); + int w = width(); // width of cell in pixels + int h = height(); // height of cell in pixels + + p.setPen( QPen( Qt::gray, 0, Qt::SolidLine ) ); + + if (sel) + p.drawRect(1, 1, w - 3, h - 3); + + p.setPen( QPen( Qt::black, 0, Qt::SolidLine ) ); + p.drawRect(3, 3, w - 7, h - 7); + p.fillRect(QRect(4, 4, w - 8, h - 8), QBrush(c)); + + if (hasFocus()) + p.drawRect(0, 0, w - 1, h - 1); +} + +/*! + +*/ +ColorPickerButton::ColorPickerButton(QWidget *parent) + : QFrame(parent) +{ + setFrameStyle(StyledPanel); +} + +/*! + +*/ +void ColorPickerButton::mousePressEvent(QMouseEvent *) +{ + setFrameShadow(Sunken); + update(); +} + +/*! + +*/ +void ColorPickerButton::mouseMoveEvent(QMouseEvent *) +{ + setFocus(); + update(); +} + +/*! + +*/ +void ColorPickerButton::mouseReleaseEvent(QMouseEvent *) +{ + setFrameShadow(Raised); + repaint(); + emit clicked(); +} + +/*! + +*/ +void ColorPickerButton::keyPressEvent(QKeyEvent *e) +{ + if (e->key() == Qt::Key_Up + || e->key() == Qt::Key_Down + || e->key() == Qt::Key_Left + || e->key() == Qt::Key_Right) { + qApp->sendEvent(parent(), e); + } else if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Space || e->key() == Qt::Key_Return) { + setFrameShadow(Sunken); + update(); + } else { + QFrame::keyPressEvent(e); + } +} + +/*! + +*/ +void ColorPickerButton::keyReleaseEvent(QKeyEvent *e) +{ + if (e->key() == Qt::Key_Up + || e->key() == Qt::Key_Down + || e->key() == Qt::Key_Left + || e->key() == Qt::Key_Right) { + qApp->sendEvent(parent(), e); + } else if (e->key() == Qt::Key_Enter || e->key() == Qt::Key_Space || e->key() == Qt::Key_Return) { + setFrameShadow(Raised); + repaint(); + emit clicked(); + } else { + QFrame::keyReleaseEvent(e); + } + +} + +/*! + +*/ +void ColorPickerButton::focusInEvent(QFocusEvent *e) +{ + setFrameShadow(Raised); + update(); + QFrame::focusOutEvent(e); +} + +/*! + +*/ +void ColorPickerButton::focusOutEvent(QFocusEvent *e) +{ + setFrameShadow(Raised); + update(); + QFrame::focusOutEvent(e); +} + +/*! + +*/ +void ColorPickerButton::paintEvent(QPaintEvent *e) +{ + QFrame::paintEvent(e); + + QPainter p(this); + p.fillRect(contentsRect(), palette().button()); + + QRect r = rect(); + + int offset = frameShadow() == Sunken ? 1 : 0; + + QPen pen(palette().buttonText(), 1); + p.setPen(pen); + + p.drawRect(r.center().x() + offset - 4, r.center().y() + offset, 1, 1); + p.drawRect(r.center().x() + offset , r.center().y() + offset, 1, 1); + p.drawRect(r.center().x() + offset + 4, r.center().y() + offset, 1, 1); + if (hasFocus()) { + p.setPen( QPen( Qt::black, 0, Qt::SolidLine ) ); + p.drawRect(0, 0, width() - 1, height() - 1); + } + + p.end(); + +} + +#include "qtcolorpicker.moc" + diff --git a/Code/Mantid/MantidPlot/src/lib/3rdparty/qtcolorpicker/src/qtcolorpicker.h b/Code/Mantid/MantidPlot/src/lib/3rdparty/qtcolorpicker/src/qtcolorpicker.h new file mode 100644 index 0000000000000000000000000000000000000000..8fcfadb87dc5e6334a815d31e0dda77f6e523991 --- /dev/null +++ b/Code/Mantid/MantidPlot/src/lib/3rdparty/qtcolorpicker/src/qtcolorpicker.h @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** This file is part of a Qt Solutions component. +** +** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +** +** Contact: Qt Software Information (qt-info@nokia.com) +** +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Solutions Commercial License Agreement provided +** with the Software or, alternatively, in accordance with the terms +** contained in a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** Please note Third Party Software included with Qt Solutions may impose +** additional restrictions and it is the user's responsibility to ensure +** that they have met the licensing requirements of the GPL, LGPL, or Qt +** Solutions Commercial license and the relevant license of the Third +** Party Software they are using. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** +****************************************************************************/ + +#ifndef QTCOLORPICKER_H +#define QTCOLORPICKER_H +#include <QtGui/QPushButton> +#include <QtCore/QString> +#include <QtGui/QColor> + +#include <QtGui/QLabel> +#include <QtCore/QEvent> +#include <QtGui/QFocusEvent> + +#if defined(Q_WS_WIN) +# if !defined(QT_QTCOLORPICKER_EXPORT) && !defined(QT_QTCOLORPICKER_IMPORT) +# define QT_QTCOLORPICKER_EXPORT +# elif defined(QT_QTCOLORPICKER_IMPORT) +# if defined(QT_QTCOLORPICKER_EXPORT) +# undef QT_QTCOLORPICKER_EXPORT +# endif +# define QT_QTCOLORPICKER_EXPORT __declspec(dllimport) +# elif defined(QT_QTCOLORPICKER_EXPORT) +# undef QT_QTCOLORPICKER_EXPORT +# define QT_QTCOLORPICKER_EXPORT __declspec(dllexport) +# endif +#else +# define QT_QTCOLORPICKER_EXPORT +#endif + +class ColorPickerPopup; + +class QT_QTCOLORPICKER_EXPORT QtColorPicker : public QPushButton +{ + Q_OBJECT + + Q_PROPERTY(bool colorDialog READ colorDialogEnabled WRITE setColorDialogEnabled) + +public: + QtColorPicker(QWidget *parent = 0, + int columns = -1, bool enableColorDialog = true); + + ~QtColorPicker(); + + void insertColor(const QColor &color, const QString &text = QString::null, int index = -1); + + QColor currentColor() const; + + QColor color(int index) const; + + void setColorDialogEnabled(bool enabled); + bool colorDialogEnabled() const; + + void setStandardColors(); + + static QColor getColor(const QPoint &pos, bool allowCustomColors = true); + +public Q_SLOTS: + void setCurrentColor(const QColor &col); + +Q_SIGNALS: + void colorChanged(const QColor &); + +protected: + void paintEvent(QPaintEvent *e); + +private Q_SLOTS: + void buttonPressed(bool toggled); + void popupClosed(); + +private: + ColorPickerPopup *popup; + QColor col; + bool withColorDialog; + bool dirty; + bool firstInserted; +}; + +#endif diff --git a/Code/Mantid/MantidPlot/src/lib/CHANGES.txt b/Code/Mantid/MantidPlot/src/lib/CHANGES.txt new file mode 100644 index 0000000000000000000000000000000000000000..ddfb1cb78972f9c121748bb21e497b126eff67e1 --- /dev/null +++ b/Code/Mantid/MantidPlot/src/lib/CHANGES.txt @@ -0,0 +1,14 @@ +Release 0.0.2 +=================== + +Bug Fixes +--------- +1. ColorMapEditor: + the level values are now displayed using DoubleSpinBox objects + +2. DoubleSpinBox: + stepBy problem fixed + +Release 0.0.1 +=================== +Initial release. diff --git a/Code/Mantid/MantidPlot/src/lib/INSTALL b/Code/Mantid/MantidPlot/src/lib/INSTALL new file mode 100644 index 0000000000000000000000000000000000000000..6ef1f420010d82fc7c9bbc64021291a6ced70d36 --- /dev/null +++ b/Code/Mantid/MantidPlot/src/lib/INSTALL @@ -0,0 +1,37 @@ +Introduction +============ + +Qti uses qmake to build all its components and examples. +qmake is part of a Qt distribution. + +qmake reads project files, that contain the options and rules how to +build a certain project. A project file ends with the suffix "*.pro". + +You need Qt4 and Qwt 5.1 installed on your system. + +A) Unix Qt4 +========================== + +qmake +make + +If you have installed a shared library it's path has to be known to +the run-time linker of your operating system. On Linux systems read +"man ldconfig" ( or google for it ). Another option is to use +the LD_LIBRARY_PATH (on some systems LIBPATH is used instead, on MacOSX +it is called DYLD_LIBRARY_PATH) environment variable. + +B) Win32/MSVC Qt4 +===================== + +Please read the qmake documentation how to convert +your *.pro files into your development environment. + +F.e MSVC with nmake: +qmake qti.pro +nmake + +C) Win32/MinGW Qt4 +================== +qmake qti.pro +make diff --git a/Code/Mantid/MantidPlot/src/lib/README b/Code/Mantid/MantidPlot/src/lib/README new file mode 100644 index 0000000000000000000000000000000000000000..052c8ea451c2390b44417e8116f53c9cfaca4589 --- /dev/null +++ b/Code/Mantid/MantidPlot/src/lib/README @@ -0,0 +1,25 @@ + +The Qti Widget Library +---------------------- + + Qti is an extension to the Qt GUI library from Troll Tech AS. + The Qti library contains widgets and components which were + primarily developed for the QtiPlot software. + +Installation +------------ + + Read INSTALL file in order to find out how to build the Qti library. + +Copyright +--------- + + Qti Widget Library + Copyright (C) 2008 Ion Vasilief + + Qti is published under the GPL License, Version 3.0. + You should have received a copy of this licence in the file gpl-3.0.txt. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. diff --git a/Code/Mantid/MantidPlot/src/lib/doc/Doxyfile b/Code/Mantid/MantidPlot/src/lib/doc/Doxyfile new file mode 100644 index 0000000000000000000000000000000000000000..37b3868a0c8c9077c54a9ca9ef8afe88e21a9a76 --- /dev/null +++ b/Code/Mantid/MantidPlot/src/lib/doc/Doxyfile @@ -0,0 +1,236 @@ +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- +PROJECT_NAME = Qti +PROJECT_NUMBER = 0.0.2 +OUTPUT_DIRECTORY = . +CREATE_SUBDIRS = NO +OUTPUT_LANGUAGE = English +USE_WINDOWS_ENCODING = NO +BRIEF_MEMBER_DESC = YES +REPEAT_BRIEF = YES +ABBREVIATE_BRIEF = +ALWAYS_DETAILED_SEC = NO +INLINE_INHERITED_MEMB = NO +FULL_PATH_NAMES = YES +STRIP_FROM_PATH = +STRIP_FROM_INC_PATH = +SHORT_NAMES = NO +JAVADOC_AUTOBRIEF = NO +MULTILINE_CPP_IS_BRIEF = NO +DETAILS_AT_TOP = YES +INHERIT_DOCS = YES +DISTRIBUTE_GROUP_DOC = NO +TAB_SIZE = 4 +ALIASES = +OPTIMIZE_OUTPUT_FOR_C = NO +OPTIMIZE_OUTPUT_JAVA = NO +SUBGROUPING = YES +#--------------------------------------------------------------------------- +# Build related configuration options +#--------------------------------------------------------------------------- +EXTRACT_ALL = YES +EXTRACT_PRIVATE = YES +EXTRACT_STATIC = YES +EXTRACT_LOCAL_CLASSES = YES +EXTRACT_LOCAL_METHODS = NO +HIDE_UNDOC_MEMBERS = NO +HIDE_UNDOC_CLASSES = NO +HIDE_FRIEND_COMPOUNDS = NO +HIDE_IN_BODY_DOCS = NO +INTERNAL_DOCS = NO +CASE_SENSE_NAMES = YES +HIDE_SCOPE_NAMES = NO +SHOW_INCLUDE_FILES = YES +INLINE_INFO = YES +SORT_MEMBER_DOCS = YES +SORT_BRIEF_DOCS = YES +SORT_BY_SCOPE_NAME = NO +GENERATE_TODOLIST = YES +GENERATE_TESTLIST = YES +GENERATE_BUGLIST = YES +GENERATE_DEPRECATEDLIST= YES +ENABLED_SECTIONS = +MAX_INITIALIZER_LINES = 30 +SHOW_USED_FILES = YES +SHOW_DIRECTORIES = YES +FILE_VERSION_FILTER = +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- +QUIET = NO +WARNINGS = YES +WARN_IF_UNDOCUMENTED = YES +WARN_IF_DOC_ERROR = YES +WARN_NO_PARAMDOC = NO +WARN_FORMAT = "$file:$line: $text" +WARN_LOGFILE = +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- +INPUT = .. +FILE_PATTERNS = *.c \ + *.cc \ + *.cxx \ + *.cpp \ + *.c++ \ + *.dox \ + *.h \ + *.hh \ + *.hxx \ + *.hpp \ + *.h++ \ + *.txt \ + *.CC \ + *.C++ \ + *.HH \ + *.H++ \ + *.C \ + *.H +RECURSIVE = yes +EXCLUDE = +EXCLUDE_SYMLINKS = NO +EXCLUDE_PATTERNS = *moc_* +EXAMPLE_PATH = ../INSTALL ../gpl-3.0.txt +EXAMPLE_PATTERNS = +EXAMPLE_RECURSIVE = NO +IMAGE_PATH = +INPUT_FILTER = +FILTER_PATTERNS = +FILTER_SOURCE_FILES = NO +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- +SOURCE_BROWSER = NO +INLINE_SOURCES = NO +STRIP_CODE_COMMENTS = YES +REFERENCED_BY_RELATION = YES +REFERENCES_RELATION = YES +VERBATIM_HEADERS = YES +#--------------------------------------------------------------------------- +# configuration options related to the alphabetical class index +#--------------------------------------------------------------------------- +ALPHABETICAL_INDEX = YES +COLS_IN_ALPHA_INDEX = 5 +IGNORE_PREFIX = +#--------------------------------------------------------------------------- +# configuration options related to the HTML output +#--------------------------------------------------------------------------- +GENERATE_HTML = YES +HTML_OUTPUT = html +HTML_FILE_EXTENSION = .html +HTML_HEADER = +HTML_FOOTER = +HTML_STYLESHEET = +HTML_ALIGN_MEMBERS = YES +GENERATE_HTMLHELP = NO +CHM_FILE = +HHC_LOCATION = +GENERATE_CHI = NO +BINARY_TOC = NO +TOC_EXPAND = NO +DISABLE_INDEX = NO +ENUM_VALUES_PER_LINE = 4 +GENERATE_TREEVIEW = NO +TREEVIEW_WIDTH = 250 +#--------------------------------------------------------------------------- +# configuration options related to the LaTeX output +#--------------------------------------------------------------------------- +GENERATE_LATEX = NO +LATEX_OUTPUT = latex +LATEX_CMD_NAME = latex +MAKEINDEX_CMD_NAME = makeindex +COMPACT_LATEX = NO +PAPER_TYPE = a4wide +EXTRA_PACKAGES = +LATEX_HEADER = +PDF_HYPERLINKS = NO +USE_PDFLATEX = NO +LATEX_BATCHMODE = NO +LATEX_HIDE_INDICES = NO +#--------------------------------------------------------------------------- +# configuration options related to the RTF output +#--------------------------------------------------------------------------- +GENERATE_RTF = NO +RTF_OUTPUT = rtf +COMPACT_RTF = NO +RTF_HYPERLINKS = NO +RTF_STYLESHEET_FILE = +RTF_EXTENSIONS_FILE = +#--------------------------------------------------------------------------- +# configuration options related to the man page output +#--------------------------------------------------------------------------- +GENERATE_MAN = NO +MAN_OUTPUT = man +MAN_EXTENSION = .3 +MAN_LINKS = NO +#--------------------------------------------------------------------------- +# configuration options related to the XML output +#--------------------------------------------------------------------------- +GENERATE_XML = NO +XML_OUTPUT = xml +XML_SCHEMA = +XML_DTD = +XML_PROGRAMLISTING = YES +#--------------------------------------------------------------------------- +# configuration options for the AutoGen Definitions output +#--------------------------------------------------------------------------- +GENERATE_AUTOGEN_DEF = NO +#--------------------------------------------------------------------------- +# configuration options related to the Perl module output +#--------------------------------------------------------------------------- +GENERATE_PERLMOD = NO +PERLMOD_LATEX = NO +PERLMOD_PRETTY = YES +PERLMOD_MAKEVAR_PREFIX = +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- +ENABLE_PREPROCESSING = YES +MACRO_EXPANSION = NO +EXPAND_ONLY_PREDEF = NO +SEARCH_INCLUDES = YES +INCLUDE_PATH = +INCLUDE_FILE_PATTERNS = +PREDEFINED = +EXPAND_AS_DEFINED = +SKIP_FUNCTION_MACROS = YES +#--------------------------------------------------------------------------- +# Configuration::additions related to external references +#--------------------------------------------------------------------------- +TAGFILES = +GENERATE_TAGFILE = +ALLEXTERNALS = NO +EXTERNAL_GROUPS = YES +PERL_PATH = /usr/bin/perl +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- +CLASS_DIAGRAMS = YES +HIDE_UNDOC_RELATIONS = YES +# recommendation: install graphviz and use HAVE_DOT = YES +HAVE_DOT = NO +CLASS_GRAPH = YES +COLLABORATION_GRAPH = YES +GROUP_GRAPHS = YES +UML_LOOK = NO +TEMPLATE_RELATIONS = NO +INCLUDE_GRAPH = YES +INCLUDED_BY_GRAPH = YES +CALL_GRAPH = NO +GRAPHICAL_HIERARCHY = YES +DIRECTORY_GRAPH = YES +DOT_IMAGE_FORMAT = png +DOT_PATH = +DOTFILE_DIRS = +MAX_DOT_GRAPH_WIDTH = 1024 +MAX_DOT_GRAPH_HEIGHT = 1024 +MAX_DOT_GRAPH_DEPTH = 1000 +DOT_TRANSPARENT = NO +DOT_MULTI_TARGETS = NO +GENERATE_LEGEND = YES +DOT_CLEANUP = YES +#--------------------------------------------------------------------------- +# Configuration::additions related to the search engine +#--------------------------------------------------------------------------- +SEARCHENGINE = NO diff --git a/Code/Mantid/MantidPlot/src/lib/doc/html/images/color_map_editor.png b/Code/Mantid/MantidPlot/src/lib/doc/html/images/color_map_editor.png new file mode 100644 index 0000000000000000000000000000000000000000..3e50a00447b8e20a8c78028e00821c4ddece05a1 Binary files /dev/null and b/Code/Mantid/MantidPlot/src/lib/doc/html/images/color_map_editor.png differ diff --git a/Code/Mantid/MantidPlot/src/lib/doc/html/images/symbol_box.png b/Code/Mantid/MantidPlot/src/lib/doc/html/images/symbol_box.png new file mode 100644 index 0000000000000000000000000000000000000000..a156b706490cdccc29012c36d9385b9b16ffc4f7 Binary files /dev/null and b/Code/Mantid/MantidPlot/src/lib/doc/html/images/symbol_box.png differ diff --git a/Code/Mantid/MantidPlot/src/lib/doc/qti.dox b/Code/Mantid/MantidPlot/src/lib/doc/qti.dox new file mode 100644 index 0000000000000000000000000000000000000000..b3b7c1d39a163b5b3b756b5df64601e38318d052 --- /dev/null +++ b/Code/Mantid/MantidPlot/src/lib/doc/qti.dox @@ -0,0 +1,60 @@ +/*! + \mainpage Qti - Qt widgets for QtiPlot + +The Qti library contains GUI Components and utility classes which were primarily +developed for QtiPlot, a scientific plotting and data analysis software. + + \image html images/color_map_editor.png + + \section license License + + Qti is distributed under the terms of the \ref gpllicense. + + \section platforms Platforms + + Qti might be usable in all environments where you find + <a href="http://www.trolltech.com/products/qt">Qt 4</a>. + + \section dependencies Dependencies + + Qti depends on the following libraries: + <a href="http://www.trolltech.com/products/qt">Qt 4</a>, + <a href="http://qwt.sourceforge.net">Qwt 5.1</a>.\n + + \section downloads Downloads + <a href="http://prdownload.berlios.de/qtiplot/libqti.zip">libqti.zip</a> + + \section installonmainpage Installation + + Have a look at the qti.pro project file. It is prepared for building + static libraries in Win32 and Unix/X11 environments. + If you don't know what to do with it, read the file \ref qtiinstall and/or + Trolltechs <a href="http://doc.trolltech.com/4.4/qmake-manual.html">qmake</a> manual. + + \section support Support + If you are looking for individual support, or need someone who implements + your Qti component/application contact ion.vasilief@proindependent.com. + + \section relatedprojects Related Projects + + <a href="http://qwt.sourceforge.net">Qwt</a>, Qt Widgets for Technical Applications.\n + <a href="http://soft.proindependent.com/qtiplot.html">QtiPlot</a>, data analysis and scientific plotting tool. + + \section credits Credits: + \par Authors: + Ion Vasilief + \par Contributors: + Knut Franke, Tomomasa Ohkubo + \par Project admin: + Ion Vasilief \<ion.vasilief@proindependent.com\> +*/ + +/*! + \page gpllicense GPL License, Version 3 + \include "gpl-3.0.txt" +*/ + +/*! + \page qtiinstall INSTALL + \include "INSTALL" +*/ diff --git a/Code/Mantid/MantidPlot/src/lib/gpl-3.0.txt b/Code/Mantid/MantidPlot/src/lib/gpl-3.0.txt new file mode 100644 index 0000000000000000000000000000000000000000..94a9ed024d3859793618152ea559a168bbcbb5e2 --- /dev/null +++ b/Code/Mantid/MantidPlot/src/lib/gpl-3.0.txt @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + <program> Copyright (C) <year> <name of author> + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +<http://www.gnu.org/licenses/>. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +<http://www.gnu.org/philosophy/why-not-lgpl.html>. diff --git a/Code/Mantid/MantidPlot/src/lib/include/CollapsiveGroupBox.h b/Code/Mantid/MantidPlot/src/lib/include/CollapsiveGroupBox.h new file mode 100644 index 0000000000000000000000000000000000000000..ff5fa73ded26b0dbaa5813d86761d8152b602737 --- /dev/null +++ b/Code/Mantid/MantidPlot/src/lib/include/CollapsiveGroupBox.h @@ -0,0 +1,55 @@ +/*************************************************************************** + File : CollapsiveGroupBox.h + Project : QtiPlot + -------------------------------------------------------------------- + Copyright : (C) 2010 by Ion Vasilief + Email (use @ for *) : ion_vasilief*yahoo.fr + Description : A collapsive QGroupBox + + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + ***************************************************************************/ + +#ifndef COLLAPSIVE_GROUP_BOX__H +#define COLLAPSIVE_GROUP_BOX__H + +#include <QGroupBox> + +//! A collapsive QGroupBox. +/** + * + */ +class CollapsiveGroupBox : public QGroupBox +{ + Q_OBJECT + +public: + //! Constructor. + /** + * \param parent parent widget (only affects placement of the widget) + */ + CollapsiveGroupBox(const QString & title = QString(), QWidget * parent = 0); + +public slots: + void setCollapsed (bool collapsed = true); + void setExpanded (bool expanded = true); +}; + +#endif diff --git a/Code/Mantid/MantidPlot/src/ColorBox.h b/Code/Mantid/MantidPlot/src/lib/include/ColorBox.h similarity index 79% rename from Code/Mantid/MantidPlot/src/ColorBox.h rename to Code/Mantid/MantidPlot/src/lib/include/ColorBox.h index 6d53c6fb9181b0ec1d69fcafa9ab91c9232b3e93..f9026c9bbc12ad0592137c8c149f1821ec452565 100644 --- a/Code/Mantid/MantidPlot/src/ColorBox.h +++ b/Code/Mantid/MantidPlot/src/lib/include/ColorBox.h @@ -2,10 +2,10 @@ File : ColorBox.h Project : QtiPlot -------------------------------------------------------------------- - Copyright : (C) 2006 by Ion Vasilief, Tilman Hoener zu Siederdissen - Email (use @ for *) : ion_vasilief*yahoo.fr, thzs*gmx.net + Copyright : (C) 2006 by Ion Vasilief + Email (use @ for *) : ion_vasilief*yahoo.fr Description : A combo box to select a standard color - + ***************************************************************************/ /*************************************************************************** @@ -31,7 +31,10 @@ #include <QComboBox> -//! A combo box to select a standard color +//! A modified QComboBox used for color selection. +/** + * It contains a list of 24 predefined colors. + */ class ColorBox : public QComboBox { Q_OBJECT @@ -39,23 +42,31 @@ class ColorBox : public QComboBox public: //! Constructor /** - * @param parent :: parent widget + * \param parent parent widget */ ColorBox(QWidget *parent = 0); //! Set the current color void setColor(const QColor& c); //! Return the current color QColor color() const; - + //! Return the list of colors + static QList<QColor> colorList(); + //! Returns the color names + static QStringList colorNames(); //! Return the index for a given color static int colorIndex(const QColor& c); - //! Return the color at index 'colorindex' + //! Return the color at index 'colorIndex' static QColor color(int colorIndex); + //! Return the default color at index 'colorIndex' + static QColor defaultColor(int colorIndex); //! Returns TRUE if the color is included in the color box, otherwise returns FALSE. static bool isValidColor(const QColor& color); //! Returns the number of predefined colors static int numPredefinedColors(); - + //! Returns the color name for the predefined colors + static QStringList defaultColorNames(); + //! Returns the list of predefined colors + static QList<QColor> defaultColors(); protected: //! Internal initialization function @@ -67,4 +78,3 @@ protected: }; #endif - diff --git a/Code/Mantid/MantidPlot/src/ColorButton.h b/Code/Mantid/MantidPlot/src/lib/include/ColorButton.h similarity index 78% rename from Code/Mantid/MantidPlot/src/ColorButton.h rename to Code/Mantid/MantidPlot/src/lib/include/ColorButton.h index f37f867da4d4c7627b94a1fa3a24bb4af995c6a7..f6e106a776245753e7a52d6a4061e7de29dc4294 100644 --- a/Code/Mantid/MantidPlot/src/ColorButton.h +++ b/Code/Mantid/MantidPlot/src/lib/include/ColorButton.h @@ -2,9 +2,9 @@ File : ColorButton.h Project : QtiPlot -------------------------------------------------------------------- - Copyright : (C) 2007 by Ion Vasilief + Copyright : (C) 2009 by Ion Vasilief Email (use @ for *) : ion_vasilief*yahoo.fr - Description : A button used for color selection + Description : A wrapper around QtColorPicker from QtSolutions ***************************************************************************/ @@ -30,30 +30,29 @@ #ifndef COLORBUTTON_H #define COLORBUTTON_H -#include <QPushButton> +#include <qtcolorpicker.h> -//! A button used for color selection -class ColorButton : public QPushButton +//! A customized QtColorPicker used for color selection. +/** + * + */ +class ColorButton : public QtColorPicker { Q_OBJECT public: - //! Constructor + //! Constructor. + /** + * \param parent parent widget (only affects placement of the widget) + */ ColorButton(QWidget *parent = 0); - //! Set the color of the display part - void setColor(const QColor& c); - //! Get the color of the display part - QColor color(){return d_color;}; + //! Set the current color to be displayed + void setColor(const QColor& c){setCurrentColor (c);}; + //! Get the current color + QColor color(){return currentColor();}; signals: void colorChanged(); - -private slots: - void pickColor(); - -private: - void updateColor(); - QColor d_color; }; #endif diff --git a/Code/Mantid/MantidPlot/src/lib/include/ColorMapEditor.h b/Code/Mantid/MantidPlot/src/lib/include/ColorMapEditor.h new file mode 100644 index 0000000000000000000000000000000000000000..f41240d90759f307b839edfb0ff22af68d4ee50e --- /dev/null +++ b/Code/Mantid/MantidPlot/src/lib/include/ColorMapEditor.h @@ -0,0 +1,96 @@ +/*************************************************************************** + File : ColorMapEditor.h + Project : QtiPlot +-------------------------------------------------------------------- + Copyright : (C) 2006 by Ion Vasilief + Email (use @ for *) : ion_vasilief*yahoo.fr + Description : A QwtLinearColorMap Editor Widget + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + ***************************************************************************/ +#ifndef COLORMAPEDITOR_H +#define COLORMAPEDITOR_H + +#include <QWidget> +#include <QLocale> +#include <qwt_color_map.h> + +class QPushButton; +class QTableWidget; +class QCheckBox; +class DoubleSpinBox; + +//! A complex widget allowing to customize a QwtLinearColorMap. +/** + * It uses a QTableWidget to display the values in one column and their corresponding colors in a second column. + * A click on a table color pops-up a QColorDialog allowing to customize it. + + \image html images/color_map_editor.png + */ +class ColorMapEditor: public QWidget +{ + Q_OBJECT + +public: + //! Constructor. + /** + * \param parent parent widget (only affects placement of the widget) + */ + ColorMapEditor(const QLocale& locale = QLocale::system(), int precision = 6, QWidget* parent = 0); + //! Returns the customized color map. + QwtLinearColorMap colorMap(){return color_map;}; + //! Use this function to initialize the color map to be edited. + void setColorMap(const QwtLinearColorMap& map); + //! Use this function to initialize the values range. + void setRange(double min, double max); + //! Exports the map to a pseudo-XML string + static QString saveToXmlString(const QwtLinearColorMap& color_map); + +signals: + void scalingChanged(); + +protected slots: + void updateColorMap(); + void enableButtons(int row); + void showColorDialog(int row, int col); + void insertLevel(); + void deleteLevel(); + void setScaledColors(bool scale = true); + void spinBoxActivated(DoubleSpinBox *); + + bool eventFilter(QObject *object, QEvent *e); + +private: + //! Table displaying the values ranges in the first column and their corresponding colors in the second column + QTableWidget *table; + QPushButton *insertBtn, *deleteBtn; + QCheckBox *scaleColorsBox; + + //! Color map object + QwtLinearColorMap color_map; + //! Levels range + double min_val, max_val; + //! Locale settings used to display level values + QLocale d_locale; + //! Precision used to display level values + int d_precision; +}; + +#endif diff --git a/Code/Mantid/MantidPlot/src/lib/include/DoubleSpinBox.h b/Code/Mantid/MantidPlot/src/lib/include/DoubleSpinBox.h new file mode 100644 index 0000000000000000000000000000000000000000..6fa07a7f2aa98bdfa425cceff374514bdf8cc794 --- /dev/null +++ b/Code/Mantid/MantidPlot/src/lib/include/DoubleSpinBox.h @@ -0,0 +1,105 @@ +/*************************************************************************** + File : DoubleSpinBox.h + Project : QtiPlot + -------------------------------------------------------------------- + Copyright : (C) 2007-2008 by Ion Vasilief + Email (use @ for *) : ion_vasilief*yahoo.fr + Description : A Double Spin Box + + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + ***************************************************************************/ +#ifndef DoubleSpinBox_H +#define DoubleSpinBox_H + +#include <QAbstractSpinBox> +#include <QCheckBox> + +//! A QDoubleSpinBox allowing to customize numbers display with respect to locale settings. +/** + * It allows the user to specify a custom display format. + */ +class DoubleSpinBox : public QAbstractSpinBox +{ + Q_OBJECT + +public: + //! Constructor. + /** + * \param format format used to display numbers: has the same meaning as in QLocale::toString ( double i, char f = 'g', int prec = 6 ) + * \param parent parent widget (only affects placement of the dialog) + */ + DoubleSpinBox(const char format = 'g', QWidget * parent = 0); + + void setSingleStep(double val); + void setMaximum(double max); + void setMinimum(double min); + void setRange(double min, double max); + + int decimals(){return d_prec;}; + void setDecimals(int prec){if (prec >= 0) d_prec = prec;}; + + double value(){interpretText(); return d_value;}; + bool setValue(double val); + + void setFormat(const char format, int prec = 1){d_format = format; setDecimals(prec);}; + + QString textFromValue ( double value ) const; + virtual QValidator::State validate ( QString & input, int & pos ) const; + +signals: + void valueChanged ( double d ); + //! Signal emitted when the spin box gains focus + void activated(DoubleSpinBox *); + +private slots: + void interpretText(); + +protected: + void stepBy ( int steps ); + StepEnabled stepEnabled () const; + void focusInEvent(QFocusEvent *); + +private: + char d_format; + double d_min_val; + double d_max_val; + double d_value; + double d_step; + int d_prec; +}; + +//! A checkable DoubleSpinBox that can be used to select the limits of a double interval. +class RangeLimitBox : public QWidget +{ +public: + enum LimitType{LeftLimit, RightLimit}; + + RangeLimitBox(LimitType type, QWidget * parent = 0); + void setDecimals(int prec){d_spin_box->setDecimals(prec);}; + double value(); + bool isChecked(){return d_checkbox->isChecked();}; + +private: + DoubleSpinBox *d_spin_box; + QCheckBox *d_checkbox; + LimitType d_type; +}; +#endif // FITDIALOG_H diff --git a/Code/Mantid/MantidPlot/src/lib/include/ExtensibleFileDialog.h b/Code/Mantid/MantidPlot/src/lib/include/ExtensibleFileDialog.h new file mode 100644 index 0000000000000000000000000000000000000000..25e74562d319b5a730953a63de714c1d5ba1fbad --- /dev/null +++ b/Code/Mantid/MantidPlot/src/lib/include/ExtensibleFileDialog.h @@ -0,0 +1,83 @@ +/*************************************************************************** + File : ExtensibleFileDialog.h + Project : QtiPlot + -------------------------------------------------------------------- + Copyright : (C) 2007 by Knut Franke, Ion Vasilief + Email (use @ for *) : knut.franke*gmx.de, ion_vasilief*yahoo.fr + Description : QFileDialog plus generic extension support + + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + ***************************************************************************/ +#ifndef EXTENSIBLE_FILE_DIALOG_H +#define EXTENSIBLE_FILE_DIALOG_H + +#include <QFileDialog> +#include <QPushButton> + +//! QFileDialog plus generic extension support. +/** + * This is a simple hack on top of QFileDialog that allows a custom extension widget to be added to + * the bottom of the dialog. A button is provided for toggling display of this widget on/off. + * + * For the placement of button and extension widget, it is assumed that QFileDialog uses a + * QGridLayout as its top-level layout. Other layouts will probably lead to a strange outlook, + * although the functionality should stay intact. + */ +class ExtensibleFileDialog : public QFileDialog +{ + Q_OBJECT + + public: + //! Constructor. + /** + * \param parent parent widget (only affects placement of the dialog) + * \param extended flag: show/hide the advanced options on start-up + * \param flags window flags + */ + ExtensibleFileDialog(QWidget *parent=0, bool extended = true, Qt::WFlags flags=0); + //! Set the extension widget to be displayed when the user presses the toggle button. + void setExtensionWidget(QWidget *extension); + + //! Tells weather the dialog has a valid extension widget + bool isExtendable(){return d_extension != NULL;}; + bool isExtended(){return d_extension_toggle->isChecked();}; + //! Toggle extension widget on/off + void setExtended(bool extended); + //! Sets the text to be displayed in the toggle button + void setExtentionToggleButtonText(const QString& text){d_extension_toggle->setText(text);}; + //! Enables/Disables editing of the file type filter + void setEditableFilter(bool on = true); + + private slots: + void updateToggleButtonText(bool); + + protected: + //! Button for toggling display of extension on/off. + QPushButton *d_extension_toggle; + + private: + //! The extension widget + QWidget *d_extension; + //! The layout row (of the assumed QGridLayout) used for extensions + int d_extension_row; +}; + +#endif // ifndef EXTENSIBLE_FILE_DIALOG_H diff --git a/Code/Mantid/MantidPlot/src/lib/include/LineNumberDisplay.h b/Code/Mantid/MantidPlot/src/lib/include/LineNumberDisplay.h new file mode 100644 index 0000000000000000000000000000000000000000..0b0cf139959984cdb55894a1b4a3c87be6cbfb96 --- /dev/null +++ b/Code/Mantid/MantidPlot/src/lib/include/LineNumberDisplay.h @@ -0,0 +1,61 @@ +/*************************************************************************** + File : LineNumberDisplay.h + Project : QtiPlot + -------------------------------------------------------------------- + Copyright : (C) 2008 by Ion Vasilief + Email (use @ for *) : ion_vasilief*yahoo.fr + Description : A widget displaying line numbers for a QTextEdit + + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + ***************************************************************************/ +#ifndef LineNumberDisplay_H +#define LineNumberDisplay_H + +#include <QTextEdit> + +//! A QTextEdit displaying line numbers. +/** + * It must be used in connection with another "source" QTextEdit. + */ +class LineNumberDisplay: public QTextEdit +{ + Q_OBJECT + +public: + //! Constructor + /** + * \param te the "source" QTextEdit for which we want to display the line numbers + * \param parent parent widget (only affects placement of the dialog) + */ + LineNumberDisplay(QTextEdit *te, QWidget *parent = 0); + +public slots: + void updateLineNumbers(bool force = false); + void updateDocumentSelection(); + +private slots: + void changeCharFormat (const QTextCharFormat &); + +private: + void showEvent(QShowEvent *); + QTextEdit *d_text_edit; +}; +#endif diff --git a/Code/Mantid/MantidPlot/src/lib/include/PatternBox.h b/Code/Mantid/MantidPlot/src/lib/include/PatternBox.h new file mode 100644 index 0000000000000000000000000000000000000000..fc0063ee2c04d1cf28fde5fe8e67c7b6e25f16eb --- /dev/null +++ b/Code/Mantid/MantidPlot/src/lib/include/PatternBox.h @@ -0,0 +1,61 @@ +/*************************************************************************** + File : PatternBox.h + Project : QtiPlot + -------------------------------------------------------------------- + Copyright : (C) 2006 by Tomomasa Ohkubo, Ion Vasilief + Email (use @ for *) : ion_vasilief*yahoo.fr + Description : Pattern combo box + + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + ***************************************************************************/ +#ifndef PATTERNBOX_H +#define PATTERNBOX_H + +#include <QComboBox> + +//! A modified QComboBox allowing to choose a Qt::BrushStyle style. +/** + * This is a simple hack on top of the QComboBox class. + */ +class PatternBox : public QComboBox +{ + Q_OBJECT + +public: + //! Constructor. + /** + * \param parent parent widget (only affects placement of the widget) + */ + PatternBox(QWidget *parent = 0); + void setPattern(const Qt::BrushStyle& c); + Qt::BrushStyle getSelectedPattern() const; + + static int patternIndex(const Qt::BrushStyle& style); + static Qt::BrushStyle brushStyle(int index); + +protected: + void init(); + +private: + static const Qt::BrushStyle patterns[]; +}; + +#endif diff --git a/Code/Mantid/MantidPlot/src/lib/include/PenStyleBox.h b/Code/Mantid/MantidPlot/src/lib/include/PenStyleBox.h new file mode 100644 index 0000000000000000000000000000000000000000..9ff608d13b7f6f47d8b2f9eab35ef1cbf43b869e --- /dev/null +++ b/Code/Mantid/MantidPlot/src/lib/include/PenStyleBox.h @@ -0,0 +1,58 @@ +/*************************************************************************** + File : PenStyleBox.h + Project : QtiPlot + -------------------------------------------------------------------- + Copyright : (C) 2008 Ion Vasilief + Email (use @ for *) : ion_vasilief*yahoo.fr + Description : Pen style combo box + + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + ***************************************************************************/ +#ifndef PEN_STYLE_BOX_H +#define PEN_STYLE_BOX_H + +#include <QComboBox> + +//! A modified QComboBox allowing to choose a Qt::PenStyle. +/** + * This is a simple hack on top of the QComboBox class. + */ +class PenStyleBox : public QComboBox +{ + Q_OBJECT + +public: + //! Constructor. + /** + * \param parent parent widget (only affects placement of the widget) + */ + PenStyleBox(QWidget *parent = 0); + void setStyle(const Qt::PenStyle& style); + Qt::PenStyle style() const; + + static int styleIndex(const Qt::PenStyle& style); + static Qt::PenStyle penStyle(int index); + +private: + static const Qt::PenStyle patterns[]; +}; + +#endif diff --git a/Code/Mantid/MantidPlot/src/lib/include/SymbolBox.h b/Code/Mantid/MantidPlot/src/lib/include/SymbolBox.h new file mode 100644 index 0000000000000000000000000000000000000000..173895af7d6f5730fbd897ef9ba52e00d8c17450 --- /dev/null +++ b/Code/Mantid/MantidPlot/src/lib/include/SymbolBox.h @@ -0,0 +1,69 @@ +/*************************************************************************** + File : SymbolBox.h + Project : QtiPlot + -------------------------------------------------------------------- + Copyright : (C) 2006 by Ion Vasilief + Email (use @ for *) : ion_vasilief*yahoo.fr + Description : Plot symbol combo box + + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + ***************************************************************************/ +#ifndef SYMBOLBOX_H +#define SYMBOLBOX_H + +#include <QComboBox> +#include <qwt_symbol.h> + +//! A modified QComboBox allowing to choose a QwtSmbol style. +/** + * This is a simple hack on top of the QComboBox class. + \image html images/symbol_box.png + */ +class SymbolBox : public QComboBox +{ + Q_OBJECT +public: + //! Constructor. + /** + * \param parent parent widget (only affects placement of the widget) + */ + SymbolBox(bool showNoSymbol = true, QWidget *parent = 0); + + void setStyle(const QwtSymbol::Style& c); + QwtSymbol::Style selectedSymbol() const; + + static QwtSymbol::Style style(int index); + static int symbolIndex(const QwtSymbol::Style& style); + static QList<int> defaultSymbols(); + +signals: + //! Signal emitted when the box gains focus + void activated(SymbolBox *); + +protected: + void init(bool showNoSymbol); + void focusInEvent(QFocusEvent *); + +private: + static const QwtSymbol::Style symbols[]; +}; + +#endif diff --git a/Code/Mantid/MantidPlot/src/lib/include/SymbolDialog.h b/Code/Mantid/MantidPlot/src/lib/include/SymbolDialog.h new file mode 100644 index 0000000000000000000000000000000000000000..488c106b409604e0f8b30b00c2fc0e5246f8cd46 --- /dev/null +++ b/Code/Mantid/MantidPlot/src/lib/include/SymbolDialog.h @@ -0,0 +1,106 @@ +/*************************************************************************** + File : SymbolDialog.h + Project : QtiPlot + -------------------------------------------------------------------- + Copyright : (C) 2006 by Ion Vasilief, Tilman Hoener zu Siederdissen + Email (use @ for *) : ion_vasilief*yahoo.fr, thzs*gmx.net + Description : Tool window to select special text characters + + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + ***************************************************************************/ +#ifndef SYMBOLDIALOG_H +#define SYMBOLDIALOG_H + +#include <QDialog> +class QPushButton; +class QSizePolicy; +class QGroupBox; +class QShortcut; +class QHBoxLayout; +class QVBoxLayout; +class QGridLayout; +class QButtonGroup; + +//! Tools window to select special text characters +class SymbolDialog : public QDialog +{ + Q_OBJECT + +public: + //! Character set + enum CharSet{ + lowerGreek = 0, /*!< lower case Greek letters */ + upperGreek = 1, /*!< upper case Greek letters */ + mathSymbols = 2, /*!< mathematical symbols */ + arrowSymbols = 3, /*!< arrow symbols */ + numberSymbols = 4, /*!< number symbols (e.g. 1/2, vi)*/ + latexArrowSymbols = 5, /*!< default LaTeX arrow symbols */ + latexMathSymbols = 6 /*!< default LaTeX math symbols */ + }; + + //! Constructor + /** + * \param charSet character set (lower- or uppercase) + * \param parent parent widget + * \param fl window flags + */ + SymbolDialog(CharSet charSet, QWidget* parent = 0, Qt::WFlags fl = 0 ); + +private: + //! Show lowercase Greek characters + void initLowerGreekChars(); + //! Show uppercase Greek characters + void initUpperGreekChars(); + //! Show mathematical symbols + void initMathSymbols(); + //! Show arrow symbols + void initArrowSymbols(); + //! Show number symbols + void initNumberSymbols(); + //! Show default LaTeX arrow symbols + void initLatexArrowSymbols(); + //! Show default LaTeX math symbols + void initLatexMathSymbols(); + + QButtonGroup * buttons; + QPushButton * closeButton; + int numButtons; + QVBoxLayout * mainLayout; + QGridLayout * gridLayout; + +protected: + //! Event handler: When the dialog gets the focus the first button is set to react on [return] + void focusInEvent( QFocusEvent * event ); + +public slots: + //! Change language (reset title) + virtual void languageChange(); + //! Find and emit char from pressed button + void getChar(int btnIndex); + //! Find and emit char from current button ([return] pressed) + void addCurrentChar(); + +signals: + //! Emitted when a letter is to be added + void addLetter(const QString&); +}; + +#endif // exportDialog_H diff --git a/Code/Mantid/MantidPlot/src/lib/include/TextFormatButtons.h b/Code/Mantid/MantidPlot/src/lib/include/TextFormatButtons.h new file mode 100644 index 0000000000000000000000000000000000000000..5f3de25e078244f4ac4deadf7e2d9693da2618a0 --- /dev/null +++ b/Code/Mantid/MantidPlot/src/lib/include/TextFormatButtons.h @@ -0,0 +1,90 @@ +/*************************************************************************** + File : TextFormatButtons.h + Project : QtiPlot + -------------------------------------------------------------------- + Copyright : (C) 2006 by Ion Vasilief, Tilman Hoener zu Siederdissen + Email (use @ for *) : ion_vasilief*yahoo.fr, thzs*gmx.net + Description : Widget with text format buttons (connected to a QTextEdit) + + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + ***************************************************************************/ + +#ifndef TEXTFORMATBUTTONS_H +#define TEXTFORMATBUTTONS_H + +#include <QWidget> +class QTextEdit; +class QPushButton; + +//! Widget with text format buttons (connected to a QTextEdit) +class TextFormatButtons : public QWidget +{ + Q_OBJECT + +public: + enum Buttons{Plot3D, AxisLabel, Legend, Equation, TexLegend}; + + //! Constructor + /** + * \param textEdit the QTextEdit that the buttons shall affect + * \param parent parent widget + */ + TextFormatButtons(QTextEdit * textEdit, Buttons buttons = Plot3D, QWidget * parent=0); + void setButtons(Buttons btns); + +private: + QTextEdit *connectedTextEdit; + Buttons d_buttons; + //! Internal function: format selected text with prefix and postfix + void formatText(const QString & prefix, const QString & postfix); + void init(Buttons btns); + +private slots: + //! Format seleted text to fraction + void addFraction(); + //! Format seleted text to square root + void addSquareRoot(); + //! Format seleted text to subscript + void addSubscript(); + //! Format seleted text to superscript + void addSuperscript(); + //! Format seleted text to underlined + void addUnderline(); + //! Format seleted text to italics + void addItalics(); + //! Format seleted text to bold + void addBold(); + //! Insert curve marker into the text + void addCurve(); + + //! Let the user insert lower case greek letters + void showLowerGreek(); + //! Let the user insert capital greek letters + void showUpperGreek(); + //! Let the user insert mathematical symbols + void showMathSymbols(); + //! Let the user insert arrow symbols + void showArrowSymbols(); + //! Insert 'letter' into the text + void addSymbol(const QString& letter); +}; + +#endif // TEXTFORMATBUTTONS_H diff --git a/Code/Mantid/MantidPlot/src/lib/libqti.pri b/Code/Mantid/MantidPlot/src/lib/libqti.pri new file mode 100644 index 0000000000000000000000000000000000000000..1bc12a1ca6bb857bf7537d50da29016e58cd5a79 --- /dev/null +++ b/Code/Mantid/MantidPlot/src/lib/libqti.pri @@ -0,0 +1,39 @@ +############################################################### +##################### libqti ################################## +############################################################### + +INCLUDEPATH += src/lib/include + +HEADERS += src/lib/include/CollapsiveGroupBox.h \ + src/lib/include/ColorBox.h \ + src/lib/include/ColorButton.h \ + src/lib/include/ColorMapEditor.h \ + src/lib/include/DoubleSpinBox.h \ + src/lib/include/ExtensibleFileDialog.h \ + src/lib/include/LineNumberDisplay.h \ + src/lib/include/PatternBox.h \ + src/lib/include/PenStyleBox.h \ + src/lib/include/SymbolBox.h \ + src/lib/include/SymbolDialog.h \ + src/lib/include/TextFormatButtons.h \ + +SOURCES += src/lib/src/CollapsiveGroupBox.cpp \ + src/lib/src/ColorBox.cpp \ + src/lib/src/ColorButton.cpp \ + src/lib/src/ColorMapEditor.cpp \ + src/lib/src/DoubleSpinBox.cpp \ + src/lib/src/ExtensibleFileDialog.cpp \ + src/lib/src/LineNumberDisplay.cpp \ + src/lib/src/PatternBox.cpp \ + src/lib/src/PenStyleBox.cpp \ + src/lib/src/SymbolBox.cpp \ + src/lib/src/SymbolDialog.cpp \ + src/lib/src/TextFormatButtons.cpp \ + +############################################################### +##################### 3rdparty Qt Solutions ################### +############################################################### + +INCLUDEPATH += src/lib/3rdparty/qtcolorpicker/src +HEADERS += src/lib/3rdparty/qtcolorpicker/src/qtcolorpicker.h +SOURCES += src/lib/3rdparty/qtcolorpicker/src/qtcolorpicker.cpp diff --git a/Code/Mantid/MantidPlot/src/lib/qti.pro b/Code/Mantid/MantidPlot/src/lib/qti.pro new file mode 100755 index 0000000000000000000000000000000000000000..b7b93d8aee45df32167d7043ce67f14e5e4c1f3d --- /dev/null +++ b/Code/Mantid/MantidPlot/src/lib/qti.pro @@ -0,0 +1,50 @@ +QMAKE_PROJECT_DEPTH = 0 +linux-g++-64: libsuff=64 + +TARGET = qti +TEMPLATE = lib + +VERSION = 0.0.1 + +CONFIG += thread +CONFIG += warn_on +CONFIG += release +CONFIG += staticlib + +MOC_DIR = ./tmp/ +OBJECTS_DIR = ./tmp/ +DESTDIR = ./ + +INCLUDEPATH += ./include/ +INCLUDEPATH += ../../../3rdparty/qwt/src + +##################### Linux (Mac OS X) ###################################### + +# statically link against Qwt library in 3rdparty +unix:LIBS += ../3rdparty/qwt/lib/libqwt.a + +# dynamically link against dependencies if they are installed system-wide +#unix:LIBS += -lqwt + +##################### Windows ############################################### +win32:LIBS += ../3rdparty/qwt/lib/libqwt.a + +HEADERS += include/ColorBox.h \ + include/ColorButton.h \ + include/ColorMapEditor.h \ + include/DoubleSpinBox.h \ + include/ExtensibleFileDialog.h \ + include/LineNumberDisplay.h \ + include/PatternBox.h \ + include/PenStyleBox.h \ + include/SymbolBox.h \ + +SOURCES += src/ColorBox.cpp \ + src/ColorButton.cpp \ + src/ColorMapEditor.cpp \ + src/DoubleSpinBox.cpp \ + src/ExtensibleFileDialog.cpp \ + src/LineNumberDisplay.cpp \ + src/PatternBox.cpp \ + src/PenStyleBox.cpp \ + src/SymbolBox.cpp \ diff --git a/Code/Mantid/MantidPlot/src/lib/src/CollapsiveGroupBox.cpp b/Code/Mantid/MantidPlot/src/lib/src/CollapsiveGroupBox.cpp new file mode 100644 index 0000000000000000000000000000000000000000..4257626898c5a2e2fcdf4cc6b164f3f5f79518f5 --- /dev/null +++ b/Code/Mantid/MantidPlot/src/lib/src/CollapsiveGroupBox.cpp @@ -0,0 +1,55 @@ +/*************************************************************************** + File : CollapsiveGroupBox.cpp + Project : QtiPlot + -------------------------------------------------------------------- + Copyright : (C) 2010 by Ion Vasilief + Email (use @ for *) : ion_vasilief*yahoo.fr + Description : A collapsive QGroupBox + + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + ***************************************************************************/ +#include "CollapsiveGroupBox.h" + +CollapsiveGroupBox::CollapsiveGroupBox(const QString & title, QWidget *parent) : QGroupBox(title, parent) +{ + setCheckable(true); + connect(this, SIGNAL(toggled(bool)), this, SLOT(setExpanded(bool))); +} + +void CollapsiveGroupBox::setCollapsed(bool collapsed) +{ + foreach (QObject *o, children()){ + if (o->isWidgetType()) + ((QWidget *)o)->setVisible(collapsed); + } + + setFlat(collapsed); +} + +void CollapsiveGroupBox::setExpanded(bool expanded) +{ + foreach (QObject *o, children()){ + if (o->isWidgetType()) + ((QWidget *)o)->setVisible(expanded); + } + + setFlat(!expanded); +} diff --git a/Code/Mantid/MantidPlot/src/lib/src/ColorBox.cpp b/Code/Mantid/MantidPlot/src/lib/src/ColorBox.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8af6323403bcff94bb9faf87e6d1fcb163fdb0c5 --- /dev/null +++ b/Code/Mantid/MantidPlot/src/lib/src/ColorBox.cpp @@ -0,0 +1,205 @@ +/*************************************************************************** + File : ColorBox.cpp + Project : QtiPlot + -------------------------------------------------------------------- + Copyright : (C) 2006-2010 by Ion Vasilief, Alex Kargovsky + Email (use @ for *) : ion_vasilief*yahoo.fr, kargovsky*yumr.phys.msu.su + Description : A combo box to select a standard color + + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + ***************************************************************************/ +#include "ColorBox.h" + +#include <QSettings> +#include <QPixmap> +#include <QPainter> +#include <algorithm> + +const QColor ColorBox::colors[] = { + QColor(Qt::black), + QColor(Qt::red), + QColor(Qt::green), + QColor(Qt::blue), + QColor(Qt::cyan), + QColor(Qt::magenta), + QColor(Qt::yellow), + QColor(Qt::darkYellow), + QColor(Qt::darkBlue), + QColor(Qt::darkMagenta), + QColor(Qt::darkRed), + QColor(Qt::darkGreen), + QColor(Qt::darkCyan), + QColor("#0000A0"), + QColor("#FF8000"), + QColor("#8000FF"), + QColor("#FF0080"), + QColor(Qt::white), + QColor(Qt::lightGray), + QColor(Qt::gray), + QColor("#FFFF80"), + QColor("#80FFFF"), + QColor("#FF80FF"), + QColor(Qt::darkGray), +}; + +ColorBox::ColorBox(QWidget *parent) : QComboBox(parent) +{ + setEditable(false); + init(); +} + +void ColorBox::init() +{ + QList<QColor> indexedColors = colorList(); + QStringList color_names = colorNames(); + + QPixmap icon = QPixmap(28, 16); + QRect r = QRect(0, 0, 27, 15); + + QPainter p; + p.begin(&icon); + + for (int i = 0; i < indexedColors.size(); i++){ + p.setBrush(QBrush(indexedColors[i])); + p.drawRect(r); + this->addItem(icon, color_names[i]); + } + p.end(); +} + +void ColorBox::setColor(const QColor& c) +{ + setCurrentIndex(colorIndex(c)); +} + +QColor ColorBox::color() const +{ + return color(this->currentIndex()); +} + +int ColorBox::colorIndex(const QColor& c) +{ + if (!isValidColor(c)) + return 0; + + return colorList().indexOf(c); +} + +QColor ColorBox::color(int colorIndex) +{ + QList<QColor> colorsList = colorList(); + if (colorIndex >= 0 && colorIndex < colorsList.size()) + return colorsList[colorIndex]; + + return Qt::black; // default color is black. +} + +QList<QColor> ColorBox::colorList() +{ +#ifdef Q_OS_MAC + QSettings settings(QSettings::IniFormat,QSettings::UserScope, "ProIndependent", "QtiPlot"); +#else + QSettings settings(QSettings::NativeFormat,QSettings::UserScope, "ProIndependent", "QtiPlot"); +#endif + settings.beginGroup("/General"); + + QList<QColor> indexedColors; + QStringList lst = settings.value("/IndexedColors").toStringList(); + if (!lst.isEmpty()){ + for (int i = 0; i < lst.size(); i++) + indexedColors << QColor(lst[i]); + } else { + for (int i = 0; i < colors_count; i++) + indexedColors << colors[i]; + } + settings.endGroup(); + + return indexedColors; +} + +QStringList ColorBox::colorNames() +{ +#ifdef Q_OS_MAC + QSettings settings(QSettings::IniFormat,QSettings::UserScope, "ProIndependent", "QtiPlot"); +#else + QSettings settings(QSettings::NativeFormat,QSettings::UserScope, "ProIndependent", "QtiPlot"); +#endif + settings.beginGroup("/General"); + QStringList color_names = settings.value("/IndexedColorNames", defaultColorNames()).toStringList(); + settings.endGroup(); + return color_names; +} + +QColor ColorBox::defaultColor(int colorIndex) +{ + if (colorIndex >= 0 && colorIndex < (int)sizeof(colors)) + return colors[colorIndex]; + + return Qt::black; // default color is black. +} + +bool ColorBox::isValidColor(const QColor& color) +{ + return colorList().contains(color); +} + +int ColorBox::numPredefinedColors() +{ + return colors_count; +} + +QStringList ColorBox::defaultColorNames() +{ + QStringList color_names = QStringList() << tr( "black" ); + color_names << tr( "red" ); + color_names << tr( "green" ); + color_names << tr( "blue" ); + color_names << tr( "cyan" ); + color_names << tr( "magenta" ); + color_names << tr( "yellow" ); + color_names << tr( "dark yellow" ); + color_names << tr( "navy" ); + color_names << tr( "purple" ); + color_names << tr( "wine" ); + color_names << tr( "olive" ); + color_names << tr( "dark cyan" ); + color_names << tr( "royal" ); + color_names << tr( "orange" ); + color_names << tr( "violet" ); + color_names << tr( "pink" ); + color_names << tr( "white" ); + color_names << tr( "light gray" ); + color_names << tr( "gray" ); + color_names << tr( "light yellow" ); + color_names << tr( "light cyan" ); + color_names << tr( "light magenta" ); + color_names << tr( "dark gray" ); + return color_names; +} + +QList<QColor> ColorBox::defaultColors() +{ + QList<QColor> lst; + for (int i = 0; i < colors_count; i++) + lst << colors[i]; + + return lst; +} diff --git a/Code/Mantid/MantidPlot/src/ColorButton.cpp b/Code/Mantid/MantidPlot/src/lib/src/ColorButton.cpp similarity index 69% rename from Code/Mantid/MantidPlot/src/ColorButton.cpp rename to Code/Mantid/MantidPlot/src/lib/src/ColorButton.cpp index 67ca5b868e24802f558f13880d0f5eb324402a47..07ab110d8f3dd293ae14b5c90c63ef829e22bf7e 100644 --- a/Code/Mantid/MantidPlot/src/ColorButton.cpp +++ b/Code/Mantid/MantidPlot/src/lib/src/ColorButton.cpp @@ -2,9 +2,9 @@ File : ColorButton.cpp Project : QtiPlot -------------------------------------------------------------------- - Copyright : (C) 2007 by Ion Vasilief + Copyright : (C) 2009 - 2010 by Ion Vasilief Email (use @ for *) : ion_vasilief*yahoo.fr - Description : A button used for color selection + Description : A wrapper around QtColorPicker from QtSolutions ***************************************************************************/ @@ -27,45 +27,23 @@ * * ***************************************************************************/ #include "ColorButton.h" -#include <QPainter> +#include "ColorBox.h" #include <QColorDialog> -ColorButton::ColorButton(QWidget *parent) : QPushButton(parent), - d_color(Qt::black) +ColorButton::ColorButton(QWidget *parent) : QtColorPicker(parent) { - updateColor(); - connect(this, SIGNAL(clicked()), this, SLOT(pickColor())); -} - -void ColorButton::setColor(const QColor& c) -{ - if (d_color == c) - return; - - d_color = c; - updateColor(); - emit colorChanged(); -} - -void ColorButton::updateColor() -{ - QRect r = QRect(0, 0, 27, 15); - QPixmap pix(QSize(28, 16)); - pix.fill(d_color); - - QPainter p; - p.begin(&pix); - p.drawRect(r); - p.end(); - - setIcon(QIcon(pix)); -} - -void ColorButton::pickColor() -{ - QColor c = QColorDialog::getColor(d_color, this); - if ( !c.isValid() ) - return ; - - setColor(c); + QStringList color_names = ColorBox::defaultColorNames(); + QList<QColor> defaultColors = ColorBox::defaultColors(); + for (int i = 0; i < ColorBox::numPredefinedColors(); i++) + insertColor(defaultColors[i], color_names[i]); + + QList<QColor> colors = ColorBox::colorList(); + color_names = ColorBox::colorNames(); + for (int i = 0; i < colors.count(); i++){ + QColor c = colors[i]; + if (!defaultColors.contains(c)) + insertColor(c, color_names[i]); + } + + connect(this, SIGNAL(colorChanged(const QColor & )), this, SIGNAL(colorChanged())); } diff --git a/Code/Mantid/MantidPlot/src/lib/src/ColorMapEditor.cpp b/Code/Mantid/MantidPlot/src/lib/src/ColorMapEditor.cpp new file mode 100644 index 0000000000000000000000000000000000000000..29774a149dfebde9688777ac84decf95eaf20675 --- /dev/null +++ b/Code/Mantid/MantidPlot/src/lib/src/ColorMapEditor.cpp @@ -0,0 +1,312 @@ +/*************************************************************************** + File : ColorMapEditor.cpp + Project : QtiPlot +-------------------------------------------------------------------- + Copyright : (C) 2006 by Ion Vasilief + Email (use @ for *) : ion_vasilief*yahoo.fr + Description : A QwtLinearColorMap Editor Widget + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + ***************************************************************************/ +#include "ColorMapEditor.h" +#include "DoubleSpinBox.h" + +#include <QPushButton> +#include <QTableWidget> +#include <QHeaderView> +#include <QCheckBox> +#include <QColorDialog> +#include <QLayout> +#include <QKeyEvent> +#include <QMouseEvent> +#include <QMessageBox> + +ColorMapEditor::ColorMapEditor(const QLocale& locale, int precision, QWidget* parent) + : QWidget(parent), + color_map(QwtLinearColorMap()), + min_val(0), + max_val(1), + d_locale(locale), + d_precision(precision) +{ +table = new QTableWidget(); +table->setColumnCount(2); +table->setSelectionMode(QAbstractItemView::SingleSelection); +table->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents); +table->verticalHeader()->hide(); +table->horizontalHeader()->setClickable( false ); +table->horizontalHeader()->setResizeMode(0, QHeaderView::Interactive); +table->horizontalHeader()->setResizeMode(1, QHeaderView::ResizeToContents); +table->horizontalHeader()->setStretchLastSection(true); +table->viewport()->setMouseTracking(true); +table->viewport()->installEventFilter(this); +table->setHorizontalHeaderLabels(QStringList() << tr("Level") << tr("Color")); +table->setMinimumHeight(6*table->horizontalHeader()->height() + 2); +table->installEventFilter(this); + +connect(table, SIGNAL(cellClicked (int, int)), this, SLOT(showColorDialog(int, int))); + +insertBtn = new QPushButton(tr("&Insert")); +insertBtn->setEnabled(false); +connect(insertBtn, SIGNAL(clicked()), this, SLOT(insertLevel())); + +deleteBtn = new QPushButton(tr("&Delete")); +deleteBtn->setEnabled(false); +connect(deleteBtn, SIGNAL(clicked()), this, SLOT(deleteLevel())); + +QHBoxLayout* hb = new QHBoxLayout(); +hb->addWidget(insertBtn); +hb->addWidget(deleteBtn); + +scaleColorsBox = new QCheckBox(tr("&Scale Colors")); +scaleColorsBox->setChecked(true); +connect(scaleColorsBox, SIGNAL(toggled(bool)), this, SLOT(setScaledColors(bool))); + +QVBoxLayout* vl = new QVBoxLayout(this); +vl->setSpacing(0); +vl->addWidget(table); +vl->addLayout(hb); +vl->addWidget(scaleColorsBox); + +setFocusProxy(table); +setMaximumWidth(200); +} + +void ColorMapEditor::updateColorMap() +{ + int rows = table->rowCount(); + QColor c_min = QColor(table->item(0, 1)->text()); + QColor c_max = QColor(table->item(rows - 1, 1)->text()); + QwtLinearColorMap map(c_min, c_max); + for (int i = 1; i < rows-1; i++){ + QwtDoubleInterval range = QwtDoubleInterval(min_val, max_val); + double val = (((DoubleSpinBox*)table->cellWidget(i, 0))->value() - min_val)/range.width(); + map.addColorStop (val, QColor(table->item(i, 1)->text())); + } + + color_map = map; + setScaledColors(scaleColorsBox->isChecked()); +} + +void ColorMapEditor::setColorMap(const QwtLinearColorMap& map) +{ + scaleColorsBox->setChecked(map.mode() == QwtLinearColorMap::ScaledColors); + + QwtArray <double> colors = map.colorStops(); + int rows = (int)colors.size(); + table->setRowCount(rows); + table->blockSignals(true); + + QwtDoubleInterval range = QwtDoubleInterval(min_val, max_val); + for (int i = 0; i < rows; i++){ + DoubleSpinBox *sb = new DoubleSpinBox(); + sb->setLocale(d_locale); + sb->setDecimals(d_precision); + sb->setValue(min_val + colors[i] * range.width()); + + if (i == 0) + sb->setRange(min_val, min_val); + else if (i == rows -1) + sb->setRange(max_val, max_val); + else + sb->setRange(min_val, max_val); + + connect(sb, SIGNAL(valueChanged(double)), this, SLOT(updateColorMap())); + connect(sb, SIGNAL(activated(DoubleSpinBox *)), this, SLOT(spinBoxActivated(DoubleSpinBox *))); + table->setCellWidget(i, 0, sb); + + QColor c = QColor(map.rgb(QwtDoubleInterval(0, 1), colors[i])); + QTableWidgetItem *it = new QTableWidgetItem(c.name()); + #ifdef Q_CC_MSVC + it->setFlags(it->flags() & (~Qt::ItemIsEditable)); + #else + it->setFlags(!Qt::ItemIsEditable); + #endif + it->setBackground(QBrush(c)); + it->setForeground(QBrush(c)); + table->setItem(i, 1, it); + } + table->blockSignals(false); + + color_map = map; +} + +void ColorMapEditor::setRange(double min, double max) +{ + min_val = QMIN(min, max); + max_val = QMAX(min, max); +} + +void ColorMapEditor::insertLevel() +{ + int row = table->currentRow(); + DoubleSpinBox *sb = (DoubleSpinBox*)table->cellWidget(row, 0); + if (!sb) + return; + + double current_value = sb->value(); + double previous_value = min_val; + sb = (DoubleSpinBox*)table->cellWidget(row - 1, 0); + if (sb) + previous_value = sb->value(); + + double val = 0.5*(current_value + previous_value); + QwtDoubleInterval range = QwtDoubleInterval(min_val, max_val); + double mapped_val = (val - min_val)/range.width(); + + QColor c = QColor(color_map.rgb(QwtDoubleInterval(0, 1), mapped_val)); + + table->blockSignals(true); + table->insertRow(row); + + sb = new DoubleSpinBox(); + sb->setLocale(d_locale); + sb->setDecimals(d_precision); + sb->setValue(val); + sb->setRange(min_val, max_val); + connect(sb, SIGNAL(valueChanged(double)), this, SLOT(updateColorMap())); + connect(sb, SIGNAL(activated(DoubleSpinBox *)), this, SLOT(spinBoxActivated(DoubleSpinBox *))); + table->setCellWidget(row, 0, sb); + + QTableWidgetItem *it = new QTableWidgetItem(c.name()); +#ifdef Q_CC_MSVC + it->setFlags(it->flags() & (~Qt::ItemIsEditable)); +#else + it->setFlags(!Qt::ItemIsEditable); +#endif + it->setBackground(QBrush(c)); + it->setForeground(QBrush(c)); + table->setItem(row, 1, it); + table->blockSignals(false); + + enableButtons(table->currentRow()); + updateColorMap(); +} + +void ColorMapEditor::deleteLevel() +{ + table->removeRow (table->currentRow()); + enableButtons(table->currentRow()); + updateColorMap(); +} + +void ColorMapEditor::showColorDialog(int row, int col) +{ + if (col != 1) + return; + + enableButtons(row); + + QColor c = QColor(table->item(row, 1)->text()); + QColor color = QColorDialog::getColor(c, this); + if (!color.isValid() || color == c) + return; + + table->item(row, 1)->setText(color.name()); + table->item(row, 1)->setForeground(QBrush(color)); + table->item(row, 1)->setBackground(QBrush(color)); + + updateColorMap(); +} + +bool ColorMapEditor::eventFilter(QObject *object, QEvent *e) +{ + if (e->type() == QEvent::MouseMove && object == table->viewport()){ + const QMouseEvent *me = (const QMouseEvent *)e; + QPoint pos = table->viewport()->mapToParent(me->pos()); + int row = table->rowAt(pos.y() - table->horizontalHeader()->height()); + if (table->columnAt(pos.x()) == 1 && row >= 0 && row < table->rowCount()) + setCursor(QCursor(Qt::PointingHandCursor)); + else + setCursor(QCursor(Qt::ArrowCursor)); + return true; + } else if (e->type() == QEvent::Leave && object == table->viewport()){ + setCursor(QCursor(Qt::ArrowCursor)); + return true; + } else if (e->type() == QEvent::KeyPress && object == table){ + QKeyEvent *ke = (QKeyEvent *)e; + if (ke->key() == Qt::Key_Return && table->currentColumn() == 1){ + showColorDialog(table->currentRow(), 1); + return true; + } + return false; + } + return QObject::eventFilter(object, e); +} + +void ColorMapEditor::enableButtons(int row) +{ + if (row < 0) + return; + + if (row == 0 || row == table->rowCount()-1) + deleteBtn->setEnabled(false); + else + deleteBtn->setEnabled(true); + + if (!row) + insertBtn->setEnabled(false); + else + insertBtn->setEnabled(true); +} + +void ColorMapEditor::setScaledColors(bool scale) +{ + if (scale) + color_map.setMode(QwtLinearColorMap::ScaledColors); + else + color_map.setMode(QwtLinearColorMap::FixedColors); + + scalingChanged(); +} + +QString ColorMapEditor::saveToXmlString(const QwtLinearColorMap& color_map) +{ + QString s = "<ColorMap>\n"; + s += "\t<Mode>" + QString::number(color_map.mode()) + "</Mode>\n"; + s += "\t<MinColor>" + color_map.color1().name() + "</MinColor>\n"; + s += "\t<MaxColor>" + color_map.color2().name() + "</MaxColor>\n"; + QwtArray <double> colors = color_map.colorStops(); + int stops = (int)colors.size(); + s += "\t<ColorStops>" + QString::number(stops - 2) + "</ColorStops>\n"; + for (int i = 1; i < stops - 1; i++) + { + s += "\t<Stop>" + QString::number(colors[i]) + "\t"; + s += QColor(color_map.rgb(QwtDoubleInterval(0,1), colors[i])).name(); + s += "</Stop>\n"; + } + return s += "</ColorMap>\n"; +} + +void ColorMapEditor::spinBoxActivated(DoubleSpinBox *sb) +{ + if (!sb) + return; + + int rows = table->rowCount(); + for (int i = 0; i < rows; i++){ + DoubleSpinBox *box = (DoubleSpinBox*)table->cellWidget(i, 0); + if (box && box == sb){ + table->setCurrentCell(i, 0); + enableButtons(i); + return; + } + } +} diff --git a/Code/Mantid/MantidPlot/src/lib/src/DoubleSpinBox.cpp b/Code/Mantid/MantidPlot/src/lib/src/DoubleSpinBox.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e1d5088dd05f09c34d2dfa5b14181458fc5ba0f1 --- /dev/null +++ b/Code/Mantid/MantidPlot/src/lib/src/DoubleSpinBox.cpp @@ -0,0 +1,204 @@ +/*************************************************************************** + File : DoubleSpinBox.cpp + Project : QtiPlot + -------------------------------------------------------------------- + Copyright : (C) 2007-2008 by Ion Vasilief + Email (use @ for *) : ion_vasilief*yahoo.fr + Description : A Double Spin Box + + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + ***************************************************************************/ +#include "DoubleSpinBox.h" +#include <MyParser.h> +#include <QLineEdit> +#include <QHBoxLayout> +#include <QCloseEvent> +#include <float.h> +#include <math.h> + +DoubleSpinBox::DoubleSpinBox(const char format, QWidget * parent) +:QAbstractSpinBox(parent), +d_format(format), +d_min_val(-DBL_MAX), +d_max_val(DBL_MAX), +d_value(0.0), +d_step(0.1), +d_prec(14) +{ + if (format == 'f') + d_prec = 1; + + setFocusPolicy(Qt::StrongFocus); + lineEdit()->setText(locale().toString(d_value, d_format, d_prec)); + setWrapping(false); + connect(this, SIGNAL(editingFinished()), this, SLOT(interpretText())); +} + +void DoubleSpinBox::setSingleStep(double val) +{ + if (d_step != val && val < d_max_val) + d_step = val; +} + +void DoubleSpinBox::setMaximum(double max) +{ + if (max == d_max_val || max > DBL_MAX) + return; + + d_max_val = max; +} + +void DoubleSpinBox::setMinimum(double min) +{ + if (min == d_min_val || min < -DBL_MAX) + return; + + d_min_val = min; +} + +void DoubleSpinBox::setRange(double min, double max) +{ + setMinimum(min); + setMaximum(max); +} + +void DoubleSpinBox::interpretText() +{ + bool ok = false; + QString s = text(); + double value = locale().toDouble(s, &ok); + if (ok && value == d_value) + return; + + if (!ok){ + MyParser parser; + parser.setLocale(QLocale()); + parser.addGSLConstants(); + try { + parser.SetExpr(s.toAscii().constData()); + value = parser.Eval(); + } catch (mu::ParserError &e){ + lineEdit()->setText(textFromValue(d_value)); + return; + } + } + + if (setValue(value)) + emit valueChanged(d_value); + else + lineEdit()->setText(textFromValue(d_value)); +} + +void DoubleSpinBox::stepBy ( int steps ) +{ + double val = d_value + steps*d_step; + if (fabs(fabs(d_value) - d_step) < 1e-14 && d_value * steps < 0)//possible zero + val = 0.0; + + if (setValue(val)) + emit valueChanged(d_value); +} + +QAbstractSpinBox::StepEnabled DoubleSpinBox::stepEnabled () const +{ + QAbstractSpinBox::StepEnabled stepDown = QAbstractSpinBox::StepNone; + if (d_value > d_min_val) + stepDown = StepDownEnabled; + + QAbstractSpinBox::StepEnabled stepUp = QAbstractSpinBox::StepNone; + if (d_value < d_max_val) + stepUp = StepUpEnabled; + + return stepDown | stepUp; +} + +bool DoubleSpinBox::setValue(double val) +{ + if (val >= d_min_val && val <= d_max_val){ + d_value = val; + lineEdit()->setText(textFromValue(d_value)); + return true; + } + + lineEdit()->setText(textFromValue(d_value)); + return false; +} + +QString DoubleSpinBox::textFromValue (double value) const +{ + if (!specialValueText().isEmpty() && value == d_min_val) + return specialValueText(); + + if (d_prec <= 14) + return locale().toString(value, d_format, d_prec); + + return locale().toString(value, d_format, 6); +} + +QValidator::State DoubleSpinBox::validate(QString & , int & ) const +{ + return QValidator::Acceptable; +} + +void DoubleSpinBox::focusInEvent(QFocusEvent * e) +{ + emit activated(this); + return QAbstractSpinBox::focusInEvent(e); +} + +/***************************************************************************** + * + * Class RangeLimitBox + * + *****************************************************************************/ + +RangeLimitBox::RangeLimitBox(LimitType type, QWidget * parent) +:QWidget(parent), +d_type(type) +{ + d_checkbox = new QCheckBox(); + d_spin_box = new DoubleSpinBox(); + d_spin_box->setSpecialValueText(" "); + d_spin_box->setValue(-DBL_MAX); + d_spin_box->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + d_spin_box->setEnabled(false); + + QHBoxLayout *l = new QHBoxLayout(this); + l->setMargin(0); + l->setSpacing(0); + l->addWidget(d_checkbox); + l->addWidget(d_spin_box); + + setFocusPolicy(Qt::StrongFocus); + setFocusProxy(d_spin_box); + connect(d_checkbox, SIGNAL(toggled(bool)), d_spin_box, SLOT(setEnabled(bool))); +} + +double RangeLimitBox::value() +{ + if (d_checkbox->isChecked()) + return d_spin_box->value(); + + double val = -DBL_MAX; + if (d_type == RightLimit) + return DBL_MAX; + return val; +} diff --git a/Code/Mantid/MantidPlot/src/lib/src/ExtensibleFileDialog.cpp b/Code/Mantid/MantidPlot/src/lib/src/ExtensibleFileDialog.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d66adb28ab49c066af2f6d32e5f47c226aee5a69 --- /dev/null +++ b/Code/Mantid/MantidPlot/src/lib/src/ExtensibleFileDialog.cpp @@ -0,0 +1,124 @@ +/*************************************************************************** + File : ExtensibleFileDialog.cpp + Project : QtiPlot + -------------------------------------------------------------------- + Copyright : (C) 2007 by Knut Franke + (C) 2007 - 2010 by Ion Vasilief + Email (use @ for *) : knut.franke*gmx.de, ion_vasilief*yahoo.fr + Description : QFileDialog plus generic extension support + + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + ***************************************************************************/ + +#include "ExtensibleFileDialog.h" +#include <QGridLayout> +#include <QDesktopServices> +#include <QUrl> +#include <QComboBox> + +ExtensibleFileDialog::ExtensibleFileDialog(QWidget *parent, bool extended, Qt::WFlags flags) + : QFileDialog(parent, flags) +{ + d_extension = 0; + + d_extension_toggle = new QPushButton(); + d_extension_toggle->setCheckable(true); + d_extension_toggle->hide(); // show only for d_extension != 0 + setExtended(extended); + + QGridLayout *main_layout = qobject_cast<QGridLayout*>(layout()); + if (main_layout) { + d_extension_row = main_layout->rowCount(); + main_layout->addWidget(d_extension_toggle, d_extension_row, main_layout->columnCount()-1); + main_layout->setRowStretch(d_extension_row, 0); + main_layout->setRowStretch(d_extension_row+1, 0); + } else { + // fallback in case QFileDialog uses a different layout in the future (=> main_layout==0) + // would probably look a mess, but at least all functions would be accessible + layout()->addWidget(d_extension_toggle); + } + + connect(this, SIGNAL(accepted()), this, SLOT(close())); + connect(this, SIGNAL(rejected()), this, SLOT(close())); +} + +void ExtensibleFileDialog::setExtensionWidget(QWidget *extension) +{ + if (d_extension == extension) + return; + if (d_extension) { + d_extension->hide(); + disconnect(d_extension_toggle, SIGNAL(toggled(bool))); + } + d_extension = extension; + if (!d_extension) { + d_extension_toggle->hide(); + return; + } + d_extension_toggle->show(); + + QGridLayout *main_layout = qobject_cast<QGridLayout*>(layout()); + if (main_layout) + main_layout->addWidget(d_extension, d_extension_row, 0, 2, main_layout->columnCount()-1); + else + layout()->addWidget(d_extension); + + d_extension->setVisible(d_extension_toggle->isChecked()); + connect(d_extension_toggle, SIGNAL(toggled(bool)), d_extension, SLOT(setVisible(bool))); + connect(d_extension_toggle, SIGNAL(toggled(bool)), this, SLOT(updateToggleButtonText(bool))); +} + +void ExtensibleFileDialog::setEditableFilter(bool on) +{ + QLayout *main_layout = layout(); + if (!main_layout) + return; + + for (int i = 0; i < main_layout->count(); i++){ + QLayoutItem *item = main_layout->itemAt(i); + if (!item) + continue; + QComboBox *filterBox = qobject_cast<QComboBox*>(item->widget()); + if (filterBox){ + filterBox->setEditable(on); + connect(filterBox, SIGNAL(editTextChanged(const QString &)), + this, SIGNAL(filterSelected(const QString &))); + return; + } + } +} + +void ExtensibleFileDialog::updateToggleButtonText(bool toggled) +{ + QString s = tr("&Advanced"); + if (toggled) + s += " >>"; + else + s = tr("<< &Advanced"); + d_extension_toggle->setText(s); +} + +void ExtensibleFileDialog::setExtended(bool extended) +{ + updateToggleButtonText(extended); + if (extended) + d_extension_toggle->toggle(); +} diff --git a/Code/Mantid/MantidPlot/src/lib/src/LineNumberDisplay.cpp b/Code/Mantid/MantidPlot/src/lib/src/LineNumberDisplay.cpp new file mode 100644 index 0000000000000000000000000000000000000000..efaeb28a6c986f5d75c59d5c0c75e3da6257f0fe --- /dev/null +++ b/Code/Mantid/MantidPlot/src/lib/src/LineNumberDisplay.cpp @@ -0,0 +1,123 @@ +/*************************************************************************** + File : LineNumberDisplay.cpp + Project : QtiPlot + -------------------------------------------------------------------- + Copyright : (C) 2008 by Ion Vasilief + Email (use @ for *) : ion_vasilief*yahoo.fr + Description : A widget displaying line numbers for a QTextEdit + + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + ***************************************************************************/ +#include "LineNumberDisplay.h" +#include <QScrollBar> +#include <QShowEvent> +#include <QPainter> + +LineNumberDisplay::LineNumberDisplay(QTextEdit *te, QWidget *parent) + : QTextEdit(parent), d_text_edit(te) +{ + setReadOnly(true); + setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + setFrameStyle(QFrame::Panel | QFrame::Raised); + setMaximumWidth(0); + setLineWidth(0); + setFocusPolicy(Qt::NoFocus); + setCurrentFont(te->currentFont()); + viewport()->setCursor(Qt::ArrowCursor); + + QPalette palette = this->palette(); + palette.setColor(QPalette::Highlight, palette.color(QPalette::Base)); + setPalette(palette); + + if (te){ + connect(this, SIGNAL(selectionChanged()), this, SLOT(updateDocumentSelection())); + + connect(te->document(), SIGNAL(contentsChanged()), this, SLOT(updateLineNumbers())); + connect((QObject *)te->verticalScrollBar(), SIGNAL(valueChanged(int)), + (QObject *)verticalScrollBar(), SLOT(setValue(int))); + connect(te, SIGNAL(currentCharFormatChanged (const QTextCharFormat &)), + this, SLOT(changeCharFormat (const QTextCharFormat &))); + } +} + +void LineNumberDisplay::updateDocumentSelection() +{ + if (!isVisible() || !d_text_edit) + return; + + QTextCursor c = textCursor(); +#if QT_VERSION >= 0x040500 + int selectionStart = document()->findBlock(c.selectionStart()).firstLineNumber(); + int selectionEnd = document()->findBlock(c.selectionEnd()).firstLineNumber(); +#else + int selectionStart = document()->findBlock(c.selectionStart()).blockNumber(); + int selectionEnd = document()->findBlock(c.selectionEnd()).blockNumber(); +#endif + int selectedLines = abs(selectionEnd - selectionStart); + + QTextCursor cursor(d_text_edit->textCursor()); + cursor.movePosition(QTextCursor::Start); + for (int i = 0; i < selectionStart; i++) + cursor.movePosition(QTextCursor::Down); + + for (int i = 0; i < selectedLines; i++) + cursor.movePosition(QTextCursor::Down, QTextCursor::KeepAnchor); + + cursor.movePosition(QTextCursor::EndOfLine, QTextCursor::KeepAnchor); + + if (selectionEnd == d_text_edit->document()->blockCount() - 1) + cursor.movePosition(QTextCursor::End, QTextCursor::KeepAnchor); + + d_text_edit->setTextCursor(cursor); +} + +void LineNumberDisplay::updateLineNumbers(bool force) +{ + if (!isVisible() || !d_text_edit) + return; + + int lines = d_text_edit->document()->blockCount(); + if (document()->blockCount() - 1 == lines && !force) + return; + + QString aux; + for(int i = 0; i < lines; i++) + aux += QString::number(i + 1) + "\n"; + + setPlainText(aux); + + QFontMetrics fm(d_text_edit->currentFont(), this); + setMaximumWidth(2*fm.boundingRect(QString::number(lines)).width()); + verticalScrollBar()->setValue(d_text_edit->verticalScrollBar()->value()); +} + +void LineNumberDisplay::showEvent(QShowEvent *e) +{ + e->accept(); + if (isVisible()) + updateLineNumbers(); +} + +void LineNumberDisplay::changeCharFormat (const QTextCharFormat &f) +{ + setCurrentFont(f.font()); +} diff --git a/Code/Mantid/MantidPlot/src/lib/src/PatternBox.cpp b/Code/Mantid/MantidPlot/src/lib/src/PatternBox.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8161e726175821f02586844d43dc94e37e90b7bf --- /dev/null +++ b/Code/Mantid/MantidPlot/src/lib/src/PatternBox.cpp @@ -0,0 +1,187 @@ +/*************************************************************************** + File : PatternBox.cpp + Project : QtiPlot + -------------------------------------------------------------------- + Copyright : (C) 2006 by Tomomasa Ohkubo, Ion Vasilief + Email (use @ for *) : ion_vasilief*yahoo.fr + Description : Pattern combox box + + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + ***************************************************************************/ +#include "PatternBox.h" + +#include <algorithm> +#include <qpixmap.h> +#include <qpainter.h> + +const Qt::BrushStyle PatternBox::patterns[] = { + Qt::SolidPattern, + Qt::HorPattern, + Qt::VerPattern, + Qt::CrossPattern, + Qt::BDiagPattern, + Qt::FDiagPattern, + Qt::DiagCrossPattern, + Qt::Dense1Pattern, + Qt::Dense2Pattern, + Qt::Dense3Pattern, + Qt::Dense4Pattern, + Qt::Dense5Pattern, + Qt::Dense6Pattern, + Qt::Dense7Pattern, + Qt::NoBrush +}; + +PatternBox::PatternBox(QWidget *parent) : QComboBox(parent) +{ + init(); +} + +void PatternBox::init() +{ + + QPixmap icon = QPixmap(28, 14); + icon.fill ( QColor (Qt::white) ); + const QRect r = QRect(0, 0, 27, 13); + QPainter p(&icon); + QBrush br = QBrush(QColor(Qt::darkGray), Qt::SolidPattern); + p.fillRect(r, br); + p.drawRect(r); + this->addItem(icon, tr( "Solid" ) ); + + br = QBrush(QColor(Qt::darkGray), Qt::HorPattern); + p.eraseRect(r); + p.fillRect(r, br); + p.drawRect(r); + this->addItem(icon, tr( "Horizontal" ) ); + + br = QBrush(QColor(Qt::darkGray), Qt::VerPattern); + p.eraseRect(r); + p.fillRect(r, br); + p.drawRect(r); + this->addItem(icon, tr( "Vertical" ) ); + + br = QBrush(QColor(Qt::darkGray), Qt::CrossPattern); + p.eraseRect(r); + p.fillRect(r, br); + p.drawRect(r); + this->addItem(icon, tr( "Cross" ) ); + + br = QBrush(QColor(Qt::darkGray), Qt::BDiagPattern); + p.eraseRect(r); + p.fillRect(r, br); + p.drawRect(r); + this->addItem(icon, tr( "BDiagonal" ) ); + + br = QBrush(QColor(Qt::darkGray), Qt::FDiagPattern); + p.eraseRect(r); + p.fillRect(r, br); + p.drawRect(r); + this->addItem(icon, tr( "FDiagonal" ) ); + + br = QBrush(QColor(Qt::darkGray), Qt::DiagCrossPattern); + p.eraseRect(r); + p.fillRect(r, br); + p.drawRect(r); + this->addItem(icon, tr( "DiagCross" ) ); + + br = QBrush(QColor(Qt::darkGray), Qt::Dense1Pattern); + p.eraseRect(r); + p.fillRect(r, br); + p.drawRect(r); + this->addItem(icon, tr( "Dense1" ) ); + + br = QBrush(QColor(Qt::darkGray), Qt::Dense2Pattern); + p.eraseRect(r); + p.fillRect(r, br); + p.drawRect(r); + this->addItem(icon, tr( "Dense2" ) ); + + br = QBrush(QColor(Qt::darkGray), Qt::Dense3Pattern); + p.eraseRect(r); + p.fillRect(r, br); + p.drawRect(r); + this->addItem(icon, tr( "Dense3" ) ); + + br = QBrush(QColor(Qt::darkGray), Qt::Dense4Pattern); + p.eraseRect(r); + p.fillRect(r, br); + p.drawRect(r); + this->addItem(icon, tr( "Dense4" ) ); + + br = QBrush(QColor(Qt::darkGray), Qt::Dense5Pattern); + p.eraseRect(r); + p.fillRect(r, br); + p.drawRect(r); + this->addItem(icon, tr( "Dense5" ) ); + + br = QBrush(QColor(Qt::darkGray), Qt::Dense6Pattern); + p.eraseRect(r); + p.fillRect(r, br); + p.drawRect(r); + this->addItem(icon, tr( "Dense6" ) ); + + br = QBrush(QColor(Qt::darkGray), Qt::Dense7Pattern); + p.eraseRect(r); + p.fillRect(r, br); + p.drawRect(r); + this->addItem(icon, tr( "Dense7" ) ); + + p.eraseRect(r); + p.drawRect(r); + this->addItem(icon, tr( "None" ) ); + p.end(); +} + +void PatternBox::setPattern(const Qt::BrushStyle& style) +{ + const Qt::BrushStyle*ite = std::find(patterns, patterns + sizeof(patterns), style); + if (ite == patterns + sizeof(patterns)) + this->setCurrentIndex(14); // default pattern is none. + else + this->setCurrentIndex(ite - patterns); +} + +Qt::BrushStyle PatternBox::brushStyle(int index) +{ + if (index < (int)sizeof(patterns)) + return patterns[index]; + else + return Qt::NoBrush; // default patterns is none. +} + +Qt::BrushStyle PatternBox::getSelectedPattern() const +{ + size_t i = this->currentIndex(); + if (i < sizeof(patterns)) + return patterns[i]; + else + return Qt::NoBrush; // default patterns is none. +} + +int PatternBox::patternIndex(const Qt::BrushStyle& style) +{ + const Qt::BrushStyle*ite = std::find(patterns, patterns + sizeof(patterns), style); + if (ite == patterns + sizeof(patterns)) + return 14; // default pattern is none. + else + return (ite - patterns); +} diff --git a/Code/Mantid/MantidPlot/src/lib/src/PenStyleBox.cpp b/Code/Mantid/MantidPlot/src/lib/src/PenStyleBox.cpp new file mode 100644 index 0000000000000000000000000000000000000000..db48675b3dc778b1c55550a5e3615881067cd90d --- /dev/null +++ b/Code/Mantid/MantidPlot/src/lib/src/PenStyleBox.cpp @@ -0,0 +1,84 @@ +/*************************************************************************** + File : PenStyleBox.cpp + Project : QtiPlot + -------------------------------------------------------------------- + Copyright : (C) 2008 Ion Vasilief + Email (use @ for *) : ion_vasilief*yahoo.fr + Description : Pen style combox box + + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + ***************************************************************************/ +#include "PenStyleBox.h" + +#include <algorithm> + +const Qt::PenStyle PenStyleBox::patterns[] = { + Qt::SolidLine, + Qt::DashLine, + Qt::DotLine, + Qt::DashDotLine, + Qt::DashDotDotLine +}; + +PenStyleBox::PenStyleBox(QWidget *parent) : QComboBox(parent) +{ + setEditable(false); + addItem("_____"); + addItem("_ _ _"); + addItem("....."); + addItem("_._._"); + addItem("_.._.."); +} + +void PenStyleBox::setStyle(const Qt::PenStyle& style) +{ + const Qt::PenStyle*ite = std::find(patterns, patterns + sizeof(patterns), style); + if (ite == patterns + sizeof(patterns)) + this->setCurrentIndex(0); // default style is solid. + else + this->setCurrentIndex(ite - patterns); +} + +Qt::PenStyle PenStyleBox::penStyle(int index) +{ + if (index < (int)sizeof(patterns)) + return patterns[index]; + else + return Qt::SolidLine; // default style is solid. +} + +Qt::PenStyle PenStyleBox::style() const +{ + size_t i = this->currentIndex(); + if (i < sizeof(patterns)) + return patterns[i]; + else + return Qt::SolidLine; // default style is solid. +} + +int PenStyleBox::styleIndex(const Qt::PenStyle& style) +{ + const Qt::PenStyle*ite = std::find(patterns, patterns + sizeof(patterns), style); + if (ite == patterns + sizeof(patterns)) + return 0; // default style is solid. + else + return (ite - patterns); +} diff --git a/Code/Mantid/MantidPlot/src/lib/src/SymbolBox.cpp b/Code/Mantid/MantidPlot/src/lib/src/SymbolBox.cpp new file mode 100644 index 0000000000000000000000000000000000000000..dcdf66317d1d525f2a64ef7b4478e9610e0f7498 --- /dev/null +++ b/Code/Mantid/MantidPlot/src/lib/src/SymbolBox.cpp @@ -0,0 +1,198 @@ +/*************************************************************************** + File : SymbolBox.cpp + Project : QtiPlot + -------------------------------------------------------------------- + Copyright : (C) 2006 by Ion Vasilief + Email (use @ for *) : ion_vasilief*yahoo.fr + Description : Plot symbol combo box + + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + ***************************************************************************/ +#include "SymbolBox.h" +#include <algorithm> + +#include <qpixmap.h> +#include <qpainter.h> + +const QwtSymbol::Style SymbolBox::symbols[] = { + QwtSymbol::NoSymbol, + QwtSymbol::Ellipse, + QwtSymbol::Rect, + QwtSymbol::Diamond, + QwtSymbol::Triangle, + QwtSymbol::DTriangle, + QwtSymbol::UTriangle, + QwtSymbol::LTriangle, + QwtSymbol::RTriangle, + QwtSymbol::Cross, + QwtSymbol::XCross, + QwtSymbol::HLine, + QwtSymbol::VLine, + QwtSymbol::Star1, + QwtSymbol::Star2, + QwtSymbol::Hexagon +}; + +SymbolBox::SymbolBox(bool showNoSymbol, QWidget *parent) : QComboBox(parent) +{ + init(showNoSymbol); +} + +void SymbolBox::init(bool showNoSymbol) +{ + QPixmap icon = QPixmap(15, 15); + QColor c = QColor (Qt::gray); + icon.fill(c); + const QRect r = QRect(1, 1, 14, 14); + QPainter p(&icon); + p.setRenderHint(QPainter::Antialiasing); + QwtSymbol symb; + p.setBrush(QBrush(QColor(Qt::white))); + + if (showNoSymbol) + this->addItem(tr("No Symbol" )); + + symb.setStyle (QwtSymbol::Ellipse); + symb.draw(&p, r); + this->addItem(icon, tr("Ellipse" )); + + symb.setStyle (QwtSymbol::Rect); + icon.fill(c); + symb.draw(&p, r.adjusted(0, 0, -1, -1)); + this->addItem(icon,tr("Rectangle")); + + symb.setStyle (QwtSymbol::Diamond); + icon.fill(c); + symb.draw(&p, r); + this->addItem(icon,tr("Diamond")); + + symb.setStyle (QwtSymbol::Triangle); + icon.fill(c); + symb.draw(&p, r); + this->addItem(icon,tr("Triangle")); + + symb.setStyle (QwtSymbol::DTriangle); + icon.fill(c); + symb.draw(&p, r); + this->addItem(icon,tr("Down Triangle")); + + symb.setStyle (QwtSymbol::UTriangle); + icon.fill(c); + symb.draw(&p, r); + this->addItem(icon,tr("Up Triangle")); + + symb.setStyle (QwtSymbol::LTriangle); + icon.fill(c); + symb.draw(&p, r); + this->addItem(icon,tr("Left Triangle")); + + symb.setStyle (QwtSymbol::RTriangle); + icon.fill(c); + symb.draw(&p, r); + this->addItem(icon,tr("Right Triangle")); + + symb.setStyle (QwtSymbol::Cross); + icon.fill(c); + symb.draw(&p, r); + this->addItem(icon,tr("Cross")); + + symb.setStyle (QwtSymbol::XCross); + icon.fill(c); + symb.draw(&p, r); + this->addItem(icon,tr("Diagonal Cross")); + + symb.setStyle (QwtSymbol::HLine); + icon.fill(c); + symb.draw(&p, r); + this->addItem(icon,tr("Horizontal Line")); + + symb.setStyle (QwtSymbol::VLine); + p.eraseRect ( r ); + symb.draw(&p, r); + this->addItem(icon,tr("Vertical Line")); + + symb.setStyle (QwtSymbol::Star1); + icon.fill(c); + symb.draw(&p, r); + this->addItem(icon,tr("Star 1")); + + symb.setStyle (QwtSymbol::Star2); + icon.fill(c); + symb.draw(&p, r); + this->addItem(icon,tr("Star 2")); + + symb.setStyle (QwtSymbol::Hexagon); + icon.fill(c); + symb.draw(&p, r); + this->addItem(icon,tr("Hexagon")); + + p.end(); +} + +void SymbolBox::setStyle(const QwtSymbol::Style& style) +{ + const QwtSymbol::Style*ite = std::find(symbols, symbols + sizeof(symbols), style); + if (ite == symbols + sizeof(symbols)) + this->setCurrentIndex(0); + else + this->setCurrentIndex(ite - symbols); +} + +QwtSymbol::Style SymbolBox::selectedSymbol() const +{ + size_t i = this->currentIndex(); + if (i < sizeof(symbols)) + return symbols[this->currentIndex()]; + + return QwtSymbol::NoSymbol; +} + +int SymbolBox::symbolIndex(const QwtSymbol::Style& style) +{ + const QwtSymbol::Style*ite = std::find(symbols, symbols + sizeof(symbols), style); + if (ite == symbols + sizeof(symbols)) + return 0; + + return (ite - symbols); +} + +QwtSymbol::Style SymbolBox::style(int index) +{ + if (index >= 0 && index < (int)sizeof(symbols)) + return symbols[index]; + + return QwtSymbol::NoSymbol; +} + +QList<int> SymbolBox::defaultSymbols() +{ + QList<int> lst; + for (int i = 0; i < QwtSymbol::StyleCnt; i++) + lst << i; + + return lst; +} + +void SymbolBox::focusInEvent(QFocusEvent * e) +{ + emit activated(this); + return QComboBox::focusInEvent(e); +} diff --git a/Code/Mantid/MantidPlot/src/lib/src/SymbolDialog.cpp b/Code/Mantid/MantidPlot/src/lib/src/SymbolDialog.cpp new file mode 100644 index 0000000000000000000000000000000000000000..71b2953f79e86f3ed9b0922bd614c4193360feb4 --- /dev/null +++ b/Code/Mantid/MantidPlot/src/lib/src/SymbolDialog.cpp @@ -0,0 +1,694 @@ +/*************************************************************************** + File : SymbolDialog.cpp + Project : QtiPlot + -------------------------------------------------------------------- + Copyright : (C) 2004 - 2010 by Ion Vasilief, + (C) 2006 - June 2007 by Tilman Hoener zu Siederdissen + Email (use @ for *) : ion_vasilief*yahoo.fr, thzs*gmx.net + Description : Tool window to select special text characters + + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + ***************************************************************************/ +#include "SymbolDialog.h" +#include <QPushButton> +#include <QSizePolicy> +#include <QGroupBox> +#include <QShortcut> +#include <QHBoxLayout> +#include <QButtonGroup> +#include <QTextCodec> +#include <QFontDatabase> + +SymbolDialog::SymbolDialog(CharSet charSet, QWidget* parent, Qt::WFlags fl ) +: QDialog( parent, fl ) +{ + setAttribute(Qt::WA_DeleteOnClose); + setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ); + setSizeGripEnabled( false ); + + buttons = new QButtonGroup(this); + mainLayout = new QVBoxLayout(this); + gridLayout = new QGridLayout(); + + switch(charSet){ + case lowerGreek: + initLowerGreekChars(); + break; + case upperGreek: + initUpperGreekChars(); + break; + case mathSymbols: + initMathSymbols(); + break; + case arrowSymbols: + initArrowSymbols(); + break; + case numberSymbols: + initNumberSymbols(); + break; + case latexArrowSymbols: + initLatexArrowSymbols(); + break; + case latexMathSymbols: + initLatexMathSymbols(); + break; + } + + closeButton = new QPushButton(tr("&Close"), this); + + mainLayout->addLayout( gridLayout ); + mainLayout->addStretch(); + mainLayout->addWidget( closeButton ); + + languageChange(); + + connect(buttons, SIGNAL(buttonClicked(int)), this, SLOT(getChar(int))); + connect(closeButton, SIGNAL(clicked()), this, SLOT(close())); + QShortcut *shortcut = new QShortcut(Qt::Key_Return, this); + connect( shortcut , SIGNAL(activated()), this, SLOT(addCurrentChar()) ); +} + +void SymbolDialog::initLowerGreekChars() +{ + int counter = 0; + for (int i=0 ; i <= (0x3C9-0x3B1) ; i++,counter++ ){ + QPushButton *btn = new QPushButton(QString(QChar(i+0x3B1))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/5,counter%5); + } +} + +void SymbolDialog::initUpperGreekChars() +{ + int i, counter = 0; + for ( i=0; i <= (0x394-0x393); i++,counter++ ){ + QPushButton *btn = new QPushButton(QString(QChar(i+0x393))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn, counter + 1); + gridLayout->addWidget(btn, counter/5,counter%5); + } + + for ( i=0; i <= (0x3A0-0x398); i+=3,counter++ ){ + QPushButton *btn = new QPushButton(QString(QChar(i+0x398))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn, counter + 1); + gridLayout->addWidget(btn, counter/5,counter%5); + } + + for ( i=0; i <= (0x3A6-0x3A0); i+=3,counter++ ){ + QPushButton *btn = new QPushButton(QString(QChar(i+0x3A0))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn, counter + 1); + gridLayout->addWidget(btn, counter/5,counter%5); + } + + + for ( i=0 ; i <= (0x3A9-0x3A8) ; i++,counter++ ){ + QPushButton *btn = new QPushButton(QString(QChar(i+0x3A8))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/5,counter%5); + } + + numButtons = counter; +} + +void SymbolDialog::initNumberSymbols() +{ + int i, counter = 0; + for ( i=0 ; i <= (0x216B-0x2153) ; i++,counter++ ){ + QPushButton *btn = new QPushButton(QString(QChar(i+0x2153))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/8,counter%8); + } + for ( i=0 ; i <= (0x217B-0x2170) ; i++,counter++ ){ + QPushButton *btn = new QPushButton(QString(QChar(i+0x2170))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/8,counter%8); + } + numButtons = counter; +} + +void SymbolDialog::initMathSymbols() +{ + int i, counter = 0; + for ( i=0 ; i <= (0x220D-0x2200) ; i++,counter++ ){ + QPushButton *btn = new QPushButton(QString(QChar(i+0x2200))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/8,counter%8); + } + for ( i=0 ; i <= (0x2211-0x220F) ; i++,counter++ ){ + QPushButton *btn = new QPushButton(QString(QChar(i+0x220F))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/8,counter%8); + } + for ( i=0 ; i <= (0x00B1-0x00B1) ; i++,counter++ ){ + QPushButton *btn = new QPushButton(QString(QChar(i+0x00B1))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/8,counter%8); + } + for ( i=0 ; i <= (0x2213-0x2213) ; i++,counter++ ) + { + QPushButton *btn = new QPushButton(QString(QChar(i+0x2213))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/8,counter%8); + } + // MULTIPLICATION SIGN + for ( i=0; i <= (0x00D7-0x00D7) ; i++,counter++ ){ + QPushButton *btn = new QPushButton(QString(QChar(i+0x00D7))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/8,counter%8); + } + + for ( i=0 ; i <= (0x221E - 0x2217) ; i++,counter++ ) + { + QPushButton *btn = new QPushButton(QString(QChar(i+0x2217))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/8,counter%8); + } + for ( i=0 ; i <= (0x2222-0x2222) ; i++,counter++ ) + { + QPushButton *btn = new QPushButton(QString(QChar(i+0x2222))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/8,counter%8); + } + for ( i=0 ; i <= (0x2230-0x2227) ; i++,counter++ ) + { + QPushButton *btn = new QPushButton(QString(QChar(i+0x2227))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/8,counter%8); + } + for ( i=0 ; i <= (0x223F-0x223F) ; i++,counter++ ) + { + QPushButton *btn = new QPushButton(QString(QChar(i+0x223F))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/8,counter%8); + } + + for ( i=0 ; i <= (0x2245-0x2245) ; i++,counter++ ) + { + QPushButton *btn = new QPushButton(QString(QChar(i+0x2245))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/8,counter%8); + } + for ( i=0 ; i <= (0x2248-0x2248) ; i++,counter++ ) + { + QPushButton *btn = new QPushButton(QString(QChar(i+0x2248))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/8,counter%8); + } + for ( i=0 ; i <= (0x2259-0x2259) ; i++,counter++ ) + { + QPushButton *btn = new QPushButton(QString(QChar(i+0x2259))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/8,counter%8); + } + + for ( i=0 ; i <= (0x2255-0x2254) ; i++,counter++ ) + { + QPushButton *btn = new QPushButton(QString(QChar(i+0x2254))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/8,counter%8); + } + + for ( i=0 ; i <= (0x2267-0x225F) ; i++,counter++ ) + { + QPushButton *btn = new QPushButton(QString(QChar(i+0x225F))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/8,counter%8); + } + + // < SIGN + for ( i=0; i < 1 ; i++,counter++ ){ + QPushButton *btn = new QPushButton(QString("<")); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/8,counter%8); + } + + for ( i=0 ; i <= (0x226B-0x226A) ; i++,counter++ ) + { + QPushButton *btn = new QPushButton(QString(QChar(i+0x226A))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/8,counter%8); + } + + for ( i=0 ; i <= (0x2289-0x2282) ; i++,counter++ ) + { + QPushButton *btn = new QPushButton(QString(QChar(i+0x2282))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/8,counter%8); + } + + // h bar + for ( i=0 ; i <= (0x210F-0x210F) ; i++,counter++ ) + { + QPushButton *btn = new QPushButton(QString(QChar(i+0x210F))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/8,counter%8); + } + + // angstrom + for ( i=0 ; i <= (0x212B-0x212B) ; i++,counter++ ) + { + QPushButton *btn = new QPushButton(QString(QChar(i+0x212B))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/8,counter%8); + } + // per mille and per ten thousand (thanks to Knut Franke) + for ( i=0; i <= (0x2031-0x2030) ; i++,counter++ ){ + QPushButton *btn = new QPushButton(QString(QChar(i+0x2030))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/8,counter%8); + } + numButtons = counter; +} + +void SymbolDialog::initLatexMathSymbols() +{ + int i, counter = 0; + for ( i=0 ; i <= (0x2200-0x2200) ; i++,counter++ ){ + QPushButton *btn = new QPushButton(QString(QChar(i+0x2200))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/7,counter%7); + } + for ( i=0 ; i <= (0x2209-0x2202) ; i++,counter++ ){ + QPushButton *btn = new QPushButton(QString(QChar(i+0x2202))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/7,counter%7); + } + for ( i=0 ; i <= (0x220C-0x220B) ; i++,counter++ ){ + QPushButton *btn = new QPushButton(QString(QChar(i+0x220B))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/7,counter%7); + } + for ( i=0 ; i <= (0x2211-0x220F) ; i++,counter++ ){ + QPushButton *btn = new QPushButton(QString(QChar(i+0x220F))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/7,counter%7); + } + for ( i=0 ; i <= (0x00B1-0x00B1) ; i++,counter++ ){ + QPushButton *btn = new QPushButton(QString(QChar(i+0x00B1))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/7,counter%7); + } + for ( i=0 ; i <= (0x2213-0x2213) ; i++,counter++ ) + { + QPushButton *btn = new QPushButton(QString(QChar(i+0x2213))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/7,counter%7); + } + // MULTIPLICATION SIGN + for ( i=0; i <= (0x00D7-0x00D7) ; i++,counter++ ){ + QPushButton *btn = new QPushButton(QString(QChar(i+0x00D7))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/7,counter%7); + } + + for ( i=0 ; i <= (0x221E - 0x2217) ; i++,counter++ ) + { + QPushButton *btn = new QPushButton(QString(QChar(i+0x2217))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/7,counter%7); + } + for ( i=0 ; i < (0x222F-0x2227) ; i++,counter++ ) + { + QPushButton *btn = new QPushButton(QString(QChar(i+0x2227))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/7,counter%7); + } + for ( i=0 ; i <= (0x223F-0x223F) ; i++,counter++ ) + { + QPushButton *btn = new QPushButton(QString(QChar(i+0x223F))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/7,counter%7); + } + for ( i=0 ; i <= (0x2245-0x2245) ; i++,counter++ ) + { + QPushButton *btn = new QPushButton(QString(QChar(i+0x2245))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/7,counter%7); + } + for ( i=0 ; i <= (0x2248-0x2248) ; i++,counter++ ) + { + QPushButton *btn = new QPushButton(QString(QChar(i+0x2248))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/7,counter%7); + } + for ( i=0 ; i <= (0x2265-0x2260) ; i++,counter++ ) + { + QPushButton *btn = new QPushButton(QString(QChar(i+0x2260))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/7,counter%7); + } + for ( i=0 ; i <= (0x226B-0x226A) ; i++,counter++ ) + { + QPushButton *btn = new QPushButton(QString(QChar(i+0x226A))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/7,counter%7); + } + for ( i=0 ; i <= (0x2289-0x2282) ; i++,counter++ ) + { + QPushButton *btn = new QPushButton(QString(QChar(i+0x2282))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/7,counter%7); + } + + // h bar + for ( i=0 ; i <= (0x210F-0x210F) ; i++,counter++ ) + { + QPushButton *btn = new QPushButton(QString(QChar(i+0x210F))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/7,counter%7); + } + + // angstrom + for ( i=0 ; i <= (0x212B-0x212B) ; i++,counter++ ) + { + QPushButton *btn = new QPushButton(QString(QChar(i+0x212B))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/7,counter%7); + } + numButtons = counter; + + QFont font = this->font(); + QStringList families = QFontDatabase().families(); + foreach(QString f, families){ + if (f.contains("Unicode")){ + font.setFamily(f); + + for(int i = 0; i < numButtons; i++){ + QWidget *w = gridLayout->itemAt(i)->widget(); + if (w) + w->setFont(font); + } + break; + } + } +} + +void SymbolDialog::initArrowSymbols() +{ + int i, counter = 0; + for ( i=0 ; i <= (0x219B-0x2190) ; i++,counter++ ) + { + QPushButton *btn = new QPushButton(QString(QChar(i+0x2190))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/6,counter%6); + } + for ( i=0 ; i <= (0x21A7-0x21A4) ; i++,counter++ ) + { + QPushButton *btn = new QPushButton(QString(QChar(i+0x21A4))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/6,counter%6); + } + for ( i=0 ; i <= (0x21D5-0x21CD) ; i++,counter++ ) + { + QPushButton *btn = new QPushButton(QString(QChar(i+0x21CD))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/6,counter%6); + } + for ( i=0 ; i <= (0x21E9-0x21E6) ; i++,counter++ ) + { + QPushButton *btn = new QPushButton(QString(QChar(i+0x21E6))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/6,counter%6); + } + numButtons = counter; +} + +void SymbolDialog::initLatexArrowSymbols() +{ + QFont font = this->font(); + QStringList families = QFontDatabase().families(); + foreach(QString f, families){ + if (f.contains("Unicode")){ + font.setFamily(f); + break; + } + } + + int i, counter = 0; + for ( i=0 ; i <= (0x2199-0x2190) ; i++,counter++ ) + { + QPushButton *btn = new QPushButton(QString(QChar(i+0x2190))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setFont(font); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/6,counter%6); + } + + for ( i=0 ; i <= (0x21AA-0x21A9) ; i++,counter++ ) + { + QPushButton *btn = new QPushButton(QString(QChar(i+0x21A9))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setFont(font); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/6,counter%6); + } + + for ( i=0 ; i <= (0x21D5-0x21D0) ; i++,counter++ ) + { + QPushButton *btn = new QPushButton(QString(QChar(i+0x21D0))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setFont(font); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/6,counter%6); + } + + for ( i=0 ; i <= (0x21BD-0x21BC) ; i++,counter++ ) + { + QPushButton *btn = new QPushButton(QString(QChar(i+0x21BC))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setFont(font); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/6,counter%6); + } + + for ( i=0 ; i <= (0x21C1-0x21C0) ; i++,counter++ ) + { + QPushButton *btn = new QPushButton(QString(QChar(i+0x21C0))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setFont(font); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/6,counter%6); + } + + QPushButton *btn = new QPushButton(QString(QChar(0x21CC))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setFont(font); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/6,counter%6); + + counter++; + + btn = new QPushButton(QString(QChar(0x21A6))); + btn->setMaximumWidth(40); + btn->setFlat ( true ); + btn->setFont(font); + btn->setAutoDefault (false); + buttons->addButton(btn,counter+1); + gridLayout->addWidget(btn,counter/6,counter%6); + + numButtons = counter; +} + +void SymbolDialog::addCurrentChar() +{ + for (int i=1; i < numButtons; i++) + { + QPushButton *btn = (QPushButton *) buttons->button(i); + if (btn && btn->hasFocus()) + emit addLetter(btn->text()); + } +} + +void SymbolDialog::getChar(int btnIndex) +{ + QPushButton * btn = (QPushButton *)buttons->button( btnIndex ); + if(btn) + emit addLetter(btn->text().replace("<", "<")); +} + + +void SymbolDialog::languageChange() +{ + setWindowTitle( tr( "QtiPlot - Choose Symbol" ) ); +} + + +void SymbolDialog::focusInEvent( QFocusEvent * event ) +{ + Q_UNUSED(event) + // select the first button as default (in case [return] is pressed) + ((QPushButton *)buttons->button(1))->setFocus(Qt::TabFocusReason); +} diff --git a/Code/Mantid/MantidPlot/src/lib/src/TextFormatButtons.cpp b/Code/Mantid/MantidPlot/src/lib/src/TextFormatButtons.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e606474ad86328e1f2c319e6ba63e9bef89011d1 --- /dev/null +++ b/Code/Mantid/MantidPlot/src/lib/src/TextFormatButtons.cpp @@ -0,0 +1,554 @@ +/*************************************************************************** + File : TextFormatButtons.cpp + Project : QtiPlot + -------------------------------------------------------------------- + Copyright : (C) 2006 by Ion Vasilief, Tilman Hoener zu Siederdissen + Email (use @ for *) : ion_vasilief*yahoo.fr, thzs*gmx.net + Description : Widget with text format buttons (connected to a QTextEdit) + + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software * + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * + * Boston, MA 02110-1301 USA * + * * + ***************************************************************************/ + +#include "TextFormatButtons.h" +#include "SymbolDialog.h" +#include <QTextEdit> +#include <QPushButton> +#include <QHBoxLayout> +#include <QString> + +TextFormatButtons::TextFormatButtons(QTextEdit * textEdit, Buttons buttons, QWidget * parent) +: QWidget(parent), +connectedTextEdit(textEdit), +d_buttons(buttons) +{ + QHBoxLayout * layout = new QHBoxLayout(this); + layout->setMargin(0); + layout->setSpacing(0); + + init(buttons); +} + +void TextFormatButtons::init(Buttons buttons) +{ + QHBoxLayout *layout = (QHBoxLayout*)this->layout(); + QLayoutItem *child; + while ((child = layout->takeAt(0)) != 0){ + if (child->widget()) + delete child->widget(); + } + + QFont font = QFont(); + int btnSize = 32; +#ifdef Q_OS_MAC + btnSize = 38; +#endif + if (buttons == Legend || buttons == TexLegend){ + QPushButton *buttonCurve = new QPushButton( QPixmap(":/lineSymbol.png"), QString()); + buttonCurve->setFixedWidth(btnSize); + buttonCurve->setFixedHeight(btnSize); + buttonCurve->setFont(font); + layout->addWidget(buttonCurve); + connect( buttonCurve, SIGNAL(clicked()), this, SLOT(addCurve()) ); + } + + QPushButton *buttonSubscript = new QPushButton(QPixmap(":/index.png"), QString()); + buttonSubscript->setFixedWidth(btnSize); + buttonSubscript->setFixedHeight(btnSize); + buttonSubscript->setFont(font); + layout->addWidget(buttonSubscript); + connect( buttonSubscript, SIGNAL(clicked()), this, SLOT(addSubscript()) ); + + QPushButton *buttonSuperscript = new QPushButton(QPixmap(":/exp.png"), QString()); + buttonSuperscript->setFixedWidth(btnSize); + buttonSuperscript->setFixedHeight(btnSize); + buttonSuperscript->setFont(font); + layout->addWidget(buttonSuperscript); + connect( buttonSuperscript, SIGNAL(clicked()), this, SLOT(addSuperscript())); + + if (buttons == Equation || buttons == TexLegend){ + QPushButton *buttonFraction = new QPushButton(QPixmap(":/fraction.png"), QString()); + buttonFraction->setFixedWidth(btnSize); + buttonFraction->setFixedHeight(btnSize); + buttonFraction->setFont(font); + layout->addWidget(buttonFraction); + connect(buttonFraction, SIGNAL(clicked()), this, SLOT(addFraction())); + + QPushButton *buttonSquareRoot = new QPushButton(QPixmap(":/square_root.png"), QString()); + buttonSquareRoot->setFixedWidth(btnSize); + buttonSquareRoot->setFixedHeight(btnSize); + buttonSquareRoot->setFont(font); + layout->addWidget(buttonSquareRoot); + connect(buttonSquareRoot, SIGNAL(clicked()), this, SLOT(addSquareRoot())); + } + + QPushButton *buttonLowerGreek = new QPushButton(QString(QChar(0x3B1))); + buttonLowerGreek->setFont(font); + buttonLowerGreek->setFixedWidth(btnSize); + buttonLowerGreek->setFixedHeight(btnSize); + layout->addWidget(buttonLowerGreek); + connect( buttonLowerGreek, SIGNAL(clicked()), this, SLOT(showLowerGreek())); + + QPushButton *buttonUpperGreek = new QPushButton(QString(QChar(0x393))); + buttonUpperGreek->setFont(font); + buttonUpperGreek->setFixedWidth(btnSize); + buttonUpperGreek->setFixedHeight(btnSize); + layout->addWidget(buttonUpperGreek); + connect( buttonUpperGreek, SIGNAL(clicked()), this, SLOT(showUpperGreek())); + + QPushButton *buttonArrowSymbols = new QPushButton(QString(QChar(0x2192))); + buttonArrowSymbols->setFont(font); + buttonArrowSymbols->setFixedWidth(btnSize); + buttonArrowSymbols->setFixedHeight(btnSize); + layout->addWidget(buttonArrowSymbols); + connect( buttonArrowSymbols, SIGNAL(clicked()), this, SLOT(showArrowSymbols())); + + QPushButton *buttonMathSymbols = new QPushButton(QString(QChar(0x222B))); + buttonMathSymbols->setFont(font); + buttonMathSymbols->setFixedWidth(btnSize); + buttonMathSymbols->setFixedHeight(btnSize); + layout->addWidget(buttonMathSymbols); + connect( buttonMathSymbols, SIGNAL(clicked()), this, SLOT(showMathSymbols())); + + if (buttons != Plot3D && buttons != Equation && buttons != TexLegend){ + font = this->font(); + font.setBold(true); + + QPushButton *buttonBold = new QPushButton(tr("B","Button bold")); + buttonBold->setFont(font); + buttonBold->setFixedWidth(btnSize); + buttonBold->setFixedHeight(btnSize); + layout->addWidget(buttonBold); + connect( buttonBold, SIGNAL(clicked()), this, SLOT(addBold())); + + font = this->font(); + font.setItalic(true); + + QPushButton *buttonItalics = new QPushButton(tr("It","Button italics")); + buttonItalics->setFont(font); + buttonItalics->setFixedWidth(btnSize); + buttonItalics->setFixedHeight(btnSize); + layout->addWidget(buttonItalics); + connect( buttonItalics, SIGNAL(clicked()), this, SLOT(addItalics())); + + font = this->font(); + font.setUnderline(true); + + QPushButton *buttonUnderline = new QPushButton(tr("U","Button underline")); + buttonUnderline->setFont(font); + buttonUnderline->setFixedWidth(btnSize); + buttonUnderline->setFixedHeight(btnSize); + layout->addWidget(buttonUnderline); + layout->addStretch(); + connect( buttonUnderline, SIGNAL(clicked()), this, SLOT(addUnderline())); + } else + layout->addStretch(); +} + +void TextFormatButtons::showLowerGreek() +{ + SymbolDialog *greekLetters = new SymbolDialog(SymbolDialog::lowerGreek, this, Qt::Tool|Qt::WindowStaysOnTopHint); + greekLetters->setAttribute(Qt::WA_DeleteOnClose); + QFont f = connectedTextEdit->font(); + f.setPointSize(12); + greekLetters->setFont(f); + connect(greekLetters, SIGNAL(addLetter(const QString&)), this, SLOT(addSymbol(const QString&))); + greekLetters->show(); + greekLetters->setFocus(); +} + +void TextFormatButtons::showUpperGreek() +{ + SymbolDialog *greekLetters = new SymbolDialog(SymbolDialog::upperGreek, this, Qt::Tool|Qt::WindowStaysOnTopHint); + greekLetters->setAttribute(Qt::WA_DeleteOnClose); + QFont f = connectedTextEdit->font(); + f.setPointSize(12); + greekLetters->setFont(f); + connect(greekLetters, SIGNAL(addLetter(const QString&)), this, SLOT(addSymbol(const QString&))); + greekLetters->show(); + greekLetters->setFocus(); +} + +void TextFormatButtons::showMathSymbols() +{ + SymbolDialog::CharSet charSet = SymbolDialog::mathSymbols; + if (d_buttons == Equation || d_buttons == TexLegend) + charSet = SymbolDialog::latexMathSymbols; + + SymbolDialog *mathSymbols = new SymbolDialog(charSet, this, Qt::Tool|Qt::WindowStaysOnTopHint); + mathSymbols->setAttribute(Qt::WA_DeleteOnClose); + QFont f = connectedTextEdit->font(); + f.setPointSize(12); + mathSymbols->setFont(f); + connect(mathSymbols, SIGNAL(addLetter(const QString&)), this, SLOT(addSymbol(const QString&))); + mathSymbols->show(); + mathSymbols->setFocus(); +} + +void TextFormatButtons::showArrowSymbols() +{ + SymbolDialog::CharSet charSet = SymbolDialog::arrowSymbols; + if (d_buttons == Equation || d_buttons == TexLegend) + charSet = SymbolDialog::latexArrowSymbols; + + SymbolDialog *arrowSymbols = new SymbolDialog(charSet, this, Qt::Tool|Qt::WindowStaysOnTopHint); + arrowSymbols->setAttribute(Qt::WA_DeleteOnClose); + arrowSymbols->setFont(connectedTextEdit->font()); + QFont f = connectedTextEdit->font(); + f.setPointSize(12); + arrowSymbols->setFont(f); + connect(arrowSymbols, SIGNAL(addLetter(const QString&)), this, SLOT(addSymbol(const QString&))); + arrowSymbols->show(); + arrowSymbols->setFocus(); +} + +void TextFormatButtons::addSymbol(const QString & letter) +{ + if (d_buttons == Equation || d_buttons == TexLegend){ + int s = 0x3B1; + if (letter == QString(QChar(s))) + connectedTextEdit->textCursor().insertText("\\alpha"); + else if (letter == QString(QChar(1 + s))) + connectedTextEdit->textCursor().insertText("\\beta"); + else if (letter == QString(QChar(2 + s))) + connectedTextEdit->textCursor().insertText("\\gamma"); + else if (letter == QString(QChar(3 + s))) + connectedTextEdit->textCursor().insertText("\\delta"); + else if (letter == QString(QChar(4 + s))) + connectedTextEdit->textCursor().insertText("\\epsilon"); + else if (letter == QString(QChar(5 + s))) + connectedTextEdit->textCursor().insertText("\\zeta"); + else if (letter == QString(QChar(6 + s))) + connectedTextEdit->textCursor().insertText("\\eta"); + else if (letter == QString(QChar(7 + s))) + connectedTextEdit->textCursor().insertText("\\theta"); + else if (letter == QString(QChar(8 + s))) + connectedTextEdit->textCursor().insertText("\\iota"); + else if (letter == QString(QChar(9 + s))) + connectedTextEdit->textCursor().insertText("\\kappa"); + else if (letter == QString(QChar(10 + s))) + connectedTextEdit->textCursor().insertText("\\lambda"); + else if (letter == QString(QChar(11 + s))) + connectedTextEdit->textCursor().insertText("\\mu"); + else if (letter == QString(QChar(12 + s))) + connectedTextEdit->textCursor().insertText("\\nu"); + else if (letter == QString(QChar(13 + s))) + connectedTextEdit->textCursor().insertText("\\xi"); + else if (letter == QString(QChar(14 + s))) + connectedTextEdit->textCursor().insertText("\\\\o"); + else if (letter == QString(QChar(15 + s))) + connectedTextEdit->textCursor().insertText("\\pi"); + else if (letter == QString(QChar(16 + s))) + connectedTextEdit->textCursor().insertText("\\rho"); + else if (letter == QString(QChar(17 + s))) + connectedTextEdit->textCursor().insertText("\\varsigma"); + else if (letter == QString(QChar(18 + s))) + connectedTextEdit->textCursor().insertText("\\sigma"); + else if (letter == QString(QChar(19 + s))) + connectedTextEdit->textCursor().insertText("\\tau"); + else if (letter == QString(QChar(20 + s))) + connectedTextEdit->textCursor().insertText("\\upsilon"); + else if (letter == QString(QChar(21 + s))) + connectedTextEdit->textCursor().insertText("\\varphi"); + else if (letter == QString(QChar(22 + s))) + connectedTextEdit->textCursor().insertText("\\chi"); + else if (letter == QString(QChar(23 + s))) + connectedTextEdit->textCursor().insertText("\\psi"); + else if (letter == QString(QChar(24 + s))) + connectedTextEdit->textCursor().insertText("\\omega"); + + s = 0x393; + if (letter == QString(QChar(s))) + connectedTextEdit->textCursor().insertText("\\Gamma"); + else if (letter == QString(QChar(1 + s))) + connectedTextEdit->textCursor().insertText("\\Delta"); + else if (letter == QString(QChar(5 + s))) + connectedTextEdit->textCursor().insertText("\\Theta"); + else if (letter == QString(QChar(8 + s))) + connectedTextEdit->textCursor().insertText("\\Lambda"); + else if (letter == QString(QChar(11 + s))) + connectedTextEdit->textCursor().insertText("\\Xi"); + else if (letter == QString(QChar(13 + s))) + connectedTextEdit->textCursor().insertText("\\Pi"); + else if (letter == QString(QChar(16 + s))) + connectedTextEdit->textCursor().insertText("\\Sigma"); + else if (letter == QString(QChar(19 + s))) + connectedTextEdit->textCursor().insertText("\\Phi"); + else if (letter == QString(QChar(21 + s))) + connectedTextEdit->textCursor().insertText("\\Psi"); + else if (letter == QString(QChar(22 + s))) + connectedTextEdit->textCursor().insertText("\\Omega"); + + s = 0x2190; + if (letter == QString(QChar(s))) + connectedTextEdit->textCursor().insertText("\\leftarrow"); + else if (letter == QString(QChar(1 + s))) + connectedTextEdit->textCursor().insertText("\\uparrow"); + else if (letter == QString(QChar(2 + s))) + connectedTextEdit->textCursor().insertText("\\rightarrow"); + else if (letter == QString(QChar(3 + s))) + connectedTextEdit->textCursor().insertText("\\downarrow"); + else if (letter == QString(QChar(4 + s))) + connectedTextEdit->textCursor().insertText("\\leftrightarrow"); + else if (letter == QString(QChar(5 + s))) + connectedTextEdit->textCursor().insertText("\\updownarrow"); + else if (letter == QString(QChar(6 + s))) + connectedTextEdit->textCursor().insertText("\\nwarrow"); + else if (letter == QString(QChar(7 + s))) + connectedTextEdit->textCursor().insertText("\\nearrow"); + else if (letter == QString(QChar(8 + s))) + connectedTextEdit->textCursor().insertText("\\searrow"); + else if (letter == QString(QChar(9 + s))) + connectedTextEdit->textCursor().insertText("\\swarrow"); + + s = 0x21D0; + if (letter == QString(QChar(s))) + connectedTextEdit->textCursor().insertText("\\Leftarrow"); + else if (letter == QString(QChar(1 + s))) + connectedTextEdit->textCursor().insertText("\\Uparrow"); + else if (letter == QString(QChar(2 + s))) + connectedTextEdit->textCursor().insertText("\\Rightarrow"); + else if (letter == QString(QChar(3 + s))) + connectedTextEdit->textCursor().insertText("\\Downarrow"); + else if (letter == QString(QChar(4 + s))) + connectedTextEdit->textCursor().insertText("\\Leftrightarrow"); + else if (letter == QString(QChar(5 + s))) + connectedTextEdit->textCursor().insertText("\\Updownarrow"); + + if (letter == QString(QChar(0x21A6))) + connectedTextEdit->textCursor().insertText("\\mapsto"); + else if (letter == QString(QChar(0x21A9))) + connectedTextEdit->textCursor().insertText("\\hookleftarrow"); + else if (letter == QString(QChar(0x21AA))) + connectedTextEdit->textCursor().insertText("\\hookrightarrow"); + else if (letter == QString(QChar(0x21BC))) + connectedTextEdit->textCursor().insertText("\\leftharpoonup"); + else if (letter == QString(QChar(0x21BD))) + connectedTextEdit->textCursor().insertText("\\leftharpoondown"); + else if (letter == QString(QChar(0x21C0))) + connectedTextEdit->textCursor().insertText("\\rightharpoonup"); + else if (letter == QString(QChar(0x21C1))) + connectedTextEdit->textCursor().insertText("\\rightharpoondown"); + else if (letter == QString(QChar(0x21CC))) + connectedTextEdit->textCursor().insertText("\\rightleftharpoons"); + + s = 0x2200; + if (letter == QString(QChar(s))) + connectedTextEdit->textCursor().insertText("\\forall"); + else if (letter == QString(QChar(2 + s))) + connectedTextEdit->textCursor().insertText("\\partial"); + else if (letter == QString(QChar(3 + s))) + connectedTextEdit->textCursor().insertText("\\exists"); + else if (letter == QString(QChar(4 + s))) + connectedTextEdit->textCursor().insertText("\\not\\exists"); + else if (letter == QString(QChar(5 + s))) + connectedTextEdit->textCursor().insertText("\\oslash"); + else if (letter == QString(QChar(6 + s))) + connectedTextEdit->textCursor().insertText("\\Delta"); + else if (letter == QString(QChar(7 + s))) + connectedTextEdit->textCursor().insertText("\\nabla"); + else if (letter == QString(QChar(8 + s))) + connectedTextEdit->textCursor().insertText("\\in"); + else if (letter == QString(QChar(9 + s))) + connectedTextEdit->textCursor().insertText("\\notin"); + else if (letter == QString(QChar(11 + s))) + connectedTextEdit->textCursor().insertText("\\ni"); + else if (letter == QString(QChar(12 + s))) + connectedTextEdit->textCursor().insertText("\\not\\ni"); + + s = 0x220F; + if (letter == QString(QChar(s))) + connectedTextEdit->textCursor().insertText("\\prod"); + else if (letter == QString(QChar(1 + s))) + connectedTextEdit->textCursor().insertText("\\coprod"); + else if (letter == QString(QChar(2 + s))) + connectedTextEdit->textCursor().insertText("\\sum"); + + if (letter == QString(QChar(0x00B1))) + connectedTextEdit->textCursor().insertText("\\pm"); + else if (letter == QString(QChar(0x2213))) + connectedTextEdit->textCursor().insertText("\\mp"); + else if (letter == QString(QChar(0x00D7))) + connectedTextEdit->textCursor().insertText("\\times"); + + s = 0x2217; + if (letter == QString(QChar(s))) + connectedTextEdit->textCursor().insertText("\\ast"); + else if (letter == QString(QChar(1 + s))) + connectedTextEdit->textCursor().insertText("\\circ"); + else if (letter == QString(QChar(2 + s))) + connectedTextEdit->textCursor().insertText("\\bullet"); + else if (letter == QString(QChar(3 + s))) + connectedTextEdit->textCursor().insertText("\\surd"); + else if (letter == QString(QChar(4 + s))) + connectedTextEdit->textCursor().insertText("\\sqrt[3]{}"); + else if (letter == QString(QChar(5 + s))) + connectedTextEdit->textCursor().insertText("\\sqrt[4]{}"); + else if (letter == QString(QChar(6 + s))) + connectedTextEdit->textCursor().insertText("\\propto"); + else if (letter == QString(QChar(7 + s))) + connectedTextEdit->textCursor().insertText("\\infty"); + + s = 0x2227; + if (letter == QString(QChar(s))) + connectedTextEdit->textCursor().insertText("\\wedge"); + else if (letter == QString(QChar(1 + s))) + connectedTextEdit->textCursor().insertText("\\vee"); + else if (letter == QString(QChar(2 + s))) + connectedTextEdit->textCursor().insertText("\\cap"); + else if (letter == QString(QChar(3 + s))) + connectedTextEdit->textCursor().insertText("\\cup"); + else if (letter == QString(QChar(4 + s))) + connectedTextEdit->textCursor().insertText("\\int"); + else if (letter == QString(QChar(5 + s))) + connectedTextEdit->textCursor().insertText("\\int \\!\\!\\! \\int"); + else if (letter == QString(QChar(6 + s))) + connectedTextEdit->textCursor().insertText("\\int \\!\\!\\! \\int \\!\\!\\! \\int"); + else if (letter == QString(QChar(7 + s))) + connectedTextEdit->textCursor().insertText("\\oint"); + + if (letter == QString(QChar(0x223F))) + connectedTextEdit->textCursor().insertText("\\sim"); + else if (letter == QString(QChar(0x2245))) + connectedTextEdit->textCursor().insertText("\\cong"); + else if (letter == QString(QChar(0x2248))) + connectedTextEdit->textCursor().insertText("\\approx"); + + s = 0x2260; + if (letter == QString(QChar(s))) + connectedTextEdit->textCursor().insertText("\\not="); + else if (letter == QString(QChar(1 + s))) + connectedTextEdit->textCursor().insertText("\\equiv"); + else if (letter == QString(QChar(2 + s))) + connectedTextEdit->textCursor().insertText("\\not\\equiv"); + + s = 0x2264; + if (letter == QString(QChar(s))) + connectedTextEdit->textCursor().insertText("\\le"); + else if (letter == QString(QChar(1 + s))) + connectedTextEdit->textCursor().insertText("\\ge"); + + s = 0x226A; + if (letter == QString(QChar(s))) + connectedTextEdit->textCursor().insertText("\\ll"); + else if (letter == QString(QChar(1 + s))) + connectedTextEdit->textCursor().insertText("\\gg"); + + s = 0x2282; + if (letter == QString(QChar(s))) + connectedTextEdit->textCursor().insertText("\\subset"); + else if (letter == QString(QChar(1 + s))) + connectedTextEdit->textCursor().insertText("\\supset"); + else if (letter == QString(QChar(2 + s))) + connectedTextEdit->textCursor().insertText("\\not\\subset"); + else if (letter == QString(QChar(3 + s))) + connectedTextEdit->textCursor().insertText("\\not\\supset"); + else if (letter == QString(QChar(4 + s))) + connectedTextEdit->textCursor().insertText("\\subseteq"); + else if (letter == QString(QChar(5 + s))) + connectedTextEdit->textCursor().insertText("\\supseteq"); + else if (letter == QString(QChar(6 + s))) + connectedTextEdit->textCursor().insertText("\\not\\subseteq"); + else if (letter == QString(QChar(7 + s))) + connectedTextEdit->textCursor().insertText("\\not\\supseteq"); + + if (letter == QString(QChar(0x210F))) + connectedTextEdit->textCursor().insertText("\\hbar"); + else if (letter == QString(QChar(0x212B))) + connectedTextEdit->textCursor().insertText("\\AA"); + } else + connectedTextEdit->textCursor().insertText(letter); +} + +void TextFormatButtons::addCurve() +{ + formatText("\\l(",")"); +} + +void TextFormatButtons::addUnderline() +{ + formatText("<u>","</u>"); +} + +void TextFormatButtons::addItalics() +{ + formatText("<i>","</i>"); +} + +void TextFormatButtons::addBold() +{ + formatText("<b>","</b>"); +} + +void TextFormatButtons::addSubscript() +{ + if (d_buttons == TexLegend || d_buttons == Equation || d_buttons == Plot3D) + formatText("_{","}"); + else + formatText("<sub>","</sub>"); +} + +void TextFormatButtons::addSuperscript() +{ + if (d_buttons == TexLegend || d_buttons == Equation || d_buttons == Plot3D) + formatText("^{","}"); + else + formatText("<sup>","</sup>"); +} + +void TextFormatButtons::addFraction() +{ + if (d_buttons == TexLegend || d_buttons == Equation) + formatText("\\frac{","}{}"); +} + +void TextFormatButtons::addSquareRoot() +{ + if (d_buttons == TexLegend || d_buttons == Equation) + formatText("\\sqrt{","}"); +} + +void TextFormatButtons::formatText(const QString & prefix, const QString & postfix) +{ + QTextCursor cursor = connectedTextEdit->textCursor(); + QString markedText = cursor.selectedText(); + cursor.insertText(prefix+markedText+postfix); + if(markedText.isEmpty()) + { + // if no text is marked, place cursor inside the <..></..> statement + // instead of after it + cursor.movePosition(QTextCursor::PreviousCharacter,QTextCursor::MoveAnchor,postfix.size()); + // the next line makes the selection visible to the user + // (the line above only changes the selection in the + // underlying QTextDocument) + connectedTextEdit->setTextCursor(cursor); + } + // give focus back to text edit + connectedTextEdit->setFocus(); +} + +void TextFormatButtons::setButtons(Buttons btns) +{ + if (btns == d_buttons) + return; + + d_buttons = btns; + init(d_buttons); +}