Beispiel #1
0
bool WidgetBase::IsSelectionCopyCompatible (
    ViewNumber::Enum vn, ViewNumber::Enum otherVn) const
{
    ViewSettings& vs = GetViewSettings (vn);
    ViewSettings& otherVs = GetViewSettings (otherVn);
    return otherVn != vn && 
        vs.GetSimulationIndex () == otherVs.GetSimulationIndex ();
}
Beispiel #2
0
bool WidgetBase::IsColorMapScalarCopyCompatible (
    ViewNumber::Enum vn, ViewNumber::Enum otherVn) const
{
    ColorMapScalarType::Enum currentColorBarType = 
        GetSettings ().GetColorMapScalarType (vn);
    const ViewSettings& vs = GetViewSettings (vn);
    const ViewSettings& otherVs = GetViewSettings (otherVn);
    size_t currentProperty = vs.GetBodyOrOtherScalar ();
    return otherVn != vn &&
        
        currentColorBarType == GetSettings ().GetColorMapScalarType (otherVn) &&
        
        ((currentColorBarType == ColorMapScalarType::T1_KDE) 
         ||
         currentProperty == otherVs.GetBodyOrOtherScalar ());
}
Beispiel #3
0
void WidgetBase::infoFoam ()
{
    const ViewSettings& vs = GetViewSettings ();
    ostringstream ostr;
    ostr << GetFoam ().GetInfo () << endl 
         << GetSimulation ().GetT1Info (GetTime (), vs.T1sShiftLower ());
    ShowMessageBox (m_widget, ostr.str ().c_str ());
}
Beispiel #4
0
G3D::Matrix3 WidgetBase::GetRotationForAxisOrder (ViewNumber::Enum viewNumber, 
                                                  size_t timeStep) const
{
    const ViewSettings& vs = GetViewSettings (viewNumber);
    const Simulation& simulation = GetSimulation (viewNumber);
    const Foam& foam = simulation.GetFoam (timeStep);
    return vs.GetRotationForAxisOrder (foam);
}
Beispiel #5
0
void WidgetBase::contextMenuEventColorMapVelocity (QMenu* menu) const
{
    menu->addAction (m_actionColorMapVelocityClampClear.get ());
    addCopyCompatibleMenu (menu, "Copy", &m_actionColorMapVelocityCopy[0], 
                           &WidgetBase::IsColorMapVelocityCopyCompatible);
    if (GetViewSettings ().GetBodyOrOtherScalar () == 
        BodyScalar::VELOCITY_MAGNITUDE)
        menu->addAction (m_actionColorMapVelocityCopyVelocityMagnitude.get ());
    menu->addAction (m_actionColorMapVelocityEdit.get ());
}
Beispiel #6
0
void WidgetBase::ResetTransformFocus ()
{
    vector<ViewNumber::Enum> vn = GetSettings ().GetTwoHalvesViewNumbers ();
    for (size_t i = 0; i < vn.size (); ++i)
    {
	ViewNumber::Enum viewNumber = vn[i];
	ViewSettings& vs = GetViewSettings (viewNumber);
	vs.SetRotation (G3D::Matrix3::identity ());
	vs.SetScaleRatio (1);
	vs.SetTranslation (G3D::Vector3::zero ());
    }
}
Beispiel #7
0
void CAddinApp::OnCommand(UINT id)
{
	switch (id)
	{
	case ID_ShowSheetWindow:
		{
			IVWindowPtr window = GetValidActiveWindow(visDrawing);

			if (!window)
				return;

			ShowShapeSheetWatchWindow(window, !IsShapeSheetWatchWindowShown(window));
			break;
		}

	case ID_AddWatch:
		{
			IVWindowPtr sheet_window = GetValidActiveWindow(visSheet);

			if (!sheet_window)
				return;

			IVCellPtr selected_cell = sheet_window->GetSelectedCell();
			if (selected_cell)
			{
				IVWindowPtr window = FindDocumentWindow(selected_cell);

				if (window)
				{
					CVisioFrameWnd* wnd = 
						ShowShapeSheetWatchWindow(window, true);

					GetViewSettings()->AddCellMask(selected_cell->Name);
					UpdateViews(UpdateOption_Hilight|UpdateOption_UseKey);
				}
			}
		}
	}
}
Beispiel #8
0
void WidgetBase::contextMenuEvent (QContextMenuEvent *event)
{
    QMenu menu (m_widget);
    ViewNumber::Enum viewNumber = GetViewNumber ();
    const ViewSettings& vs = GetViewSettings (viewNumber);
    size_t property = vs.GetBodyOrOtherScalar ();
    QPoint contextMenuPosWindow = event->pos ();
    if (vs.IsScalarShown () && property != OtherScalar::DMP_COLOR && 
        ! vs.IsScalarContext () && 
        GetSettings ().GetColorMapScalarRectWithLabels (
            viewNumber, GetViewRect ()).contains (
                QtToOpenGl (contextMenuPosWindow, m_widget->height ())))
	contextMenuEventColorMapScalar (&menu);
    else if (vs.IsVelocityShown () &&
             GetSettings ().GetColorMapVelocityRectWithLabels (
                 viewNumber, GetViewRect ()).contains (
                     QtToOpenGl (contextMenuPosWindow, m_widget->height ())))
        contextMenuEventColorMapVelocity (&menu);
    else
	contextMenuEventView (&menu);
    menu.exec (event->globalPos());
}
Beispiel #9
0
bool VMFExporter::ExportVMF( CMapLayout* pLayout, const char *mapname, bool bPopupWarnings )
{
    m_bPopupWarnings = bPopupWarnings;

    Init();

    m_pMapLayout = pLayout;

    if ( pLayout->m_PlacedRooms.Count() <= 0 )
    {
        Q_snprintf( m_szLastExporterError, sizeof(m_szLastExporterError), "Failed to export: No rooms placed in the map layout!\n" );
        return false;
    }

    // see if we have a start room
    bool bHasStartRoom = false;
    for ( int i = 0 ; i < pLayout->m_PlacedRooms.Count() ; i++ )
    {
        if ( pLayout->m_PlacedRooms[i]->m_pRoomTemplate->IsStartRoom() )
        {
            int half_map_size = MAP_LAYOUT_TILES_WIDE * 0.5f;		// shift back so the middle of our grid is the origin
            m_vecStartRoomOrigin.x = ( pLayout->m_PlacedRooms[i]->m_iPosX - half_map_size ) * ASW_TILE_SIZE;
            m_vecStartRoomOrigin.y = ( pLayout->m_PlacedRooms[i]->m_iPosY - half_map_size ) * ASW_TILE_SIZE;
            bHasStartRoom = true;
            break;
        }
    }
    LoadUniqueKeyList();

    m_iNextNodeID = 0;

    m_pExportKeys = new KeyValues( "ExportKeys" );

    m_pExportKeys->AddSubKey( GetVersionInfo() );
    m_pExportKeys->AddSubKey( GetDefaultVisGroups() );
    m_pExportKeys->AddSubKey( GetViewSettings() );
    m_pExportWorldKeys = GetDefaultWorldChunk();
    if ( !m_pExportWorldKeys )
    {
        Q_snprintf( m_szLastExporterError, sizeof(m_szLastExporterError), "Failed to save world chunk start\n");
        return false;
    }
    m_pExportKeys->AddSubKey( m_pExportWorldKeys );


    // save out the big cube the whole level sits in
    if ( !AddLevelContainer() )
    {
        Q_snprintf( m_szLastExporterError, sizeof(m_szLastExporterError), "Failed to save level container\n");
        return false;
    }

    if ( tilegen_use_instancing.GetBool() )
    {
        int nLogicalRooms = m_pMapLayout->m_LogicalRooms.Count();
        int nPlacedRooms = m_pMapLayout->m_PlacedRooms.Count();

        m_pRoom = NULL;
        for ( int i = 0; i < nLogicalRooms; ++ i )
        {
            AddRoomInstance( m_pMapLayout->m_LogicalRooms[i] );
        }

        for ( int i = 0; i < nPlacedRooms; ++ i )
        {
            m_pRoom = m_pMapLayout->m_PlacedRooms[i];
            AddRoomInstance( m_pRoom->m_pRoomTemplate, i );
        }
    }
    else
    {
        // write out logical room solids
        int iLogicalRooms = m_pMapLayout->m_LogicalRooms.Count();
        m_pRoom = NULL;
        for ( int i = 0 ; i < iLogicalRooms ; i++ )
        {
            // start logical room IDs at 5000 (assumes we'll never place 5000 real rooms)
            m_iCurrentRoom = 5000 + i;
            CRoomTemplate *pRoomTemplate = m_pMapLayout->m_LogicalRooms[i];
            if ( !pRoomTemplate )
                continue;

            if ( !AddRoomTemplateSolids( pRoomTemplate ) )
                return false;
        }

        // go through each CRoom and write out its world solids
        int iRooms = m_pMapLayout->m_PlacedRooms.Count();
        for ( m_iCurrentRoom = 0 ; m_iCurrentRoom<iRooms ; m_iCurrentRoom++)
        {
            m_pRoom = m_pMapLayout->m_PlacedRooms[m_iCurrentRoom];
            if (!m_pRoom)
                continue;
            const CRoomTemplate *pRoomTemplate = m_pRoom->m_pRoomTemplate;
            if (!pRoomTemplate)
                continue;

            if ( !AddRoomTemplateSolids( pRoomTemplate ) )
                return false;
        }

        // write out logical room entities
        m_pRoom = NULL;
        for ( int i = 0 ; i < iLogicalRooms ; i++ )
        {
            // start logical room IDs at 5000 (assumes we'll never place 5000 real rooms)
            m_iCurrentRoom = 5000 + i;
            CRoomTemplate *pRoomTemplate = m_pMapLayout->m_LogicalRooms[i];
            if ( !pRoomTemplate )
                continue;

            if ( !AddRoomTemplateEntities( pRoomTemplate ) )
                return false;
        }

        // go through each CRoom and add its entities
        for ( m_iCurrentRoom = 0 ; m_iCurrentRoom<iRooms ; m_iCurrentRoom++)
        {
            m_pRoom = m_pMapLayout->m_PlacedRooms[m_iCurrentRoom];
            if (!m_pRoom)
                continue;
            const CRoomTemplate *pRoomTemplate = m_pRoom->m_pRoomTemplate;
            if (!pRoomTemplate)
                continue;

            if ( !AddRoomTemplateEntities( pRoomTemplate ) )
                return false;
        }
    }

    // add some player starts to the map in the tile the user selected
    if ( !bHasStartRoom )
    {
        m_pExportKeys->AddSubKey( GetPlayerStarts() );
    }

    m_pExportKeys->AddSubKey( GetGameRulesProxy() );
    m_pExportKeys->AddSubKey( GetDefaultCamera() );

    // save out the export keys
    char filename[512];
    Q_snprintf( filename, sizeof(filename), "maps\\%s", mapname );
    Q_SetExtension( filename, "vmf", sizeof( filename ) );
    CUtlBuffer buf( 0, 0, CUtlBuffer::TEXT_BUFFER );
    for ( KeyValues *pKey = m_pExportKeys->GetFirstSubKey(); pKey; pKey = pKey->GetNextKey() )
    {
        pKey->RecursiveSaveToFile( buf, 0 );
    }
    if ( !g_pFullFileSystem->WriteFile( filename, "GAME", buf ) )
    {
        Msg( "Failed to SaveToFile %s\n", filename );
        return false;
    }

    // save the map layout there (so the game can get information about rooms during play)
    Q_snprintf( filename, sizeof( filename ), "maps\\%s", mapname );
    Q_SetExtension( filename, "layout", sizeof( filename ) );
    if ( !m_pMapLayout->SaveMapLayout( filename ) )
    {
        Q_snprintf( m_szLastExporterError, sizeof(m_szLastExporterError), "Failed to save .layout file\n");
        return false;
    }

    return true;
}