Ejemplo n.º 1
0
void Matrix::init(int rows, int cols)
{
	formula_str = "";
	txt_format = 'f';
	num_precision = 6;
	x_start = 1.0;
	x_end = 10.0;
	y_start = 1.0;
	y_end = 10.0;
	dMatrix = 0;
	allow_modification_signals = true;

	QDateTime dt = QDateTime::currentDateTime();
	setBirthDate(dt.toString(Qt::LocalDate));

	// create the main table widget
	d_table = new QTableWidget(rows, cols, 0);
	d_table->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding));
	d_table->setFocusPolicy(Qt::StrongFocus);
	d_table->setFocus();
	// only one contiguous selection supported
	d_table->setSelectionMode(QAbstractItemView::ContiguousSelection);
	d_table->verticalHeader()->setMovable(true);

	// background color to yellow to distinguish between matrix and table
	QPalette pal = d_table->palette();
	pal.setColor(QColorGroup::Base, QColor(255, 255, 128));
	d_table->setPalette(pal);

	// give all space to the table widget
	QVBoxLayout* main_layout = new QVBoxLayout(this);
	main_layout->setMargin(0);
	main_layout->addWidget(d_table);

	// set header properties
	QHeaderView* hHeader=(QHeaderView*)d_table->horizontalHeader();
	hHeader->setMovable(false);
	hHeader->setResizeMode(QHeaderView::Fixed);
	QHeaderView* vHeader=(QHeaderView*)d_table->verticalHeader();
	vHeader->setMovable(false);
	vHeader->setResizeMode(QHeaderView::ResizeToContents);

	// resize the table
	setGeometry(50, 50, qMin(_Matrix_initial_columns_, cols)*hHeader->sectionSize(0) + 55,
                (qMin(_Matrix_initial_rows_,rows)+1)*vHeader->sectionSize(0));

	// keyboard shortcuts
	QShortcut * sel_all = new QShortcut(QKeySequence(tr("Ctrl+A", "Matrix: select all")), this);
	connect(sel_all, SIGNAL(activated()), d_table, SLOT(selectAll()));
	// remark: the [TAB] behaviour is now nicely done by Qt4

	connect(d_table, SIGNAL(cellChanged(int,int)), this, SLOT(cellEdited(int,int)));
}
Ejemplo n.º 2
0
void Note::init(ScriptingEnv *env)
{
autoExec = false;
QDateTime dt = QDateTime::currentDateTime ();
setBirthDate(dt.toString(Qt::LocalDate));

te = new ScriptEdit(env, this, name());
te->setContext(this);
QVBoxLayout* hlayout = new QVBoxLayout(this,0,0, "hlayout1");
hlayout->addWidget(te);

setGeometry(0, 0, 500, 200);
connect(te, SIGNAL(textChanged()), this, SLOT(modifiedNote()));
}
Ejemplo n.º 3
0
MultiLayer::MultiLayer(const QString& label, QWidget* parent, const char* name, WFlags f)
        : myWidget(label,parent,name,f)
{
if ( !name )
	setName( "multilayer plot" );

setPaletteBackgroundColor( QColor(white) );

QDateTime dt = QDateTime::currentDateTime ();
setBirthDate(dt.toString(Qt::LocalDate));
	
graphs=0;cols=1;rows=1;
graph_width=500;graph_height=400;
colsSpace=5,rowsSpace=5;
active_graph=0;
addTextOn=FALSE;
movedGraph=FALSE;
resizedGraph=FALSE;
ChangeOrigin=FALSE;
	
buttonsList=new QWidgetList();
buttonsList->setAutoDelete( TRUE );
	
graphsList=new QWidgetList();
graphsList->setAutoDelete( TRUE );
	
hbox1=new QHBox(this, "hbox1"); 
LayerButton *button = new LayerButton(QString::number(1),hbox1,0);
hbox1->setFixedHeight(button->height());
setGeometry(QRect( 0, 0, graph_width, graph_height + button->height()));
delete button;
	
canvas=new QWidget (this, "canvas");
canvas->installEventFilter(this);

QVBoxLayout* layout = new QVBoxLayout(this,0,0, "hlayout3");
layout->addWidget(hbox1);
layout->addWidget(canvas);

setFocusPolicy(QWidget::StrongFocus);
setMouseTracking(TRUE);
}
Ejemplo n.º 4
0
Layout2D::Layout2D(const QString &label, QWidget *parent, const QString name,
                   Qt::WFlags f)
    : MyWidget(label, parent, name, f),
      plot2dCanvas_(new Plot2D(this)),
      layout_(new LayoutGrid2D()),
      buttionlist_(QList<LayoutButton2D *>()),
      currentAxisRect_(nullptr),
      draggingLegend(false) {
  if (name.isEmpty()) setObjectName("multilayout2d plot");
  QDateTime birthday = QDateTime::currentDateTime();
  setBirthDate(birthday.toString(Qt::LocalDate));

  QPalette pal = palette();
  pal.setColor(QPalette::Active, QPalette::Window, QColor(Qt::white));
  pal.setColor(QPalette::Inactive, QPalette::Window, QColor(Qt::white));
  pal.setColor(QPalette::Disabled, QPalette::Window, QColor(Qt::white));
  setPalette(pal);

  layoutManagebuttonsBox_ = new QHBoxLayout();
  addLayoutButton_ = new QPushButton();
  addLayoutButton_->setToolTip(tr("Add layer"));
  addLayoutButton_->setIcon(
      IconLoader::load("list-add", IconLoader::LightDark));
  addLayoutButton_->setMaximumWidth(LayoutButton2D::btnSize());
  addLayoutButton_->setMaximumHeight(LayoutButton2D::btnSize());
  connect(addLayoutButton_, SIGNAL(clicked()), this, SLOT(addAxisRectItem()));
  layoutManagebuttonsBox_->addWidget(addLayoutButton_);

  removeLayoutButton_ = new QPushButton();
  removeLayoutButton_->setToolTip(tr("Remove active layer"));
  removeLayoutButton_->setIcon(
      IconLoader::load("list-remove", IconLoader::General));
  removeLayoutButton_->setMaximumWidth(LayoutButton2D::btnSize());
  removeLayoutButton_->setMaximumHeight(LayoutButton2D::btnSize());
  connect(removeLayoutButton_, SIGNAL(clicked()), this,
          SLOT(removeAxisRectItem()));
  layoutManagebuttonsBox_->addWidget(removeLayoutButton_);

  layoutButtonsBox_ = new QHBoxLayout();
  QHBoxLayout *hbox = new QHBoxLayout();
  hbox->addLayout(layoutButtonsBox_);
  streachLabel_ = new QLabel(this);
  hbox->addWidget(streachLabel_);
  setBackground(plot2dCanvas_->getBackgroundColor());
  hbox->addLayout(layoutManagebuttonsBox_);

  QVBoxLayout *layout = new QVBoxLayout(this);
  layout->addLayout(hbox);
  layout->addWidget(plot2dCanvas_, 1);
  layout->setMargin(0);
  layout->setSpacing(0);
  setGeometry(QRect(0, 0, 500, 400));
  setMinimumSize(QSize(100, 100));
  setFocusPolicy(Qt::StrongFocus);

  plot2dCanvas_->plotLayout()->addElement(0, 0, layout_);

  // connections
  connect(plot2dCanvas_,
          SIGNAL(axisDoubleClick(QCPAxis *, QCPAxis::SelectablePart,
                                 QMouseEvent *)),
          this, SLOT(axisDoubleClicked(QCPAxis *, QCPAxis::SelectablePart)));
  connect(plot2dCanvas_, SIGNAL(mouseMove(QMouseEvent *)), this,
          SLOT(mouseMoveSignal(QMouseEvent *)));
  connect(plot2dCanvas_, SIGNAL(mousePress(QMouseEvent *)), this,
          SLOT(mousePressSignal(QMouseEvent *)));
  connect(plot2dCanvas_, SIGNAL(mouseRelease(QMouseEvent *)), this,
          SLOT(mouseReleaseSignal(QMouseEvent *)));
  connect(plot2dCanvas_, SIGNAL(beforeReplot()), this, SLOT(beforeReplot()));

  connect(plot2dCanvas_, SIGNAL(mouseWheel(QWheelEvent *)), this,
          SLOT(mouseWheel()));
  connect(plot2dCanvas_,
          SIGNAL(legendDoubleClick(QCPLegend *, QCPAbstractLegendItem *,
                                   QMouseEvent *)),
          this, SLOT(legendDoubleClick(QCPLegend *, QCPAbstractLegendItem *)));
}
Ejemplo n.º 5
0
void Matrix::init(int rows, int cols)
{
formula_str = "";
selectedCol=0;
LeftButton=FALSE;
txt_format = 'f';
num_precision = 6;
x_start = 1.0;
x_end = 10.0;
y_start = 1.0; 
y_end = 10.0;
dMatrix = 0;

QDateTime dt = QDateTime::currentDateTime ();
setBirthDate(dt.toString(Qt::LocalDate));

d_table = new QTable (rows, cols, this, "d_table");
d_table->setFocusPolicy(QWidget::StrongFocus);
d_table->setFocus();
d_table->setSelectionMode (QTable::Single);
d_table->setRowMovingEnabled(true);

/*
//!TODO: enable column moving, right now it doesn't work because of the event filter
//installed on hHeader
d_table->setColumnMovingEnabled(true);
connect(hHeader, SIGNAL(indexChange (int, int, int)), this, SLOT(notifyChanges()));
*/

QColor background = QColor(255, 255, 128);
d_table->setPaletteBackgroundColor(background);
d_table->setBackgroundColor(background);

QVBoxLayout* hlayout = new QVBoxLayout(this,0,0);
hlayout->addWidget(d_table);

QHeader* hHeader=(QHeader*)d_table->horizontalHeader();
hHeader->installEventFilter(this);
hHeader->setMouseTracking(TRUE);

QHeader* vHeader=(QHeader*)d_table->verticalHeader();
vHeader->setResizeEnabled (false);
vHeader->installEventFilter(this);

int w, h;
if (cols>3)
	w=3*hHeader->sectionSize(0);
else
	w=cols*hHeader->sectionSize(0);

if (rows>11)
	h=11*vHeader->sectionSize(0);
else
	h=(rows+1)*vHeader->sectionSize(0);
setGeometry(50,50,w+55,h);

QAccel *accel = new QAccel(this);
accel->connectItem( accel->insertItem( Key_Tab ),
                            this, SLOT(moveCurrentCell()));
accel->connectItem( accel->insertItem( CTRL+Key_A ),
                            this, SLOT(selectAll()));

connect(d_table, SIGNAL(valueChanged(int,int)), this, SLOT(cellEdited(int,int)));
connect(vHeader, SIGNAL(indexChange (int, int, int)), this, SLOT(notifyChanges()));
}
Ejemplo n.º 6
0
MultiLayer::MultiLayer(const QString &label, QWidget *parent,
                       const QString name, Qt::WFlags f)
    : MyWidget(label, parent, name, f) {
  if (name.isEmpty()) setObjectName("multilayer plot");

  QPalette pal = palette();
  pal.setColor(QPalette::Active, QPalette::Window, QColor(Qt::white));
  pal.setColor(QPalette::Inactive, QPalette::Window, QColor(Qt::white));
  pal.setColor(QPalette::Disabled, QPalette::Window, QColor(Qt::white));
  setPalette(pal);

  QDateTime birthday = QDateTime::currentDateTime();
  setBirthDate(birthday.toString(Qt::LocalDate));

  graphs = 0;
  cols = 1;
  rows = 1;
  graph_width = 500;
  graph_height = 400;
  colsSpace = 5;
  rowsSpace = 5;
  left_margin = 5;
  right_margin = 5;
  top_margin = 5;
  bottom_margin = 5;
  l_canvas_width = 400;
  l_canvas_height = 300;
  lastSize = QSize(-1, -1);
  hor_align = HCenter;
  vert_align = VCenter;
  active_graph = 0;
  addTextOn = false;
  d_scale_on_print = true;
  d_print_cropmarks = false;

  toolbuttonsBox = new QHBoxLayout();
  addLayoutButton = new QPushButton();
  addLayoutButton->setToolTip(tr("Add layer"));
  addLayoutButton->setIcon(IconLoader::load("list-add", IconLoader::LightDark));
  addLayoutButton->setMaximumWidth(LayerButton::btnSize());
  addLayoutButton->setMaximumHeight(LayerButton::btnSize());
  connect(addLayoutButton, SIGNAL(clicked()), this, SLOT(addLayer()));
  toolbuttonsBox->addWidget(addLayoutButton);

  removeLayoutButton = new QPushButton();
  removeLayoutButton->setToolTip(tr("Remove active layer"));
  removeLayoutButton->setIcon(
      IconLoader::load("list-remove", IconLoader::General));
  removeLayoutButton->setMaximumWidth(LayerButton::btnSize());
  removeLayoutButton->setMaximumHeight(LayerButton::btnSize());
  connect(removeLayoutButton, SIGNAL(clicked()), this,
          SLOT(confirmRemoveLayer()));
  toolbuttonsBox->addWidget(removeLayoutButton);

  layerButtonsBox = new QHBoxLayout();
  QHBoxLayout *hbox = new QHBoxLayout();
  hbox->addLayout(layerButtonsBox);
  hbox->addStretch();
  hbox->addLayout(toolbuttonsBox);

  canvas = new QWidget();
  canvas->installEventFilter(this);

  QVBoxLayout *layout = new QVBoxLayout(this);
  layout->addLayout(hbox);
  layout->addWidget(canvas, 1);
  layout->setMargin(0);
  layout->setSpacing(0);
  setMinimumHeight(50);
  setGeometry(QRect(0, 0, graph_width, graph_height));
  setFocusPolicy(Qt::StrongFocus);
}