/// <summary> ///Initialize a viewer /// </summary> /// <param name="theWnd">System.IntPtr that contains the window handle (HWND) of the control</param> bool InitViewer() { myGraphicDriver() = new D3DHost_GraphicDriver(); myGraphicDriver()->ChangeOptions().buffersNoSwap = true; //myGraphicDriver()->ChangeOptions().contextDebug = true; TCollection_ExtendedString a3DName ("Visu3D"); myViewer() = new V3d_Viewer (myGraphicDriver(), a3DName.ToExtString(), "", 1000.0, V3d_XposYnegZpos, Quantity_NOC_GRAY30, V3d_ZBUFFER, V3d_GOURAUD, V3d_WAIT, Standard_True, Standard_False); myViewer()->SetDefaultLights(); myViewer()->SetLightOn(); myView() = myViewer()->CreateView(); static Handle(WNT_WClass) aWClass = new WNT_WClass ("OCC_Viewer", NULL, CS_OWNDC); Handle(WNT_Window) aWNTWindow = new WNT_Window ("OCC_Viewer", aWClass, WS_POPUP, 64, 64, 64, 64); aWNTWindow->SetVirtual (Standard_True); myView()->SetWindow(aWNTWindow); myAISContext() = new AIS_InteractiveContext (myViewer()); myAISContext()->UpdateCurrentViewer(); myView()->MustBeResized(); return true; }
QMcCad_Viewer::QMcCad_Viewer(QMcCad_Editor* theEditor) { myEditor = theEditor; myIsConfigured = false; Standard_ExtString aName, cName; TCollection_ExtendedString a3DName("Visu3D"); TCollection_ExtendedString collectorName("Collector"); aName=a3DName.ToExtString(); cName=collectorName.ToExtString(); Standard_CString aDomain("McCad"); myViewer = MakeCasViewer(getenv("DISPLAY"), aName, aDomain, 1000.0, V3d_XposYnegZpos, Standard_True, Standard_True); // McCadAEV_Viewer... myCollector = MakeCasViewer(getenv("DISPLAY"), cName, aDomain, 1000.0, V3d_XposYnegZpos, Standard_True, Standard_True); myViewer->Init(); myViewer->SetDefaultLights(); myViewer->SetLightOn(); /*myViewer->ActivateGrid(Aspect_GT_Rectangular, Aspect_GDM_Lines); Standard_Real theW, theH; cout << theW << " " << theH << endl; myView->View()->Size(theW, theH); myViewer->SetRectangularGridGraphicValues(theW + 200, theH + 200, 0);*/ // myViewer->SetDefaultVisualization(V3d_WIREFRAME); myContext = new AIS_InteractiveContext(myViewer, myCollector); myContext->SetHilightColor(Quantity_NOC_HOTPINK); //myContext->SelectionColor(Quantity_NOC_PURPLE); myContext->SelectionColor(Quantity_NOC_YELLOW); //make output look a little more smooth //no good performance for more complex models //in a later version the user should be able to set resolution as high/low as is neccessary for the system in use myContext->SetDeviationAngle(myContext->DeviationAngle() / 4.5); myContext->SetDeviationCoefficient(myContext->DeviationCoefficient() / 4.5); // Lei lu 25.11.2013 //myContext->CloseAllContexts(); //myContext->OpenLocalContext(); //myContext->ActivateStandardMode(TopAbs_FACE); //myContext->SetHLRDeviationCoefficient(myContext->HLRDeviationCoefficient() / 4.5); * //myContext->SetHLRAngle(myContext->HLRAngle() / 4.5); }
QoccViewerContext::QoccViewerContext() { // Create the OCC Viewers TCollection_ExtendedString a3DName("Visual3D"); myViewer = createViewer( "DISPLAY", a3DName.ToExtString(), "", 1000.0 ); myViewer->Init(); myViewer->SetZBufferManagment(Standard_False); myViewer->SetDefaultViewProj( V3d_Zpos ); // Top view myContext = new AIS_InteractiveContext( myViewer ); myGridType = Aspect_GT_Rectangular; myGridMode = Aspect_GDM_Lines; myGridColor = Quantity_NOC_RED4; myGridTenthColor = Quantity_NOC_GRAY90; myContext->SetHilightColor(Quantity_NOC_WHITE) ; setGridOffset (0.0); gridXY(); //gridToggle(); }
CHLRDoc::CHLRDoc() { // TODO: add one-time construction code here Handle(Graphic3d_WNTGraphicDevice) theGraphicDevice = ((CHLRApp*)AfxGetApp())->GetGraphicDevice(); TCollection_ExtendedString a3DName("Visu3D"); myViewer = new V3d_Viewer(theGraphicDevice,a3DName.ToExtString(),"", 1000.0, V3d_XposYnegZpos, Quantity_NOC_GRAY30, V3d_ZBUFFER,V3d_GOURAUD,V3d_WAIT, Standard_True, Standard_False); /* Handle(V3d_Viewer) myViewerCollector; myViewerCollector = new V3d_Viewer(theGraphicDevice,a3DName.ToExtString(),"", 1000.0, V3d_XposYnegZpos, Quantity_NOC_GRAY30, V3d_ZBUFFER,V3d_GOURAUD,V3d_WAIT, Standard_True, Standard_False); */ myViewer->SetDefaultLights(); myViewer->SetLightOn(); //myAISContext =new AIS_InteractiveContext(myViewer,myViewerCollector); myAISContext =new AIS_InteractiveContext(myViewer); // VIEWER 2D TCollection_ExtendedString a2DName("Visu2D"); my2DViewer = new V2d_Viewer(theGraphicDevice,a2DName.ToExtString()); my2DViewer->SetCircularGridValues(0,0,10,8,0); my2DViewer->SetRectangularGridValues(0,0,10,10,0); myInteractiveContext2D= new ISession2D_InteractiveContext(my2DViewer); CFrameWnd* pFrame2d=((CHLRApp*)AfxGetApp())->CreateView2D(this); pFrame2d->ShowWindow(SW_SHOWNORMAL/*SW_MINIMIZE*/); // update the Maps : // entries are reserve for utilisation : // - 1 for Visible edges HighLighted // - 2 for Visible edges // - 3 for Hidden edges HighLighted // - 4 for Hidden edges Handle(Aspect_GenericColorMap) aColorMap= Handle(Aspect_GenericColorMap)::DownCast(my2DViewer->ColorMap()); ASSERT(!aColorMap.IsNull()); aColorMap->AddEntry(Aspect_ColorMapEntry (1,Quantity_Color(Quantity_NOC_RED ))); // in fact just update aColorMap->AddEntry(Aspect_ColorMapEntry (2,Quantity_Color(Quantity_NOC_WHITE))); // in fact just update aColorMap->AddEntry(Aspect_ColorMapEntry (3,Quantity_Color(Quantity_NOC_RED ))); // in fact just update aColorMap->AddEntry(Aspect_ColorMapEntry (4,Quantity_Color(Quantity_NOC_BLUE1))); // in fact just update my2DViewer->SetColorMap(aColorMap); Handle(Aspect_WidthMap) aWidthMap = my2DViewer->WidthMap(); aWidthMap->AddEntry(Aspect_WidthMapEntry(1,0.8)); // in fact just update aWidthMap->AddEntry(Aspect_WidthMapEntry(2,0.4)); // in fact just update aWidthMap->AddEntry(Aspect_WidthMapEntry(3,0.6)); // in fact just update aWidthMap->AddEntry(Aspect_WidthMapEntry(4,0.2)); // in fact just update my2DViewer->SetWidthMap(aWidthMap); Handle(Aspect_TypeMap) aTypeMap = my2DViewer->TypeMap(); aTypeMap->AddEntry(Aspect_TypeMapEntry(1,Aspect_LineStyle(Aspect_TOL_SOLID))); aTypeMap->AddEntry(Aspect_TypeMapEntry(2,Aspect_LineStyle(Aspect_TOL_SOLID))); TColQuantity_Array1OfLength anArray(1,2); anArray(1) = 0.5; anArray(2) = 0.5; aTypeMap->AddEntry(Aspect_TypeMapEntry(3,Aspect_LineStyle(anArray))); aTypeMap->AddEntry(Aspect_TypeMapEntry(4,Aspect_LineStyle(anArray))); my2DViewer->SetTypeMap(aTypeMap); myCSelectionDialogIsCreated=false; }
OccView::OccView(QWidget *parent) : QWidget(parent) { Handle_Aspect_DisplayConnection aDisplayConnection; Handle_OpenGl_GraphicDriver aGraphicDriver; // 1. Create a 3D viewer. aDisplayConnection = new Aspect_DisplayConnection (qgetenv ("DISPLAY").constData()); aGraphicDriver = new OpenGl_GraphicDriver(aDisplayConnection); mViewer = new V3d_Viewer(aGraphicDriver, Standard_ExtString("Visu3D")); mViewer->SetDefaultLights(); mViewer->SetLightOn(); // 3. Create an interactive context. mContext = new AIS_InteractiveContext(mViewer); mContext->SetDisplayMode(AIS_Shaded); if ( mView.IsNull() ) mView = mContext->CurrentViewer()->CreateView(); Handle(OcctWindow) hWnd = new OcctWindow( this ); mView->SetWindow (hWnd); if ( !hWnd->IsMapped() ) { hWnd->Map(); } // mView->SetBackgroundColor (Quantity_NOC_BLACK); mView->MustBeResized(); //Eixo x, y, z mView->TriedronDisplay(Aspect_TOTP_LEFT_LOWER, Quantity_NOC_GOLD, 0.08, V3d_ZBUFFER); #if 0 Handle(OpenGl_GraphicDriver) aGraphicDriver; if(aGraphicDriver.IsNull()) { Handle(Aspect_DisplayConnection) aDisplayConnection; aGraphicDriver = new OpenGl_GraphicDriver(aDisplayConnection); } TCollection_ExtendedString a3DName ("Visu3D"); mViewer = new V3d_Viewer (aGraphicDriver, a3DName.ToExtString(), "", 1000.0, V3d_XposYnegZpos, Quantity_NOC_GRAY30, V3d_ZBUFFER, V3d_GOURAUD, V3d_WAIT, Standard_True, Standard_True, V3d_TEX_NONE); mViewer->SetDefaultLights(); mViewer->SetLightOn(); mContext = new AIS_InteractiveContext(mViewer); if ( mView.IsNull() ) mView = mContext->CurrentViewer()->CreateView(); Handle(OcctWindow) hWnd = new OcctWindow( this ); mView->SetWindow (hWnd); if ( !hWnd->IsMapped() ) { hWnd->Map(); } mView->SetBackgroundColor(Quantity_NOC_BLACK); mView->MustBeResized(); #endif }