Пример #1
0
bool CMapWidget::event(QEvent *e)
{
  if (e->type() == QEvent::ToolTip) {
    QHelpEvent *helpEvent = static_cast<QHelpEvent *>(e);
    QPoint point = helpEvent->pos();

    CMapView *view = getView();
    CMapLevel *level = view->getCurrentlyViewedLevel();
    CMapElement *element = level ? level->findElementAt(point) : 0;
    QString s;
    if (element)
    {
      if (element->getElementType() == ROOM)
      {
        s = ((CMapRoom*)element)->getLabel();
      }
      else if (element->getElementType() == ZONE)
      {
        s = ((CMapZone*)element)->getLabel();
      }

      if (!s.trimmed().isEmpty())
        QToolTip::showText (helpEvent->globalPos(), s, this);
      else
        QToolTip::hideText ();
    }
  }
  return QWidget::event(e);
}
Пример #2
0
void SkServer::zoom(int dir)
{
  CMapView *view = m_mainWin->getView();
  view->addFov(dir, 1);
  view->repaintMap();
  sendData(SKS_OK);
}
Пример #3
0
//-----------------------------------------------------------------------------
// Purpose: Calls ReplaceView with the appropriate runtime class information to
//			switch the active view to given view type.
// Input  : eViewType - 2d xy, xz, 3d textured, flat, etc.
//-----------------------------------------------------------------------------
void CChildFrame::SetViewType(DrawType_t eViewType)
{
	CMapView *pNewView = NULL;

	switch (eViewType)
	{
		case VIEW2D_XY:
		case VIEW2D_XZ:
		case VIEW2D_YZ:
		{
			pNewView = (CMapView2D *)ReplaceView(RUNTIME_CLASS(CMapView2D));
			break;
		}

		case VIEW3D_WIREFRAME:
		case VIEW3D_POLYGON:
		case VIEW3D_TEXTURED:
		case VIEW3D_LIGHTMAP_GRID:
		case VIEW3D_LIGHTING_PREVIEW:
		case VIEW3D_SMOOTHING_GROUP:
		{
			pNewView = (CMapView *)ReplaceView(RUNTIME_CLASS(CMapView3D));
			break;
		}
	}

	if (pNewView != NULL)
	{
		SetActiveView(pNewView);
		pNewView->SetDrawType(eViewType);
		pNewView->UpdateWindow();
	}
}
Пример #4
0
void CMapWidget::showContexMenu(QMouseEvent *e)
{
  CMapLevel *level = viewWidget->getCurrentlyViewedLevel();
  if (!level) return;

  CMapView *view = mapManager->getActiveView();
  view->setSelectedPos(e->pos());
  selectedPos = e->pos();

  view->setSelectedElement(0);
  CMapElement *element = level->findElementAt (e->pos());
  if (!element) {
    showOtherContextMenu();
    return;
  }

  view->setSelectedElement(element);

  mapManager->unsetEditElement();
  switch(element->getElementType())
  {
    case ROOM : showRoomContextMenu(); break;
    case PATH : showPathContextMenu(); break;
    case TEXT : showTextContextMenu(); break;
    default   : showOtherContextMenu(); break;
  }
}
Пример #5
0
//-----------------------------------------------------------------------------
// Purpose: Stores layout information in the registry for use next session.
//-----------------------------------------------------------------------------
void CChildFrame::SaveOptions(void)
{
	if (bUsingSplitter)
	{
		//
		// Save the draw type for each pane of the splitter.
		//
		for (int nRow = 0; nRow < 2; nRow++)
		{
			for (int nCol = 0; nCol < 2; nCol++)
			{
				CMapView *pView = (CMapView *)m_wndSplitter->GetPane(nRow, nCol);
				if (pView != NULL)
				{
					char szKey[30];
					sprintf(szKey, "DrawType%d,%d", nRow, nCol);
					APP()->WriteProfileInt("Splitter", szKey, pView->GetDrawType());
				}
			}
		}

		//
		// Save the window position, size, and minimized/maximized state.
		//
		WINDOWPLACEMENT wp;
		wp.length = sizeof(wp);
		GetWindowPlacement(&wp);

		char szPlacement[100];
		sprintf(szPlacement, "(%d %d) (%d %d) (%d %d %d %d) %d", wp.ptMaxPosition.x, wp.ptMaxPosition.y, wp.ptMinPosition.x, wp.ptMinPosition.y, wp.rcNormalPosition.bottom, wp.rcNormalPosition.left, wp.rcNormalPosition.right, wp.rcNormalPosition.top, wp.showCmd);
		APP()->WriteProfileString("Splitter", "WindowPlacement", szPlacement);
	}
}
Пример #6
0
void Mapui::onLoadScene()
{
	TuiManager::getInstance()->parseScene(this,"panel_map",PATH_MAP);

    CMapView* pMapView = (CMapView*)this->getControl(PANEL_MAP,MAP_TEST);
	pMapView->setRole(Sprite::create("map/img_icon.png"),Vec2(0,0),5);
    
    CButton* pBtnBack = (CButton*)this->getControl(PANEL_MAP,BTN_BACK);
    pBtnBack->setOnClickListener(this, ccw_click_selector(Mapui::event_btn_back));
}
Пример #7
0
void SkServer::setJD(const QString &data)
{
  double jd = data.toDouble();

  jd = CLAMP(jd, MIN_JD, MAX_JD);

  CMapView *view = m_mainWin->getView();
  view->m_mapView.jd = jd;
  view->repaintMap();

  sendData(SKS_OK);
}
Пример #8
0
LRESULT CALLBACK CMapView::WndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
    CMapView* e;
    
    if (msg==WM_QUIT || msg==WM_CLOSE) 
    {
        SetWindowLong(hwnd,GWL_USERDATA,0);
        PostQuitMessage(0);
        return 0;
    }
    
    e=(CMapView*)GetWindowLong(hwnd,GWL_USERDATA);
    if (!e) return DefWindowProc(hwnd,msg,wParam,lParam);
    
    return e->MsgProc(msg,wParam,lParam);                                // so we aren't dragged down by this whole 'static member function' stuff :/
}
Пример #9
0
void SkServer::getPos()
{
  QByteArray data;

  CMapView *view = m_mainWin->getView();

  double ra, dec;

  trfConvScrPtToXY(view->width() / 2., view->height() / 2., ra, dec);
  if (view->m_mapView.epochJ2000 && view->m_mapView.coordType == SMCT_RA_DEC)
  {
    precess(&ra, &dec, view->m_mapView.jd, JD2000);
  }

  data.append(QString::number(R2D(ra), 'f'));
  data.append(",");
  data.append(QString::number(R2D(dec), 'f'));

  sendData(data);
}
Пример #10
0
/** This method is called with when input is sent to the mud */
QString CMapFilter::processCommand (const QString &command)
{
  if (mapManager->validMoveCmd(command))
  {
    CMapView *view = mapManager->getActiveView();
    if (view->getFollowMode())
    {
      QString newStr;
      newStr += executeBeforeCommand (command);
      newStr += command;
      newStr += executeAfterCommand (command);

      if (mapManager->getMapData()->validRoomCheck)
        directionCmdQueue.enqueue(new QString (command));
      else
        mapManager->movePlayerBy(command);
      return newStr;
    }
  }
  return command;
}
Пример #11
0
void SkServer::setRA_Dec(const QString &data)
{
  CMapView *view = m_mainWin->getView();

  QStringList args = data.split(",");
  if (args.count() < 2 || args.count() > 3)
  {
    sendData(SKS_INVALID);
    return;
  }

  double ra, dec, fov = CM_UNDEF;
  if (args.count() >= 2)
  {
    ra = D2R(args[0].toDouble());
    dec = D2R(args[1].toDouble());
  }

  if (args.count() == 3)
  {
    fov = D2R(args[2].toDouble());
  }

  rangeDbl(&ra, R360);
  dec = CLAMP(dec, -R90, R90);

  if (fov > CM_UNDEF)
  {
    fov = CLAMP(fov, MIN_MAP_FOV, MAX_MAP_FOV);
  }

  if (view->m_mapView.epochJ2000 && view->m_mapView.coordType == SMCT_RA_DEC)
  {
    precess(&ra, &dec, JD2000, view->m_mapView.jd);
  }
  view->centerMap(ra, dec, fov);

  sendData(SKS_OK);
}
Пример #12
0
void CMapWidget::showPathContextMenu(void)
{
  CMapPath *path = (CMapPath *) getView()->getSelectedElement();

  bool twoWay = path->getOpsitePath();

  KActionCollection *acol = getView()->actionCollection();
  KToggleAction *pathTwoWay = (KToggleAction *)acol->action("pathTwoWay");
  KToggleAction *pathOneWay = (KToggleAction *)acol->action("pathOneWay");
  QAction *pathEditBends = acol->action("pathEditBends");
  QAction *pathDelBend = acol->action("pathDelBend");
  QAction *pathAddBend = acol->action("pathAddBend");

  pathTwoWay->setChecked(twoWay);
  pathOneWay->setChecked(!twoWay);

  CMapView *view = (CMapView *) viewWidget;
  pathDelBend->setEnabled(path->mouseInPathSeg(selectedPos,view->getCurrentlyViewedZone())!=-1);
  pathEditBends->setEnabled(path->getBendCount() > 0);
  pathAddBend->setEnabled(path->getSrcRoom()->getZone()==path->getDestRoom()->getZone());

  showContextMenu (path_menu);
}
Пример #13
0
//-----------------------------------------------------------------------------
// Purpose: Calls ReplaceView with the appropriate runtime class information to
//			switch the active view to given view type.
// Input  : eViewType - 2d xy, xz, 3d textured, flat, etc.
//-----------------------------------------------------------------------------
void CChildFrame::SetViewType(DrawType_t eViewType)
{
	CMapView *pNewView = NULL;
	
	switch (eViewType)
	{
		case VIEW2D_XY:
		case VIEW2D_XZ:
		case VIEW2D_YZ:
			pNewView = (CMapView2D *)ReplaceView(RUNTIME_CLASS(CMapView2D));
			break;

		case VIEW_LOGICAL:
			pNewView = (CMapViewLogical *)ReplaceView(RUNTIME_CLASS(CMapViewLogical));
			break;

		default:
		case VIEW3D_WIREFRAME:
		case VIEW3D_POLYGON:
		case VIEW3D_TEXTURED:
		case VIEW3D_TEXTURED_SHADED:
		case VIEW3D_LIGHTMAP_GRID:
		case VIEW3D_LIGHTING_PREVIEW2:
		case VIEW3D_LIGHTING_PREVIEW_RAYTRACED:
		case VIEW3D_SMOOTHING_GROUP:
		//case VIEW3D_ENGINE:
			pNewView = (CMapView3D *)ReplaceView(RUNTIME_CLASS(CMapView3D));
			break;
	}

	if (pNewView != NULL)
	{
		SetActiveView( dynamic_cast<CView*>(pNewView->GetViewWnd()) );
		pNewView->SetDrawType(eViewType);
		pNewView->UpdateView( MAPVIEW_UPDATE_OBJECTS );
	}
}
Пример #14
0
//-----------------------------------------------------------------------------
// Purpose: Overloaded to handle the 2x2 splitter. If the splitter is enabled,
//			the splitter window is createed and one 3D view and three 2D views
//			are added to it.
// Input  : lpcs - 
//			pContext - 
// Output : Returns TRUE on success, FALSE on failure.
//-----------------------------------------------------------------------------
BOOL CChildFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext *pContext)
{
	//
	// If we are using the splitter, create the splitter and 4 views.
	//
	if (bUsingSplitter)
	{
		m_wndSplitter = new CMySplitterWnd;
		Assert(m_wndSplitter != NULL);
		
		if (m_wndSplitter == NULL)
		{
			return(FALSE);
		}

		if (!m_wndSplitter->CreateStatic(this, 2, 2))
		{
			delete m_wndSplitter;
			m_wndSplitter = NULL;
			TRACE0("Failed to create split bar ");
			return(FALSE);
		}
		
		//
		// Calculate the size of each view within the splitter,
		//
		CRect r;
		GetClientRect(r);
		CSize sizeView((r.Width() / 2) - 3, (r.Height() / 2) - 3);

		//
		// Create the 4 views as they were when the user last closed the app.
		//
		DrawType_t eDrawType[2][2];

		eDrawType[0][0] = (DrawType_t)APP()->GetProfileInt("Splitter", "DrawType0,0", VIEW3D_WIREFRAME);
		eDrawType[0][1] = (DrawType_t)APP()->GetProfileInt("Splitter", "DrawType0,1", VIEW2D_XY);
		eDrawType[1][0] = (DrawType_t)APP()->GetProfileInt("Splitter", "DrawType1,0", VIEW2D_YZ);
		eDrawType[1][1] = (DrawType_t)APP()->GetProfileInt("Splitter", "DrawType1,1", VIEW2D_XZ);

		for (int nRow = 0; nRow < 2; nRow++)
		{
			for (int nCol = 0; nCol < 2; nCol++)
			{
				// These might be lying around in people's registry.
				if ((eDrawType[nRow][nCol] == VIEW3D_ENGINE) || (eDrawType[nRow][nCol] >= VIEW_TYPE_LAST))
				{
					eDrawType[nRow][nCol] = VIEW3D_TEXTURED;
				}
			
				switch (eDrawType[nRow][nCol])
				{
					case VIEW2D_XY:
					case VIEW2D_XZ:
					case VIEW2D_YZ:
					{
						m_wndSplitter->CreateView(nRow, nCol, RUNTIME_CLASS(CMapView2D), sizeView, pContext);
						break;
					}

					case VIEW_LOGICAL:
					{
						m_wndSplitter->CreateView(nRow, nCol, RUNTIME_CLASS(CMapViewLogical), sizeView, pContext);
						break;
					}

					case VIEW3D_WIREFRAME:
					case VIEW3D_POLYGON:
					case VIEW3D_TEXTURED:
					case VIEW3D_TEXTURED_SHADED:
					case VIEW3D_LIGHTMAP_GRID:
					case VIEW3D_LIGHTING_PREVIEW2:
					case VIEW3D_LIGHTING_PREVIEW_RAYTRACED:
					case VIEW3D_SMOOTHING_GROUP:
					{
						m_wndSplitter->CreateView(nRow, nCol, RUNTIME_CLASS(CMapView3D), sizeView, pContext);
						break;
					}
				}

				CMapView *pView = dynamic_cast<CMapView*>(m_wndSplitter->GetPane(nRow, nCol));
				if (pView != NULL)
				{
					pView->SetDrawType(eDrawType[nRow][nCol]);
				}
			}
		}
		
		int nWidth = APP()->GetProfileInt("Splitter", "SplitterWidth", -1);
		int nHeight = APP()->GetProfileInt("Splitter", "SplitterHeight", -1);

		if ( nWidth != -1 && nHeight != -1 )
		{
			m_wndSplitter->SetRowInfo( 0, nHeight, 0 );
			m_wndSplitter->SetColumnInfo( 0, nWidth, 0 );
			m_wndSplitter->RecalcLayout();
		}
		else
		{
			m_bNeedsCentered = TRUE;
		}

        m_bReady = TRUE;
		return TRUE;
	}

	//
	// No splitter, call default creation code.
	//
	return(CMDIChildWnd::OnCreateClient(lpcs, pContext));
}
Пример #15
0
void CMapWidget::showContextMenu(Q3PopupMenu *menu)
{
  CMapView *view = mapManager->getActiveView();
  CMapElement *el = view->getSelectedElement();
  popupMenu(el, menu, selectedPos);
}
Пример #16
0
//-----------------------------------------------------------------------------
// Purpose: Overloaded to handle the 2x2 splitter. If the splitter is enabled,
//			the splitter window is createed and one 3D view and three 2D views
//			are added to it.
// Input  : lpcs - 
//			pContext - 
// Output : Returns TRUE on success, FALSE on failure.
//-----------------------------------------------------------------------------
BOOL CChildFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext *pContext)
{
	//
	// If we are using the splitter, create the splitter and 4 views.
	//
	if (bUsingSplitter)
	{
		m_wndSplitter = new CMySplitterWnd;
		ASSERT(m_wndSplitter != NULL);
		
		if (m_wndSplitter == NULL)
		{
			return(FALSE);
		}

		if (!m_wndSplitter->CreateStatic(this, 2, 2))
		{
			delete m_wndSplitter;
			m_wndSplitter = NULL;
			TRACE0("Failed to create split bar ");
			return(FALSE);
		}
		
		//
		// Calculate the size of each view within the splitter,
		//
		CRect r;
		GetClientRect(r);
		CSize sizeView((r.Width() / 2) - 3, (r.Height() / 2) - 3);

		//
		// Create the 4 views as they were when the user last closed the app.
		//
		DrawType_t eDrawType[2][2];

		eDrawType[0][0] = (DrawType_t)APP()->GetProfileInt("Splitter", "DrawType0,0", VIEW3D_WIREFRAME);
		eDrawType[0][1] = (DrawType_t)APP()->GetProfileInt("Splitter", "DrawType0,1", VIEW2D_XY);
		eDrawType[1][0] = (DrawType_t)APP()->GetProfileInt("Splitter", "DrawType1,0", VIEW2D_YZ);
		eDrawType[1][1] = (DrawType_t)APP()->GetProfileInt("Splitter", "DrawType1,1", VIEW2D_XZ);

		for (int nRow = 0; nRow < 2; nRow++)
		{
			for (int nCol = 0; nCol < 2; nCol++)
			{
				switch (eDrawType[nRow][nCol])
				{
					case VIEW2D_XY:
					case VIEW2D_XZ:
					case VIEW2D_YZ:
					{
						m_wndSplitter->CreateView(nRow, nCol, RUNTIME_CLASS(CMapView2D), sizeView, pContext);
						break;
					}

					case VIEW3D_WIREFRAME:
					case VIEW3D_POLYGON:
					case VIEW3D_TEXTURED:
					case VIEW3D_LIGHTMAP_GRID:
					case VIEW3D_LIGHTING_PREVIEW:
					case VIEW3D_SMOOTHING_GROUP:
					{
						m_wndSplitter->CreateView(nRow, nCol, RUNTIME_CLASS(CMapView3D), sizeView, pContext);
						break;
					}
				}

				CMapView *pView = (CMapView *)m_wndSplitter->GetPane(nRow, nCol);
				if (pView != NULL)
				{
					pView->SetDrawType(eDrawType[nRow][nCol]);
				}
			}
		}

		m_bReady = TRUE;

		return TRUE;
	}

	//
	// No splitter, call default creation code.
	//
	return(CMDIChildWnd::OnCreateClient(lpcs, pContext));
}