Exemple #1
0
void DisassemblyView::horizontalScrollBarChanged(int n)
{
  static int old = 0;
  MoveView(n - old, 0);
  old = n;
  emit viewUpdated();
}
Exemple #2
0
void DisassemblyView::resizeEvent(QResizeEvent *event)
{
  QAbstractScrollArea::resizeEvent(event);
  int w, h;
  QRect rect = viewport()->rect();
  w = rect.width() / _wChar + 1;
  h = rect.height() / _hChar + 1;
  Resize(w, h);
  emit viewUpdated();
}
Exemple #3
0
bool DisassemblyView::goTo(medusa::Address const& address)
{
  if (_core->GetDocument().GetCell(address) == nullptr)
    return false;

  GoTo(address);
  viewUpdated();

  return true;
}
Exemple #4
0
void DisassemblyView::mouseMoveEvent(QMouseEvent * evt)
{
  if (evt->buttons() & Qt::LeftButton)
  {
    medusa::u32 x = evt->x() / _wChar;
    medusa::u32 y = evt->y() / _hChar;
    EndSelection(x, y);
    _needRepaint = true; // TODO: selectionChanged
    emit viewUpdated();
  }
}
Exemple #5
0
void terrama2::services::view::core::DataManager::update(terrama2::services::view::core::ViewPtr view)
{
  {
    std::lock_guard<std::recursive_mutex> lock(mtx_);
    blockSignals(true);
    removeView(view->id);
    add(view);
    blockSignals(false);
  }

  emit viewUpdated(view);
}
Exemple #6
0
void DisassemblyView::moveCursorPosition(int x, int y)
{
  bool InvView;
  if (!MoveCursor(x, y, InvView))
    return;

  _cursorTimer.start();
  _cursorBlink = false;
  updateCursor();

  emit cursorAddressUpdated(GetCursorAddress());
  if (InvView)
    emit viewUpdated();
}
Exemple #7
0
void DisassemblyView::wheelEvent(QWheelEvent * evt)
{
  int numSteps = evt->delta() / 20;

  if (evt->orientation() == Qt::Vertical)
  {
    if (MoveView(0, -numSteps))
      emit viewUpdated();
    evt->accept();
    return;
  }

  QAbstractScrollArea::wheelEvent(evt);
}
Exemple #8
0
void DisassemblyView::setFont(void)
{
  medusa::UserConfiguration UserCfg;
  QString fontInfo = QString::fromStdString(UserCfg.GetOption("font.listing"));
  QFont font;
  font.setStyleHint(QFont::Monospace);
  font.fromString(fontInfo);

  QAbstractScrollArea::setFont(font);

  _wChar = fontMetrics().width('M');
  _hChar = fontMetrics().height();

  viewUpdated();
}
Exemple #9
0
void VtkTrackedCamera::updateView()
{
	double x = _trackedPosition[0] * _realToVirtualScale;
	double y = _trackedPosition[1] * _realToVirtualScale;
	double z = _trackedPosition[2] * _realToVirtualScale;
	double angle = vtkMath::DegreesFromRadians(
	        2 * atan(0.5 * _screenHeight * _realToVirtualScale / y));

	//double newfocal[3] = {_x + x, _y, _z + z};
	//double newpos[3] = {_x + x, _y + y, _z + z};
	//double viewup[3] = {0, 0, 1};
	SetViewAngle(angle);
	//SetPosition(newpos);
	//SetFocalPoint(newfocal);
	//SetViewUp(viewup);
	//SetClippingRange(_zNear, _zFar);
	SetViewShear(x / y, z / y, 1); // see http://www.vtk.org/pipermail/vtkusers/2005-March/078735.html

	emit viewUpdated();
}
Exemple #10
0
DisassemblyView::DisassemblyView(QWidget * parent, medusa::Medusa * core)
  : QAbstractScrollArea(parent)
  , medusa::FullDisassemblyView(
    *core,
    medusa::FormatDisassembly::ShowAddress | medusa::FormatDisassembly::AddSpaceBeforeXref,
    0, 0,
    core->GetDocument().GetStartAddress())
  , _needRepaint(true)
  , _core(core)
  , _wChar(0),              _hChar(0)
  , _addrLen(static_cast<int>(core->GetDocument().GetStartAddress().ToString().length() + 1))
  , _cursorTimer(),         _cursorBlink(false)
  , _cache()
{
  setFont(); // this method initializes both _wChar and _hChar
  setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
  setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
  connect(&_cursorTimer, SIGNAL(timeout()), this, SLOT(updateCursor()));
  _cursorTimer.setInterval(400);
  setContextMenuPolicy(Qt::CustomContextMenu);
  connect(this, SIGNAL(customContextMenuRequested(QPoint const &)), this, SLOT(showContextMenu(QPoint const &)));
  connect(horizontalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(horizontalScrollBarChanged(int)));

  connect(this, SIGNAL(DisassemblyViewAdded(medusa::Address const&)),      this->parent(),   SLOT(addDisassemblyView(medusa::Address const&)));
  connect(this, SIGNAL(SemanticViewAdded(medusa::Address const&)),         this->parent(),   SLOT(addSemanticView(medusa::Address const&)));
  connect(this, SIGNAL(ControlFlowGraphViewAdded(medusa::Address const&)), this->parent(),   SLOT(addControlFlowGraphView(medusa::Address const&)));
  connect(this, SIGNAL(viewportUpdated()),                                 this->viewport(), SLOT(update()));

  int w, h;
  QRect rect = viewport()->rect();
  w = rect.width() / _wChar + 1;
  h = rect.height() / _hChar + 1;
  Resize(w, h);
  viewUpdated();
  _UpdateActions();
}
VisualizationWidget::VisualizationWidget( QWidget* parent /*= 0*/ )
	: QWidget(parent)
{
	this->setupUi(this);

	_interactorStyle = VtkCustomInteractorStyle::New();
	vtkWidget->GetRenderWindow()->GetInteractor()->SetInteractorStyle(_interactorStyle);

	_vtkPickCallback = VtkPickCallback::New();
	vtkSmartPointer<vtkCellPicker> picker = vtkSmartPointer<vtkCellPicker>::New();
	picker->AddObserver(vtkCommand::EndPickEvent, _vtkPickCallback);
	vtkWidget->GetRenderWindow()->GetInteractor()->SetPicker(picker);

	// BUG Render Window conflicts with VREDs render window
#ifndef OGS_VRED_PLUGIN
	vtkRenderWindow* renderWindow = vtkWidget->GetRenderWindow();
	renderWindow->StereoCapableWindowOn();
	renderWindow->SetStereoTypeToCrystalEyes();
	_vtkRender = vtkRenderer::New();
	renderWindow->AddRenderer(_vtkRender);
	_interactorStyle->SetDefaultRenderer(_vtkRender);
#endif // OGS_VRED_PLUGIN

	QSettings settings("UFZ", "OpenGeoSys-5");

#ifdef OGS_USE_VRPN
	VtkTrackedCamera* cam = new VtkTrackedCamera(this);
	_vtkRender->SetActiveCamera(cam);
	connect( cam, SIGNAL(viewUpdated()), this, SLOT(updateView()) );

	//QSpaceNavigatorClient* spacenav = QSpaceNavigatorClient::Instance();
	//spacenav->init("spacenav@localhost", 1000 / 15, SpaceNavigatorClient::Z);
	//cam->setFocalPoint(0, 5.0, 0.5);
	//cam->updateView();
	//spacenav->setTranslationFactor(2.0);
	//connect( spacenav, SIGNAL(translated(double, double, double)), cam, SLOT(setTrackingData(double, double, double)) );
	//connect( spacenav, SIGNAL(translated(double, double, double)), cam, SLOT(translate(double, double, double)) );

	QVrpnArtTrackingClient* art = QVrpnArtTrackingClient::Instance(this);
	if (settings.contains("Tracking/artDeviceName"))
	{
		QString deviceName = settings.value("Tracking/artDeviceName").toString();
		QString deviceNameAt = settings.value("Tracking/artDeviceNameAt").toString();
		art->StartTracking(QString(deviceName + "@" + deviceNameAt).toStdString().c_str(),
		                   settings.value("Tracking/artUpdateInterval").toInt());
	}
	else
		art->StartTracking("[email protected]");
	connect( art, SIGNAL(positionUpdated(double, double, double)),
	         cam, SLOT(setTrackingData(double, double, double)) );

	// Connect the vtk event to the qt slot
	_qtConnect = vtkEventQtSlotConnect::New();
	_qtConnect->Connect(vtkWidget->GetRenderWindow()->GetInteractor(),
	                    vtkCommand::EndInteractionEvent,
	                    cam,
	                    SLOT(updatedFromOutside()));

#endif // OGS_USE_VRPN

	_vtkRender->SetBackground(0.0,0.0,0.0);

	// Restore settings
	stereoToolButton->setChecked(settings.value("stereoEnabled").toBool());
	//if (settings.contains("stereoEyeAngle"))
	//	cam->SetEyeAngle(settings.value("stereoEyeAngle").toDouble());
	//else
	//	cam->SetEyeAngle(2.0);
/*
    if (!stereoToolButton->isChecked())
    {
        eyeAngleLabel->setEnabled(false);
        eyeAngleSlider->setEnabled(false);
    }
 */
	//eyeAngleSlider->setValue((int)(_vtkRender->GetActiveCamera()->GetEyeAngle() * 10));

	// Create an orientation marker using vtkAxesActor
	vtkSmartPointer<vtkAxesActor> axesActor = vtkSmartPointer<vtkAxesActor>::New();
	vtkOrientationMarkerWidget* markerWidget = vtkOrientationMarkerWidget::New();
	markerWidget->SetOrientationMarker(axesActor);
	//markerWidget->SetViewport(0.0, 0.0, 0.15, 0.3); // size
	markerWidget->SetInteractor(vtkWidget->GetRenderWindow()->GetInteractor());
	markerWidget->EnabledOn();
	markerWidget->InteractiveOff();

	_isShowAllOnLoad = true;

	// Set alternate cursor shapes
	connect(_interactorStyle, SIGNAL(cursorChanged(Qt::CursorShape)),
	        this, SLOT(setCursorShape(Qt::CursorShape)));
}
Exemple #12
0
void CSVSettings::View::updateView (bool signalUpdate) const
{
    if (signalUpdate)
        emit viewUpdated(viewKey(), selectedValues());
}
Exemple #13
0
void DisassemblyView::OnDocumentUpdated(void)
{
  emit viewUpdated();
}
Exemple #14
0
void DisassemblyView::keyPressEvent(QKeyEvent * evt)
{
  bool InvView = false;

  // Move cursor
  if (evt->matches(QKeySequence::MoveToNextChar))
  { MoveCursor(+1, 0, InvView); ResetSelection(); }
  if (evt->matches(QKeySequence::MoveToPreviousChar))
  { MoveCursor(-1, 0, InvView); ResetSelection(); }

  if (evt->matches(QKeySequence::MoveToStartOfLine))
  { SetCursor(_addrLen, -1); ResetSelection(); }
  if (evt->matches(QKeySequence::MoveToEndOfLine))
  {
    medusa::LineData Line;
    if (m_PrintData.GetLine(m_Cursor.m_Address, m_Cursor.m_yAddressOffset, Line))
    {
      auto TextLen = static_cast<medusa::u32>(Line.GetText().length());
      if (TextLen != 0)
        --TextLen;
      SetCursor(TextLen, -1);
    }
  }

  if (evt->matches(QKeySequence::MoveToNextLine))
  { moveCursorPosition(0, +1); ResetSelection(); }
  if (evt->matches(QKeySequence::MoveToPreviousLine))
  { moveCursorPosition(0, -1); ResetSelection(); }

  if (evt->matches(QKeySequence::MoveToNextPage))
  { MoveCursor(0, +m_Height, InvView); ResetSelection(); }
  if (evt->matches(QKeySequence::MoveToPreviousPage))
  { MoveCursor(0, -static_cast<medusa::s32>(m_Height), InvView); ResetSelection(); }

  if (evt->matches(QKeySequence::MoveToStartOfDocument))
  {
    medusa::Address FirstAddr = m_rDoc.GetFirstAddress();
    m_Cursor.m_Address = FirstAddr;
    m_Cursor.m_yAddressOffset = 0;
    m_Top = m_Cursor;
    m_Format(FirstAddr, m_FormatFlags, m_Height);
    ResetSelection();
  }
  if (evt->matches(QKeySequence::MoveToEndOfDocument))
  {
    medusa::Address LastAddr = m_rDoc.GetLastAddress();
    m_Cursor.m_Address = LastAddr;
    m_Cursor.m_yAddressOffset = 0;
    m_Top = m_Cursor;
    m_Format(LastAddr, m_FormatFlags, m_Height);
    ResetSelection();
  }

  if (evt->matches(QKeySequence::MoveToNextWord))
  {
    medusa::LineData Line;
    if (m_PrintData.GetLine(m_Cursor.m_Address, m_Cursor.m_yAddressOffset, Line))
    {
      auto const& rText = Line.GetText();
      auto Pos = rText.find_first_not_of(" \n", m_Cursor.m_xAddressOffset);
      Pos = rText.find_first_of(" \n", Pos);
      if (Pos != std::string::npos)
        SetCursor(static_cast<medusa::u32>(Pos), -1);
      else
        SetCursor(static_cast<medusa::u32>(rText.length()), -1);
    }
  }

  if (evt->matches(QKeySequence::MoveToPreviousWord))
  {
    medusa::LineData Line;
    if (m_PrintData.GetLine(m_Cursor.m_Address, m_Cursor.m_yAddressOffset, Line))
    {
      auto const& rText = Line.GetText();
      auto Pos = rText.find_last_not_of(" \n", m_Cursor.m_xAddressOffset ? m_Cursor.m_xAddressOffset - 1 : 0);
      Pos = rText.find_last_of(" \n", Pos);
      if (Pos != std::string::npos)
        SetCursor(static_cast<medusa::u32>(Pos) + 1, -1);
      else
        SetCursor(0, -1);
    }
  }

  // Move selection
  if (evt->matches(QKeySequence::SelectNextChar))
    MoveSelection(+1, 0, InvView);
  if (evt->matches(QKeySequence::SelectPreviousChar))
    MoveSelection(-1, 0, InvView);

  if (evt->matches(QKeySequence::SelectStartOfLine))
    SetSelection(_addrLen, -1);
  if (evt->matches(QKeySequence::SelectEndOfLine))
  {
    medusa::LineData Line;
    if (m_PrintData.GetLine(m_Cursor.m_Address, m_Cursor.m_yAddressOffset, Line))
    {
      auto TextLen = static_cast<medusa::u32>(Line.GetText().length());
      if (TextLen != 0)
        --TextLen;
      SetSelection(TextLen, -1);
    }
  }

  if (evt->matches(QKeySequence::SelectNextLine))
    MoveSelection(0, +1, InvView);
  if (evt->matches(QKeySequence::SelectPreviousLine))
    MoveSelection(0, -1, InvView);

  if (evt->matches(QKeySequence::SelectNextPage))
    MoveSelection(0, +m_Height, InvView);
  if (evt->matches(QKeySequence::SelectPreviousPage))
    MoveSelection(0, -static_cast<medusa::s32>(m_Height), InvView);

  if (evt->matches(QKeySequence::SelectStartOfDocument))
  {
    m_Cursor.m_Address        = m_rDoc.GetFirstAddress();
    m_Cursor.m_xAddressOffset = 0;
    m_Cursor.m_yAddressOffset = 0;
    m_Format(m_Cursor.m_Address, m_FormatFlags, m_Height);
    m_SelectionEnd = m_Top = m_Cursor;
  }
  if (evt->matches(QKeySequence::SelectEndOfDocument))
  {
    m_Cursor.m_Address        = m_rDoc.GetLastAddress();
    m_Cursor.m_xAddressOffset = 0;
    m_Cursor.m_yAddressOffset = 0;
    m_Format(m_Cursor.m_Address, m_FormatFlags, m_Height);
    m_SelectionEnd = m_Top = m_Cursor;
  }

  if (evt->matches(QKeySequence::SelectNextWord))
  {
    medusa::LineData Line;
    if (m_PrintData.GetLine(m_Cursor.m_Address, m_Cursor.m_yAddressOffset, Line))
    {
      auto const& rText = Line.GetText();
      auto Pos = rText.find_first_not_of(" \n", m_Cursor.m_xAddressOffset);
      Pos = rText.find_first_of(" \n", Pos);
      if (Pos != std::string::npos)
        SetSelection(static_cast<medusa::u32>(Pos), -1);
      else
        SetSelection(static_cast<medusa::u32>(rText.length()), -1);
    }
  }

  if (evt->matches(QKeySequence::SelectPreviousWord))
  {
    medusa::LineData Line;
    if (m_PrintData.GetLine(m_Cursor.m_Address, m_Cursor.m_yAddressOffset, Line))
    {
      auto const& rText = Line.GetText();
      auto Pos = rText.find_last_not_of(" \n", m_Cursor.m_xAddressOffset ? m_Cursor.m_xAddressOffset - 1 : 0);
      Pos = rText.find_last_of(" \n", Pos);
      if (Pos != std::string::npos)
        SetSelection(static_cast<medusa::u32>(Pos) + 1, -1);
      else
        SetSelection(0, -1);
    }
  }

  if (evt->matches(QKeySequence::SelectAll))
  {
    medusa::Address FirstAddr = m_rDoc.GetFirstAddress();
    medusa::Address LastAddr  = m_rDoc.GetLastAddress();

    m_SelectionBegin.m_Address = FirstAddr;
    m_SelectionBegin.m_xAddressOffset = 0;
    m_SelectionBegin.m_yAddressOffset = 0;
    m_SelectionEnd.m_Address = LastAddr;
    m_SelectionEnd.m_xAddressOffset = 1; // TODO
    m_SelectionEnd.m_yAddressOffset = 1; // TODO
  }

  // Copy
  if (evt->matches(QKeySequence::Copy))
  {
    auto Start = m_SelectionBegin;
    auto Last  = m_SelectionEnd;

    if (Start.m_Address > Last.m_Address)
      std::swap(Start, Last);

    medusa::PrintData Print;
    medusa::FormatDisassembly FmtDisasm(m_rCore, Print);

    FmtDisasm(std::make_pair(Start.m_Address, Last.m_Address), m_FormatFlags);
    // TODO trim it!
    //auto& rLines = Print.GetTextLines();
    //rLines.erase();
    //rLines.erase();
    QApplication::clipboard()->setText(QString::fromStdString(Print.GetTexts()));
  }

  emit viewUpdated();

  QAbstractScrollArea::keyPressEvent(evt);
}