2001-08-28 03:35:17 +00:00
|
|
|
/**
|
|
|
|
* \file QGraphics.C
|
2002-09-24 13:57:09 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2001-08-28 03:35:17 +00:00
|
|
|
*
|
2002-10-20 01:48:28 +00:00
|
|
|
* \author John Levon
|
|
|
|
* \author Edwin Leuven
|
2002-10-31 20:05:55 +00:00
|
|
|
* \author Herbert Voss
|
2002-09-24 13:57:09 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS
|
2001-08-28 03:35:17 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2002-06-19 03:38:44 +00:00
|
|
|
#include "QtLyXView.h"
|
|
|
|
#include "ControlGraphics.h"
|
2002-11-07 00:21:28 +00:00
|
|
|
#include "controllers/helper_funcs.h"
|
2002-06-19 03:38:44 +00:00
|
|
|
#include "support/lstrings.h"
|
2003-05-13 17:01:28 +00:00
|
|
|
#include "support/tostr.h"
|
2002-06-19 03:38:44 +00:00
|
|
|
#include "support/FileInfo.h"
|
|
|
|
#include "support/filetools.h"
|
2003-06-30 23:56:22 +00:00
|
|
|
#include "support/lyxlib.h"
|
2002-06-19 03:38:44 +00:00
|
|
|
#include "insets/insetgraphicsParams.h"
|
2003-07-26 23:04:39 +00:00
|
|
|
//#include "bufferparams.h"
|
2002-06-19 03:38:44 +00:00
|
|
|
#include "lyxrc.h"
|
|
|
|
#include "lengthcombo.h"
|
2002-12-17 20:37:13 +00:00
|
|
|
#include "qt_helpers.h"
|
2002-10-31 20:05:55 +00:00
|
|
|
#include "lengthcommon.h"
|
|
|
|
#include "lyxlength.h"
|
2002-06-19 03:38:44 +00:00
|
|
|
#include "debug.h"
|
|
|
|
|
2002-01-31 13:15:33 +00:00
|
|
|
#include <qlineedit.h>
|
|
|
|
#include <qpushbutton.h>
|
|
|
|
#include <qcheckbox.h>
|
|
|
|
#include <qradiobutton.h>
|
|
|
|
#include <qcombobox.h>
|
|
|
|
#include <qgroupbox.h>
|
|
|
|
#include <qbuttongroup.h>
|
|
|
|
#include <qlabel.h>
|
|
|
|
|
2001-08-28 03:35:17 +00:00
|
|
|
#include "QGraphicsDialog.h"
|
|
|
|
#include "QGraphics.h"
|
|
|
|
#include "Qt2BC.h"
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2003-06-30 23:56:22 +00:00
|
|
|
using namespace lyx::support;
|
|
|
|
|
2002-10-31 20:05:55 +00:00
|
|
|
using std::vector;
|
2002-11-17 11:24:08 +00:00
|
|
|
using std::endl;
|
2001-08-28 03:35:17 +00:00
|
|
|
|
2003-03-07 18:44:57 +00:00
|
|
|
typedef QController<ControlGraphics, QView<QGraphicsDialog> > base_class;
|
2001-08-28 03:35:17 +00:00
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2003-03-07 18:44:57 +00:00
|
|
|
QGraphics::QGraphics(Dialog & parent)
|
2003-05-22 15:42:50 +00:00
|
|
|
: base_class(parent, _("LyX: Graphics"))
|
2001-08-28 03:35:17 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QGraphics::build_dialog()
|
|
|
|
{
|
|
|
|
dialog_.reset(new QGraphicsDialog(this));
|
|
|
|
|
2003-03-10 03:13:28 +00:00
|
|
|
bcview().setOK(dialog_->okPB);
|
|
|
|
bcview().setApply(dialog_->applyPB);
|
|
|
|
bcview().setRestore(dialog_->restorePB);
|
|
|
|
bcview().setCancel(dialog_->closePB);
|
|
|
|
|
|
|
|
bcview().addReadOnly(dialog_->rotateGB);
|
|
|
|
bcview().addReadOnly(dialog_->latexoptions);
|
|
|
|
bcview().addReadOnly(dialog_->subfigure);
|
|
|
|
bcview().addReadOnly(dialog_->subcaption);
|
|
|
|
bcview().addReadOnly(dialog_->filenameL);
|
|
|
|
bcview().addReadOnly(dialog_->filename);
|
|
|
|
bcview().addReadOnly(dialog_->browsePB);
|
|
|
|
bcview().addReadOnly(dialog_->unzipCB);
|
|
|
|
bcview().addReadOnly(dialog_->filename);
|
|
|
|
bcview().addReadOnly(dialog_->lbX);
|
|
|
|
bcview().addReadOnly(dialog_->lbY);
|
|
|
|
bcview().addReadOnly(dialog_->rtX);
|
|
|
|
bcview().addReadOnly(dialog_->rtY);
|
|
|
|
bcview().addReadOnly(dialog_->lbXunit);
|
|
|
|
bcview().addReadOnly(dialog_->lbYunit);
|
|
|
|
bcview().addReadOnly(dialog_->rtXunit);
|
|
|
|
bcview().addReadOnly(dialog_->rtYunit);
|
|
|
|
bcview().addReadOnly(dialog_->draftCB);
|
|
|
|
bcview().addReadOnly(dialog_->clip);
|
|
|
|
bcview().addReadOnly(dialog_->unzipCB);
|
|
|
|
bcview().addReadOnly(dialog_->subfigure);
|
|
|
|
bcview().addReadOnly(dialog_->subcaption);
|
|
|
|
bcview().addReadOnly(dialog_->showCB);
|
|
|
|
bcview().addReadOnly(dialog_->width);
|
|
|
|
bcview().addReadOnly(dialog_->height);
|
|
|
|
bcview().addReadOnly(dialog_->displayCB);
|
|
|
|
bcview().addReadOnly(dialog_->displayscale);
|
|
|
|
bcview().addReadOnly(dialog_->widthUnit);
|
|
|
|
bcview().addReadOnly(dialog_->heightUnit);
|
|
|
|
bcview().addReadOnly(dialog_->aspectratio);
|
|
|
|
bcview().addReadOnly(dialog_->angle);
|
|
|
|
bcview().addReadOnly(dialog_->origin);
|
|
|
|
bcview().addReadOnly(dialog_->latexoptions);
|
|
|
|
bcview().addReadOnly(dialog_->getPB);
|
2002-11-07 00:21:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
namespace {
|
2002-11-17 11:24:08 +00:00
|
|
|
|
2002-11-07 00:21:28 +00:00
|
|
|
// returns the number of the string s in the vector v
|
|
|
|
int getItemNo(vector<string> v, string const & s) {
|
|
|
|
vector<string>::const_iterator cit =
|
|
|
|
find(v.begin(), v.end(), s);
|
2002-11-17 11:24:08 +00:00
|
|
|
return (cit != v.end()) ? int(cit - v.begin()) : 0;
|
2002-11-07 00:21:28 +00:00
|
|
|
}
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2002-11-07 00:21:28 +00:00
|
|
|
// returns the number of the unit in the array unit_name,
|
|
|
|
// which is defined in lengthcommon.C
|
2002-11-17 11:24:08 +00:00
|
|
|
int getUnitNo(char const * c[], string const & s) {
|
2002-11-07 00:21:28 +00:00
|
|
|
int i = 0;
|
2002-11-17 11:24:08 +00:00
|
|
|
while (i < num_units && s != c[i])
|
2002-11-07 00:21:28 +00:00
|
|
|
++i;
|
|
|
|
return (i < num_units) ? i : 0;
|
|
|
|
}
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2002-11-07 00:21:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QGraphics::update_contents()
|
|
|
|
{
|
2002-11-17 11:24:08 +00:00
|
|
|
// clear and fill in the comboboxes
|
|
|
|
vector<string> const bb_units = frnt::getBBUnits();
|
|
|
|
dialog_->lbXunit->clear();
|
|
|
|
dialog_->lbYunit->clear();
|
|
|
|
dialog_->rtXunit->clear();
|
|
|
|
dialog_->rtYunit->clear();
|
|
|
|
for (vector<string>::const_iterator it = bb_units.begin();
|
|
|
|
it != bb_units.end(); ++it) {
|
2002-12-17 20:37:13 +00:00
|
|
|
dialog_->lbXunit->insertItem(toqstr(*it), -1);
|
|
|
|
dialog_->lbYunit->insertItem(toqstr(*it), -1);
|
|
|
|
dialog_->rtXunit->insertItem(toqstr(*it), -1);
|
|
|
|
dialog_->rtYunit->insertItem(toqstr(*it), -1);
|
2002-11-17 11:24:08 +00:00
|
|
|
}
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2001-08-28 03:35:17 +00:00
|
|
|
InsetGraphicsParams & igp = controller().params();
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2002-08-24 22:02:30 +00:00
|
|
|
// set the right default unit
|
2002-11-17 11:24:08 +00:00
|
|
|
LyXLength::UNIT unitDefault = LyXLength::CM;
|
2002-08-24 22:02:30 +00:00
|
|
|
switch (lyxrc.default_papersize) {
|
2003-07-26 23:04:39 +00:00
|
|
|
case PAPER_DEFAULT: break;
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2003-07-26 23:04:39 +00:00
|
|
|
case PAPER_USLETTER:
|
|
|
|
case PAPER_LEGALPAPER:
|
|
|
|
case PAPER_EXECUTIVEPAPER:
|
2002-11-17 11:24:08 +00:00
|
|
|
unitDefault = LyXLength::IN;
|
2002-10-20 01:48:28 +00:00
|
|
|
break;
|
|
|
|
|
2003-07-26 23:04:39 +00:00
|
|
|
case PAPER_A3PAPER:
|
|
|
|
case PAPER_A4PAPER:
|
|
|
|
case PAPER_A5PAPER:
|
|
|
|
case PAPER_B5PAPER:
|
2002-11-17 11:24:08 +00:00
|
|
|
unitDefault = LyXLength::CM;
|
2002-10-20 01:48:28 +00:00
|
|
|
break;
|
2002-08-24 22:02:30 +00:00
|
|
|
}
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2003-07-22 20:42:40 +00:00
|
|
|
string const name =
|
2003-07-23 09:17:04 +00:00
|
|
|
igp.filename.outputFilename(kernel().bufferFilepath());
|
2003-07-22 20:42:40 +00:00
|
|
|
dialog_->filename->setText(toqstr(name));
|
2002-01-31 13:15:33 +00:00
|
|
|
|
2002-10-31 20:05:55 +00:00
|
|
|
// set the bounding box values
|
2002-01-31 13:15:33 +00:00
|
|
|
if (igp.bb.empty()) {
|
2003-07-22 20:42:40 +00:00
|
|
|
string const bb = controller().readBB(igp.filename.absFilename());
|
2002-11-17 11:24:08 +00:00
|
|
|
// the values from the file always have the bigpoint-unit bp
|
2002-12-17 20:37:13 +00:00
|
|
|
dialog_->lbX->setText(toqstr(token(bb, ' ', 0)));
|
|
|
|
dialog_->lbY->setText(toqstr(token(bb, ' ', 1)));
|
|
|
|
dialog_->rtX->setText(toqstr(token(bb, ' ', 2)));
|
|
|
|
dialog_->rtY->setText(toqstr(token(bb, ' ', 3)));
|
2002-11-17 11:24:08 +00:00
|
|
|
dialog_->lbXunit->setCurrentItem(0);
|
|
|
|
dialog_->lbYunit->setCurrentItem(0);
|
|
|
|
dialog_->rtXunit->setCurrentItem(0);
|
|
|
|
dialog_->rtYunit->setCurrentItem(0);
|
|
|
|
controller().bbChanged = false;
|
2002-01-31 13:15:33 +00:00
|
|
|
} else {
|
|
|
|
// get the values from the inset
|
2002-10-31 20:05:55 +00:00
|
|
|
LyXLength anyLength;
|
2002-11-30 02:09:16 +00:00
|
|
|
string const xl(token(igp.bb, ' ', 0));
|
|
|
|
string const yl(token(igp.bb, ' ', 1));
|
|
|
|
string const xr(token(igp.bb, ' ', 2));
|
|
|
|
string const yr(token(igp.bb, ' ', 3));
|
2002-10-31 20:05:55 +00:00
|
|
|
if (isValidLength(xl, &anyLength)) {
|
2002-12-17 20:37:13 +00:00
|
|
|
dialog_->lbX->setText(toqstr(tostr(anyLength.value())));
|
2002-10-31 20:05:55 +00:00
|
|
|
string const unit(unit_name[anyLength.unit()]);
|
|
|
|
dialog_->lbXunit->setCurrentItem(getItemNo(bb_units, unit));
|
|
|
|
} else {
|
2002-12-17 20:37:13 +00:00
|
|
|
dialog_->lbX->setText(toqstr(xl));
|
2002-10-31 20:05:55 +00:00
|
|
|
}
|
|
|
|
if (isValidLength(yl, &anyLength)) {
|
2002-12-17 20:37:13 +00:00
|
|
|
dialog_->lbY->setText(toqstr(tostr(anyLength.value())));
|
2002-10-31 20:05:55 +00:00
|
|
|
string const unit(unit_name[anyLength.unit()]);
|
|
|
|
dialog_->lbYunit->setCurrentItem(getItemNo(bb_units, unit));
|
|
|
|
} else {
|
2002-12-17 20:37:13 +00:00
|
|
|
dialog_->lbY->setText(toqstr(xl));
|
2002-10-31 20:05:55 +00:00
|
|
|
}
|
|
|
|
if (isValidLength(xr, &anyLength)) {
|
2002-12-17 20:37:13 +00:00
|
|
|
dialog_->rtX->setText(toqstr(tostr(anyLength.value())));
|
2002-10-31 20:05:55 +00:00
|
|
|
string const unit(unit_name[anyLength.unit()]);
|
|
|
|
dialog_->rtXunit->setCurrentItem(getItemNo(bb_units, unit));
|
|
|
|
} else {
|
2002-12-17 20:37:13 +00:00
|
|
|
dialog_->rtX->setText(toqstr(xl));
|
2002-10-31 20:05:55 +00:00
|
|
|
}
|
|
|
|
if (isValidLength(yr, &anyLength)) {
|
2002-12-17 20:37:13 +00:00
|
|
|
dialog_->rtY->setText(toqstr(tostr(anyLength.value())));
|
2002-10-31 20:05:55 +00:00
|
|
|
string const unit(unit_name[anyLength.unit()]);
|
|
|
|
dialog_->rtYunit->setCurrentItem(getItemNo(bb_units, unit));
|
|
|
|
} else {
|
2002-12-17 20:37:13 +00:00
|
|
|
dialog_->rtY->setText(toqstr(xl));
|
2002-10-31 20:05:55 +00:00
|
|
|
}
|
2002-11-17 11:24:08 +00:00
|
|
|
controller().bbChanged = true;
|
2002-01-31 13:15:33 +00:00
|
|
|
}
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2002-01-31 13:15:33 +00:00
|
|
|
// Update the draft and clip mode
|
2002-08-25 04:06:06 +00:00
|
|
|
dialog_->draftCB->setChecked(igp.draft);
|
2002-01-31 13:15:33 +00:00
|
|
|
dialog_->clip->setChecked(igp.clip);
|
2002-08-25 04:06:06 +00:00
|
|
|
dialog_->unzipCB->setChecked(igp.noUnzip);
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2002-01-31 13:15:33 +00:00
|
|
|
// Update the subcaption check button and input field
|
|
|
|
dialog_->subfigure->setChecked(igp.subcaption);
|
2002-12-17 20:37:13 +00:00
|
|
|
dialog_->subcaption->setText(toqstr(igp.subcaptionText));
|
2001-08-28 03:35:17 +00:00
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
int item = 0;
|
2001-08-28 03:35:17 +00:00
|
|
|
switch (igp.display) {
|
2003-07-21 21:30:57 +00:00
|
|
|
case lyx::graphics::DefaultDisplay: item = 0; break;
|
|
|
|
case lyx::graphics::MonochromeDisplay: item = 1; break;
|
|
|
|
case lyx::graphics::GrayscaleDisplay: item = 2; break;
|
|
|
|
case lyx::graphics::ColorDisplay: item = 3; break;
|
|
|
|
case lyx::graphics::NoDisplay: item = 0; break;
|
2001-08-28 03:35:17 +00:00
|
|
|
}
|
2002-08-25 04:06:06 +00:00
|
|
|
dialog_->showCB->setCurrentItem(item);
|
2003-07-21 21:30:57 +00:00
|
|
|
dialog_->showCB->setEnabled(igp.display != lyx::graphics::NoDisplay && !readOnly());
|
|
|
|
dialog_->displayCB->setChecked(igp.display != lyx::graphics::NoDisplay);
|
|
|
|
dialog_->displayscale->setEnabled(igp.display != lyx::graphics::NoDisplay && !readOnly());
|
2002-12-17 20:37:13 +00:00
|
|
|
dialog_->displayscale->setText(toqstr(tostr(igp.lyxscale)));
|
2002-08-08 03:50:54 +00:00
|
|
|
|
2002-11-17 11:24:08 +00:00
|
|
|
//// the output section (width/height)
|
2002-11-07 00:21:28 +00:00
|
|
|
// set the length combo boxes
|
|
|
|
// only the width has the possibility for scale%. The original
|
2002-11-27 10:30:28 +00:00
|
|
|
// units are defined in lengthcommon.C
|
2002-11-17 11:24:08 +00:00
|
|
|
// 1. the width (a listttype)
|
|
|
|
dialog_->widthUnit->clear();
|
2002-12-17 20:37:13 +00:00
|
|
|
dialog_->widthUnit->insertItem(qt_("Scale%"));
|
2002-11-27 10:30:28 +00:00
|
|
|
for (int i = 0; i < num_units; i++)
|
2002-11-17 11:24:08 +00:00
|
|
|
dialog_->widthUnit->insertItem(unit_name_gui[i], -1);
|
|
|
|
|
2003-06-30 23:56:22 +00:00
|
|
|
if (!float_equal(igp.scale, 0.0, 0.05)) {
|
2002-11-07 00:21:28 +00:00
|
|
|
// there is a scale value > 0.05
|
2002-12-17 20:37:13 +00:00
|
|
|
dialog_->width->setText(toqstr(tostr(igp.scale)));
|
2002-11-07 00:21:28 +00:00
|
|
|
dialog_->widthUnit->setCurrentItem(0);
|
|
|
|
} else {
|
|
|
|
// no scale means default width/height
|
2002-12-17 20:37:13 +00:00
|
|
|
dialog_->width->setText(toqstr(tostr(igp.width.value())));
|
2002-11-17 11:24:08 +00:00
|
|
|
// the width cannot have a unitDefault, because
|
|
|
|
// it is a "Scale%" or another user defined unit!
|
|
|
|
// +1 instead of the "Scale%" option
|
|
|
|
int unit_ = igp.width.unit();
|
|
|
|
dialog_->widthUnit->setCurrentItem(unit_ + 1);
|
2002-11-07 00:21:28 +00:00
|
|
|
}
|
2002-11-17 11:24:08 +00:00
|
|
|
// 2. the height (a lengthgcombo type)
|
2002-12-17 20:37:13 +00:00
|
|
|
dialog_->height->setText(toqstr(tostr(igp.height.value())));
|
2002-11-17 11:24:08 +00:00
|
|
|
LyXLength::UNIT unit_ = (igp.height.value() > 0.0) ?
|
|
|
|
igp.height.unit() : unitDefault;
|
|
|
|
dialog_->heightUnit->setCurrentItem(unit_);
|
2002-11-07 00:21:28 +00:00
|
|
|
|
|
|
|
// enable height input in case of non "Scale%" as width-unit
|
|
|
|
bool use_height = (dialog_->widthUnit->currentItem() > 0);
|
|
|
|
dialog_->height->setEnabled(use_height);
|
|
|
|
dialog_->heightUnit->setEnabled(use_height);
|
|
|
|
|
2002-08-08 03:50:54 +00:00
|
|
|
dialog_->aspectratio->setChecked(igp.keepAspectRatio);
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2002-12-17 20:37:13 +00:00
|
|
|
dialog_->angle->setText(toqstr(tostr(igp.rotateAngle)));
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2002-11-17 11:24:08 +00:00
|
|
|
dialog_->origin->clear();
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2002-11-17 11:24:08 +00:00
|
|
|
using namespace frnt;
|
|
|
|
vector<RotationOriginPair> origindata = getRotationOriginData();
|
|
|
|
vector<string> const origin_lang = getFirst(origindata);
|
|
|
|
QGraphics::origin_ltx = getSecond(origindata);
|
|
|
|
|
|
|
|
for (vector<string>::const_iterator it = origin_lang.begin();
|
|
|
|
it != origin_lang.end(); ++it)
|
2002-12-17 20:37:13 +00:00
|
|
|
dialog_->origin->insertItem(toqstr(*it), -1);
|
2002-11-27 10:30:28 +00:00
|
|
|
|
2002-11-07 00:21:28 +00:00
|
|
|
if (!igp.rotateOrigin.empty())
|
|
|
|
dialog_->origin->setCurrentItem(
|
|
|
|
::getItemNo(origin_ltx, igp.rotateOrigin));
|
2002-11-17 11:24:08 +00:00
|
|
|
else
|
|
|
|
dialog_->origin->setCurrentItem(0);
|
2002-01-31 13:15:33 +00:00
|
|
|
|
2002-11-27 10:30:28 +00:00
|
|
|
//// latex section
|
2002-12-17 20:37:13 +00:00
|
|
|
dialog_->latexoptions->setText(toqstr(igp.special));
|
2001-08-28 03:35:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QGraphics::apply()
|
|
|
|
{
|
|
|
|
InsetGraphicsParams & igp = controller().params();
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2003-07-22 20:42:40 +00:00
|
|
|
igp.filename.set(fromqstr(dialog_->filename->text()),
|
2003-07-23 09:17:04 +00:00
|
|
|
kernel().bufferFilepath());
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2002-10-31 20:05:55 +00:00
|
|
|
// the bb section
|
2002-11-17 11:24:08 +00:00
|
|
|
igp.bb.erase();
|
|
|
|
if (controller().bbChanged) {
|
2002-01-31 13:15:33 +00:00
|
|
|
string bb;
|
2002-12-17 20:37:13 +00:00
|
|
|
string lbX(fromqstr(dialog_->lbX->text()));
|
|
|
|
string lbY(fromqstr(dialog_->lbY->text()));
|
|
|
|
string rtX(fromqstr(dialog_->rtX->text()));
|
|
|
|
string rtY(fromqstr(dialog_->rtY->text()));
|
2002-11-27 10:30:28 +00:00
|
|
|
int bb_sum =
|
|
|
|
strToInt(lbX) + strToInt(lbY) +
|
2002-11-17 11:24:08 +00:00
|
|
|
strToInt(rtX) + strToInt(rtX);
|
|
|
|
if (bb_sum) {
|
|
|
|
if (lbX.empty())
|
|
|
|
bb = "0 ";
|
|
|
|
else
|
2002-12-17 20:37:13 +00:00
|
|
|
bb = lbX + fromqstr(dialog_->lbXunit->currentText()) + ' ';
|
2002-11-17 11:24:08 +00:00
|
|
|
if (lbY.empty())
|
|
|
|
bb += "0 ";
|
2002-11-27 10:30:28 +00:00
|
|
|
else
|
2002-12-17 20:37:13 +00:00
|
|
|
bb += (lbY + fromqstr(dialog_->lbYunit->currentText()) + ' ');
|
2002-11-17 11:24:08 +00:00
|
|
|
if (rtX.empty())
|
|
|
|
bb += "0 ";
|
2002-11-27 10:30:28 +00:00
|
|
|
else
|
2002-12-17 20:37:13 +00:00
|
|
|
bb += (rtX + fromqstr(dialog_->rtXunit->currentText()) + ' ');
|
2002-11-17 11:24:08 +00:00
|
|
|
if (rtY.empty())
|
2002-11-27 10:30:28 +00:00
|
|
|
bb += '0';
|
|
|
|
else
|
2002-12-17 20:37:13 +00:00
|
|
|
bb += (rtY + fromqstr(dialog_->rtYunit->currentText()));
|
2002-11-17 11:24:08 +00:00
|
|
|
igp.bb = bb;
|
|
|
|
}
|
2001-08-28 03:35:17 +00:00
|
|
|
}
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2002-08-25 04:06:06 +00:00
|
|
|
igp.draft = dialog_->draftCB->isChecked();
|
2002-01-31 13:15:33 +00:00
|
|
|
igp.clip = dialog_->clip->isChecked();
|
|
|
|
igp.subcaption = dialog_->subfigure->isChecked();
|
2002-12-17 20:37:13 +00:00
|
|
|
igp.subcaptionText = fromqstr(dialog_->subcaption->text());
|
2002-01-31 13:15:33 +00:00
|
|
|
|
2002-08-25 04:06:06 +00:00
|
|
|
switch (dialog_->showCB->currentItem()) {
|
2003-07-21 21:30:57 +00:00
|
|
|
case 0: igp.display = lyx::graphics::DefaultDisplay; break;
|
|
|
|
case 1: igp.display = lyx::graphics::MonochromeDisplay; break;
|
|
|
|
case 2: igp.display = lyx::graphics::GrayscaleDisplay; break;
|
|
|
|
case 3: igp.display = lyx::graphics::ColorDisplay; break;
|
2001-08-28 03:35:17 +00:00
|
|
|
default:;
|
|
|
|
}
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2002-08-25 04:06:06 +00:00
|
|
|
if (!dialog_->displayCB->isChecked())
|
2003-07-21 21:30:57 +00:00
|
|
|
igp.display = lyx::graphics::NoDisplay;
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-12-17 20:37:13 +00:00
|
|
|
string value(fromqstr(dialog_->width->text()));
|
2002-11-07 00:21:28 +00:00
|
|
|
if (dialog_->widthUnit->currentItem() > 0) {
|
|
|
|
// width/height combination
|
2002-11-27 10:30:28 +00:00
|
|
|
int const unitNo = getUnitNo(unit_name_gui,
|
2002-12-17 20:37:13 +00:00
|
|
|
fromqstr(dialog_->widthUnit->currentText()));
|
2002-11-17 11:24:08 +00:00
|
|
|
igp.width = LyXLength(value + unit_name_ltx[unitNo]);
|
2002-11-27 10:30:28 +00:00
|
|
|
igp.scale = 0.0;
|
2002-11-07 00:21:28 +00:00
|
|
|
} else {
|
|
|
|
// scaling instead of a width
|
2002-11-27 10:30:28 +00:00
|
|
|
igp.scale = strToDbl(value);
|
|
|
|
igp.width = LyXLength();
|
2002-11-07 00:21:28 +00:00
|
|
|
}
|
2002-12-17 20:37:13 +00:00
|
|
|
value = fromqstr(dialog_->height->text());
|
2002-11-27 10:30:28 +00:00
|
|
|
int const unitNo = getUnitNo(unit_name_gui,
|
2002-12-17 20:37:13 +00:00
|
|
|
fromqstr(dialog_->heightUnit->currentText()));
|
2002-11-17 11:24:08 +00:00
|
|
|
igp.height = LyXLength(value + unit_name_ltx[unitNo]);
|
2002-01-31 13:15:33 +00:00
|
|
|
|
2002-08-08 03:50:54 +00:00
|
|
|
igp.keepAspectRatio = dialog_->aspectratio->isChecked();
|
2002-08-25 04:06:06 +00:00
|
|
|
|
|
|
|
igp.noUnzip = dialog_->unzipCB->isChecked();
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-12-17 20:37:13 +00:00
|
|
|
igp.lyxscale = strToInt(fromqstr(dialog_->displayscale->text()));
|
2002-01-31 13:15:33 +00:00
|
|
|
|
2002-12-17 20:37:13 +00:00
|
|
|
igp.rotateAngle = strToDbl(fromqstr(dialog_->angle->text()));
|
2002-08-25 04:06:06 +00:00
|
|
|
while (igp.rotateAngle < -360.0)
|
|
|
|
igp.rotateAngle += 360.0;
|
|
|
|
while (igp.rotateAngle > 360.0)
|
|
|
|
igp.rotateAngle -= 360.0;
|
2002-03-21 21:21:28 +00:00
|
|
|
|
2002-11-07 00:21:28 +00:00
|
|
|
// save the latex name for the origin. If it is the default
|
|
|
|
// then origin_ltx returns ""
|
2002-11-27 10:30:28 +00:00
|
|
|
igp.rotateOrigin =
|
2002-11-17 11:24:08 +00:00
|
|
|
QGraphics::origin_ltx[dialog_->origin->currentItem()];
|
|
|
|
|
2002-11-07 00:21:28 +00:00
|
|
|
// more latex options
|
2002-12-17 20:37:13 +00:00
|
|
|
igp.special = fromqstr(dialog_->latexoptions->text());
|
2001-08-28 03:35:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-11-07 00:21:28 +00:00
|
|
|
void QGraphics::getBB()
|
2002-01-31 13:15:33 +00:00
|
|
|
{
|
2002-12-17 20:37:13 +00:00
|
|
|
string const filename(fromqstr(dialog_->filename->text()));
|
2002-08-08 03:50:54 +00:00
|
|
|
if (!filename.empty()) {
|
2002-10-30 17:13:09 +00:00
|
|
|
string const bb(controller().readBB(filename));
|
2002-08-08 03:50:54 +00:00
|
|
|
if (!bb.empty()) {
|
2002-12-17 20:37:13 +00:00
|
|
|
dialog_->lbX->setText(toqstr(token(bb, ' ', 0)));
|
|
|
|
dialog_->lbY->setText(toqstr(token(bb, ' ', 1)));
|
|
|
|
dialog_->rtX->setText(toqstr(token(bb, ' ', 2)));
|
|
|
|
dialog_->rtY->setText(toqstr(token(bb, ' ', 3)));
|
2002-10-31 20:05:55 +00:00
|
|
|
// the default units for the bb values when reading
|
|
|
|
// it from the file
|
|
|
|
dialog_->lbXunit->setCurrentItem(0);
|
|
|
|
dialog_->lbYunit->setCurrentItem(0);
|
|
|
|
dialog_->rtXunit->setCurrentItem(0);
|
|
|
|
dialog_->rtYunit->setCurrentItem(0);
|
2002-08-08 03:50:54 +00:00
|
|
|
}
|
|
|
|
controller().bbChanged = false;
|
2002-01-31 13:15:33 +00:00
|
|
|
}
|
2001-08-28 03:35:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool QGraphics::isValid()
|
|
|
|
{
|
2002-12-17 20:37:13 +00:00
|
|
|
return !dialog_->filename->text().isEmpty();
|
2001-08-28 03:35:17 +00:00
|
|
|
}
|