00001 00002 // exotkAF_View.cxx 00004 // Copyright (C) 2001 Stephane Routelous 00005 // 00006 // This file is part of exoTK. 00007 // 00008 // exoTK is free software; you can redistribute it and/or modify 00009 // it under the terms of the GNU General Public License as published by 00010 // the Free Software Foundation; either version 2 of the License, or 00011 // (at your option) any later version. 00012 // 00013 // exoTK is distributed in the hope that it will be useful, 00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 // GNU General Public License for more details. 00017 // 00018 // You should have received a copy of the GNU General Public License 00019 // along with exoTK; if not, write to the Free Software 00020 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00022 00027 #include <exotkAF_View.hxx> 00028 #ifndef _exotkAF_CurrentActionMode_HeaderFile 00029 #include <exotkAF_CurrentActionMode.hxx> 00030 #endif 00031 #ifndef _V3d_View_HeaderFile 00032 #include <V3d_View.hxx> 00033 #endif 00034 #ifndef _exotkAF_Document_HeaderFile 00035 #include <exotkAF_Document.hxx> 00036 #endif 00037 #ifndef _exotkAIS_DisplayManager_HeaderFile 00038 #include <exotkAIS_DisplayManager.hxx> 00039 #endif 00040 #ifndef _AIS_InteractiveContext_HeaderFile 00041 #include <AIS_InteractiveContext.hxx> 00042 #endif 00043 #ifndef _exotkAIS_GraphicDevice_HeaderFile 00044 #include <exotkAIS_GraphicDevice.hxx> 00045 #endif 00046 #ifndef _WNT_Window_HeaderFile 00047 #include <WNT_Window.hxx> 00048 #endif 00049 #ifndef _exotkAF_ViewType_HeaderFile 00050 #include <exotkAF_ViewType.hxx> 00051 #endif 00052 #ifndef _exotkTree_Menu_HeaderFile 00053 #include <exotkTree_Menu.hxx> 00054 #endif 00055 #ifndef _exotkTree_MenuNode_HeaderFile 00056 #include <exotkTree_MenuNode.hxx> 00057 #endif 00058 #ifndef _exotkTree_Separator_HeaderFile 00059 #include <exotkTree_Separator.hxx> 00060 #endif 00061 #ifndef _Graphic3d_WNTGraphicDevice_HeaderFile 00062 #include <Graphic3d_WNTGraphicDevice.hxx> 00063 #endif 00064 #ifndef _exotkAF_ViewPopup_HeaderFile 00065 #include <exotkAF_ViewPopup.hxx> 00066 #endif 00067 #ifndef _exotkAIS_InteractiveObjectPopup_HeaderFile 00068 #include <exotkAIS_InteractiveObjectPopup.hxx> 00069 #endif 00070 00071 #ifndef _Standard_DefineHandle_HeaderFile 00072 #include <Standard_DefineHandle.hxx> 00073 #endif 00074 // 00075 IMPLEMENT_STANDARD_HANDLE(exotkAF_View, MMgt_TShared) 00076 IMPLEMENT_STANDARD_RTTI(exotkAF_View, MMgt_TShared) 00077 // 00078 // Foreach ancestors, we add a IMPLEMENT_STANDARD_SUPERTYPE and 00079 // a IMPLEMENT_STANDARD_SUPERTYPE_ARRAY_ENTRY macro. 00080 // We must respect the order: from the direct ancestor class 00081 // to the base class. 00082 // 00083 00084 IMPLEMENT_STANDARD_TYPE(exotkAF_View) 00085 IMPLEMENT_STANDARD_SUPERTYPE(MMgt_TShared) 00086 IMPLEMENT_STANDARD_SUPERTYPE(Standard_Transient) 00087 IMPLEMENT_STANDARD_SUPERTYPE_ARRAY() 00088 IMPLEMENT_STANDARD_SUPERTYPE_ARRAY_ENTRY(MMgt_TShared) 00089 IMPLEMENT_STANDARD_SUPERTYPE_ARRAY_ENTRY(Standard_Transient) 00090 IMPLEMENT_STANDARD_SUPERTYPE_ARRAY_END() 00091 IMPLEMENT_STANDARD_TYPE_END(exotkAF_View) 00092 00093 //================================================================================== 00094 // Function name : exotkAF_View::exotkAF_View 00095 //================================================================================== 00096 // Written by : Stephane Routelous - 2001-11-06 16:09:19 00097 // Description : 00098 // Return type : 00099 //================================================================================== 00100 exotkAF_View::exotkAF_View() 00101 :myCurrentXMousePosition(0) 00102 , myCurrentYMousePosition(0) 00103 , mySavedXMousePosition(0) 00104 , mySavedYMousePosition(0) 00105 , myInitialXMousePosition(0) 00106 , myInitialYMousePosition(0) 00107 , myCtrlPushed(Standard_False) 00108 , myShiftPushed(Standard_False) 00109 , myIsDragging(Standard_False) 00110 , myCurrentActionMode(exotkAF_camNothing) 00111 , myCurrentMouseButton(exotkAF_mbNone) 00112 , myAntialiasingIsOn(Standard_False) 00113 , myIsHiddenLine(Standard_False) 00114 { 00115 } 00116 00117 00118 //================================================================================== 00119 // Function name : exotkAF_View::~exotkAF_View 00120 //================================================================================== 00121 // Written by : Stephane Routelous - 2001-11-06 16:09:21 00122 // Description : 00123 // Return type : 00124 //================================================================================== 00125 exotkAF_View::~exotkAF_View() 00126 { 00127 if (!myView.IsNull()) 00128 myView->Remove(); 00129 } 00130 00131 //================================================================================== 00132 // Function name : exotkAF_View::SetDocument 00133 //================================================================================== 00134 // Written by : Stephane Routelous - 2001-11-06 16:09:23 00135 // Description : 00136 // Return type : void 00137 //================================================================================== 00138 // Argument : const Handle_exotkAF_Document& aDocument 00139 void exotkAF_View::SetDocument(const Handle_exotkAF_Document& aDocument) 00140 { 00141 myDocument = aDocument; 00142 } 00143 00144 //================================================================================== 00145 // Function name : exotkAF_View::SetCurrentActionMode 00146 //================================================================================== 00147 // Written by : Stephane Routelous - 2001-11-06 16:09:25 00148 // Description : 00149 // Return type : void 00150 //================================================================================== 00151 // Argument : const enum exotkAF_CurrentActionMode aMode 00152 void exotkAF_View::SetCurrentActionMode(const enum exotkAF_CurrentActionMode aMode) 00153 { 00154 switch (aMode) 00155 { 00156 case exotkAF_camMoving: 00157 break; 00158 case exotkAF_camDynamicZooming: 00159 SetDynamicZoomingMode(); 00160 break; 00161 case exotkAF_camWindowZooming: 00162 SetWindowZoomingMode(); 00163 break; 00164 case exotkAF_camDynamicPanning: 00165 SetDynamicPanningMode(); 00166 break; 00167 case exotkAF_camDynamicRotation: 00168 SetDynamicRotationMode(); 00169 break; 00170 default: 00171 case exotkAF_camNothing: 00172 SetNothingMode(); 00173 break; 00174 } 00175 } 00176 00177 //================================================================================== 00178 // Function name : exotkAF_View::CurrentActionMode 00179 //================================================================================== 00180 // Written by : Stephane Routelous - 2002-01-13 23:36:55 00181 // Description : 00182 // Return type : exotkAF_CurrentActionMode 00183 //================================================================================== 00184 exotkAF_CurrentActionMode exotkAF_View::CurrentActionMode() 00185 { 00186 return myCurrentActionMode; 00187 } 00188 //================================================================================== 00189 // Function name : exotkAF_View::SetCurrentMouseButton 00190 //================================================================================== 00191 // Written by : Stephane Routelous - 2001-11-06 16:09:27 00192 // Description : 00193 // Return type : void 00194 //================================================================================== 00195 // Argument : const enum exotkAF_MouseButton aButton 00196 void exotkAF_View::SetCurrentMouseButton(const enum exotkAF_MouseButton aButton) 00197 { 00198 myCurrentMouseButton = aButton; 00199 } 00200 00201 00202 //================================================================================== 00203 // Function name : exotkAF_View::SetNothingMode 00204 //================================================================================== 00205 // Written by : Stephane Routelous - 2001-11-06 16:09:28 00206 // Description : 00207 // Return type : void 00208 //================================================================================== 00209 void exotkAF_View::SetNothingMode() 00210 { 00211 myCurrentActionMode = exotkAF_camNothing; 00212 } 00213 00214 //================================================================================== 00215 // Function name : exotkAF_View::SetDynamicRotationMode 00216 //================================================================================== 00217 // Written by : Stephane Routelous - 2001-11-06 16:09:30 00218 // Description : 00219 // Return type : void 00220 //================================================================================== 00221 void exotkAF_View::SetDynamicRotationMode() 00222 { 00223 myCurrentActionMode = exotkAF_camDynamicRotation; 00224 } 00225 00226 //================================================================================== 00227 // Function name : exotkAF_View::SetDynamicPanningMode 00228 //================================================================================== 00229 // Written by : Stephane Routelous - 2001-11-06 16:09:32 00230 // Description : 00231 // Return type : void 00232 //================================================================================== 00233 void exotkAF_View::SetDynamicPanningMode() 00234 { 00235 myCurrentActionMode = exotkAF_camDynamicPanning; 00236 } 00237 00238 //================================================================================== 00239 // Function name : exotkAF_View::SetWindowZoomingMode 00240 //================================================================================== 00241 // Written by : Stephane Routelous - 2001-11-06 16:09:33 00242 // Description : 00243 // Return type : void 00244 //================================================================================== 00245 void exotkAF_View::SetWindowZoomingMode() 00246 { 00247 myCurrentActionMode = exotkAF_camWindowZooming; 00248 } 00249 00250 //================================================================================== 00251 // Function name : exotkAF_View::SetDynamicZoomingMode 00252 //================================================================================== 00253 // Written by : Stephane Routelous - 2001-11-06 16:09:44 00254 // Description : 00255 // Return type : void 00256 //================================================================================== 00257 void exotkAF_View::SetDynamicZoomingMode() 00258 { 00259 myCurrentActionMode = exotkAF_camDynamicZooming; 00260 } 00261 00262 //================================================================================== 00263 // Function name : exotkAF_View::SetShiftKey 00264 //================================================================================== 00265 // Written by : Stephane Routelous - 2001-11-06 16:09:43 00266 // Description : 00267 // Return type : void 00268 //================================================================================== 00269 // Argument : const Standard_Boolean On 00270 void exotkAF_View::SetShiftKey(const Standard_Boolean On) 00271 { 00272 myShiftPushed = On; 00273 } 00274 00275 //================================================================================== 00276 // Function name : exotkAF_View::SetCtrlKey 00277 //================================================================================== 00278 // Written by : Stephane Routelous - 2001-11-06 16:09:41 00279 // Description : 00280 // Return type : void 00281 //================================================================================== 00282 // Argument : const Standard_Boolean On 00283 void exotkAF_View::SetCtrlKey(const Standard_Boolean On) 00284 { 00285 myCtrlPushed = On; 00286 } 00287 00288 //================================================================================== 00289 // Function name : exotkAF_View::IsPopup 00290 //================================================================================== 00291 // Written by : Stephane Routelous - 2001-11-06 16:09:40 00292 // Description : 00293 // Return type : Standard_Boolean 00294 //================================================================================== 00295 Standard_Boolean exotkAF_View::IsPopup() 00296 { 00297 return (!myCtrlPushed && !myShiftPushed &&(myCurrentMouseButton == exotkAF_mbRight)); 00298 } 00299 00300 //================================================================================== 00301 // Function name : exotkAF_View::IsDragging 00302 //================================================================================== 00303 // Written by : Stephane Routelous - 2001-11-06 16:09:39 00304 // Description : 00305 // Return type : Standard_Boolean 00306 //================================================================================== 00307 Standard_Boolean exotkAF_View::IsDragging() 00308 { 00309 return myIsDragging; 00310 } 00311 00312 //================================================================================== 00313 // Function name : exotkAF_View::Pick 00314 //================================================================================== 00315 // Written by : Stephane Routelous - 2001-11-06 16:09:37 00316 // Description : 00317 // Return type : void 00318 //================================================================================== 00319 // Argument : const exotkAF_MouseButton aButton 00320 void exotkAF_View::Pick(const exotkAF_MouseButton aButton) 00321 { 00322 if (!myView.IsNull()) 00323 { 00324 // saving the mouse state 00325 myCurrentMouseButton = aButton; 00326 00327 mySavedXMousePosition = myCurrentXMousePosition; 00328 mySavedYMousePosition = myCurrentYMousePosition; 00329 myInitialXMousePosition = myCurrentXMousePosition; 00330 myInitialYMousePosition = myCurrentYMousePosition; 00331 00332 if (myCurrentActionMode == exotkAF_camDynamicRotation) 00333 {// dynamic rotation mode : set to HLR Off and start rotation 00334 if (myIsHiddenLine) 00335 myView->SetDegenerateModeOn(); 00336 00337 myView->StartRotation(myCurrentXMousePosition, myCurrentYMousePosition); 00338 } 00339 else if (myCurrentActionMode == exotkAF_camNothing) 00340 { 00341 if (myCurrentMouseButton == exotkAF_mbLeft) 00342 { 00343 // selection 00344 if (myShiftPushed) 00345 // selection with shift -> multiple selection 00346 myDocument->DisplayManager()->InteractiveContext()->ShiftSelect(); 00347 else 00348 // selection withous shift -> single selection ( simple pick ) 00349 myDocument->DisplayManager()->InteractiveContext()->Select(); 00350 } 00351 else if (myCurrentMouseButton == exotkAF_mbRight) 00352 { 00353 if (myCtrlPushed) 00354 { 00355 // Ctrl+Right mouse button = rotation 00356 // set the mode to HiddenLine = Off ( performance improvment ) 00357 // initialize the rotation with StartRotation 00358 if (myIsHiddenLine) 00359 myView->SetDegenerateModeOn(); 00360 myView->StartRotation(myCurrentXMousePosition, myCurrentYMousePosition); 00361 } 00362 } 00363 } 00364 } 00365 } 00366 00367 //================================================================================== 00368 // Function name : exotkAF_View::Release 00369 //================================================================================== 00370 // Written by : Stephane Routelous - 2001-11-06 16:09:49 00371 // Description : 00372 // Return type : void 00373 //================================================================================== 00374 void exotkAF_View::Release() 00375 { 00376 if (!myView.IsNull()) 00377 { 00378 if (myCurrentActionMode == exotkAF_camWindowZooming) 00379 { 00380 // Zoom window mode 00381 00382 // taking the coordinates of the window to zoom 00383 int myXmin = Min(myCurrentXMousePosition, mySavedXMousePosition); 00384 int myXmax = Max(myCurrentXMousePosition, mySavedXMousePosition); 00385 int myYmin = Min(myCurrentYMousePosition, mySavedYMousePosition); 00386 int myYmax = Max(myCurrentYMousePosition, mySavedYMousePosition); 00387 00388 // Test if the zoom window is greater than a minimale window. (2x2) 00389 if ((abs(myXmin - myXmax)>2) ||(abs(myYmin - myYmax)>2)) 00390 { 00391 // Do the zoom window between Point_min and Point_max 00392 myView->WindowFitAll(myXmin, myYmin, myXmax, myYmax); 00393 } 00394 } 00395 // not dragging anymore 00396 myIsDragging = false; 00397 00398 // set the HiddenLine Status to what it was before Rotation 00399 SetHiddenLine(myIsHiddenLine); 00400 00401 // no more buttons are pushed 00402 myCurrentMouseButton = exotkAF_mbNone; 00403 00404 // release the CurrentMode 00405 SetNothingMode(); 00406 Redraw(); 00407 } 00408 } 00409 00410 //================================================================================== 00411 // Function name : exotkAF_View::Move 00412 //================================================================================== 00413 // Written by : Stephane Routelous - 2001-11-06 16:09:52 00414 // Description : 00415 // Return type : exotkAF_CurrentActionMode 00416 //================================================================================== 00417 // Argument : const Standard_Integer x 00418 // Argument : const Standard_Integer y 00419 exotkAF_CurrentActionMode exotkAF_View::Move(const Standard_Integer x, const Standard_Integer y) 00420 { 00421 if (myView.IsNull()) 00422 return exotkAF_camNothing; 00423 00424 // save the current mouse position 00425 myCurrentXMousePosition = x; 00426 myCurrentYMousePosition = y; 00427 // cout << "set to current : X="<< myCurrentXMousePosition << " Y=myCurrentYMousePosition" << endl; 00428 // track a minimal drag window : 3x3 00429 // if the drag rectangle < 3x3 : do nothing 00430 if ((abs(myCurrentXMousePosition - myInitialXMousePosition) < 3) 00431 ||(abs(myCurrentYMousePosition - myInitialYMousePosition) < 3)) 00432 return exotkAF_camNothing; 00433 00434 if (myCtrlPushed) 00435 { 00436 // Ctrl is pushed 00437 return CtrlMove(x, y); 00438 } 00439 else if (myShiftPushed) 00440 { 00441 // Shift is pushed 00442 return ShiftMove(x, y); 00443 } 00444 00445 // neither Shift or Ctrl are pushed 00446 switch (myCurrentMouseButton) 00447 { 00448 case exotkAF_mbNone: 00449 // simple mousemove : ask MoveTo to set the dynamic hilight 00450 MoveTo(x, y); 00451 return exotkAF_camMoving; 00452 break; 00453 case exotkAF_mbLeft: 00454 switch (myCurrentActionMode) 00455 { 00456 case exotkAF_camNothing: 00457 // dragging select 00458 myIsDragging = Standard_True; 00459 myDocument->DisplayManager()->InteractiveContext()->Select(mySavedXMousePosition, mySavedYMousePosition, x, y, myView, Standard_False); 00460 // myView->Redraw(); //to see the object selected 00461 break; 00462 case exotkAF_camDynamicZooming: 00463 // dynamic zooming 00464 myView->Zoom(mySavedXMousePosition, mySavedYMousePosition, x, y); 00465 myView->Redraw(); 00466 mySavedXMousePosition = x; 00467 mySavedYMousePosition = y; 00468 break; 00469 case exotkAF_camWindowZooming: 00470 // camWindowZooming 00471 myIsDragging = Standard_True; 00472 break; 00473 case exotkAF_camDynamicRotation: 00474 // dynamic rotation 00475 myView->Rotation(x, y); 00476 myView->Redraw(); 00477 break; 00478 case exotkAF_camDynamicPanning: 00479 // dynamic panning 00480 myView->Pan(x - mySavedXMousePosition, mySavedYMousePosition - y); // Realize the panning 00481 myView->Redraw(); 00482 mySavedXMousePosition = x; 00483 mySavedYMousePosition = y; 00484 break; 00485 default: 00486 break; 00487 }// end left mouse button 00488 break; 00489 case exotkAF_mbMiddle: 00490 // nothing : moveto 00491 MoveTo(x, y); 00492 return exotkAF_camMoving; 00493 break; 00494 case exotkAF_camDynamicPanning: 00495 // dynamic panning 00496 myView->Pan(x - mySavedXMousePosition, mySavedYMousePosition - y); // Realize the panning 00497 myView->Redraw(); 00498 mySavedXMousePosition = x; 00499 mySavedYMousePosition = y; 00500 break; 00501 case exotkAF_mbRight: 00502 // nothing : moveto 00503 MoveTo(x, y); 00504 return exotkAF_camMoving; 00505 default: 00506 // nothing : moveto 00507 MoveTo(x, y); 00508 return exotkAF_camMoving; 00509 break; 00510 } 00511 return myCurrentActionMode; 00512 } 00513 00514 00515 //================================================================================== 00516 // Function name : exotkAF_View::CtrlMove 00517 //================================================================================== 00518 // Written by : Stephane Routelous - 2001-11-06 16:09:58 00519 // Description : 00520 // Return type : exotkAF_CurrentActionMode 00521 //================================================================================== 00522 // Argument : const Standard_Integer x 00523 // Argument : const Standard_Integer y 00524 exotkAF_CurrentActionMode exotkAF_View::CtrlMove(const Standard_Integer x , const Standard_Integer y) 00525 { 00526 if (myView.IsNull()) 00527 return exotkAF_camNothing; 00528 switch (myCurrentMouseButton) 00529 { 00530 case exotkAF_mbNone: 00531 // nothing : moveto 00532 // call to AISContext for the Automatic Hilight 00533 MoveTo(x, y); 00534 return exotkAF_camMoving; 00535 break; 00536 case exotkAF_mbMiddle: 00537 // dynamic zooming 00538 myView->Zoom(mySavedXMousePosition, mySavedYMousePosition, x, y); 00539 myView->Redraw(); 00540 mySavedXMousePosition = x; 00541 mySavedYMousePosition = y; 00542 return exotkAF_camDynamicZooming; 00543 break; 00544 case exotkAF_mbLeft: 00545 // dynamic panning 00546 myView->Pan(x - mySavedXMousePosition, mySavedYMousePosition - y); 00547 myView->Redraw(); 00548 mySavedXMousePosition = x; 00549 mySavedYMousePosition = y; 00550 return exotkAF_camDynamicPanning; 00551 break; 00552 case exotkAF_mbRight: 00553 // dynamic rotation 00554 myView->Rotation(x, y); 00555 myView->Redraw(); 00556 return exotkAF_camDynamicRotation; 00557 break; 00558 default: 00559 break; 00560 } 00561 return myCurrentActionMode; 00562 } 00563 00564 //================================================================================== 00565 // Function name : exotkAF_View::ShiftMove 00566 //================================================================================== 00567 // Written by : Stephane Routelous - 2001-11-06 16:10:02 00568 // Description : 00569 // Return type : exotkAF_CurrentActionMode 00570 //================================================================================== 00571 // Argument : const Standard_Integer x 00572 // Argument : const Standard_Integer y 00573 exotkAF_CurrentActionMode exotkAF_View::ShiftMove(const Standard_Integer x , const Standard_Integer y) 00574 { 00575 if (myView.IsNull()) 00576 return exotkAF_camNothing; 00577 00578 MoveTo(x, y); 00579 return exotkAF_camMoving; 00580 } 00581 00582 //================================================================================== 00583 // Function name : exotkAF_View::MoveTo 00584 //================================================================================== 00585 // Written by : Stephane Routelous - 2001-11-06 16:10:22 00586 // Description : 00587 // Return type : void 00588 //================================================================================== 00589 // Argument : const Standard_Integer x 00590 // Argument : const Standard_Integer y 00591 void exotkAF_View::MoveTo(const Standard_Integer x, const Standard_Integer y) 00592 { 00593 if (!myView.IsNull() 00594 && !myDocument.IsNull() 00595 && !myDocument->DisplayManager().IsNull() 00596 && !myDocument->DisplayManager()->InteractiveContext().IsNull()) 00597 { 00598 myDocument->DisplayManager()->InteractiveContext()->MoveTo(x, y, myView); 00599 } 00600 } 00601 00602 //================================================================================== 00603 // Function name : exotkAF_View::V3dView 00604 //================================================================================== 00605 // Written by : Stephane Routelous - 2001-11-06 16:10:24 00606 // Description : 00607 // Return type : Handle_V3d_View& 00608 //================================================================================== 00609 Handle_V3d_View& exotkAF_View::V3dView() 00610 { 00611 return myView; 00612 } 00613 00614 00615 //================================================================================== 00616 // Function name : exotkAF_View::CreateView 00617 //================================================================================== 00618 // Written by : Stephane Routelous - 2001-11-06 16:10:28 00619 // Description : 00620 // Return type : Standard_Boolean 00621 //================================================================================== 00622 // Argument : const Handle_V3d_Viewer& aViewer 00623 // Argument : const Aspect_Handle& anHandle 00624 Standard_Boolean exotkAF_View::CreateView(const Handle_V3d_Viewer& aViewer, const Aspect_Handle& anHandle) 00625 { 00626 if (!myView.IsNull()) 00627 return Standard_False; 00628 00629 // Creates a view from a Viewer ( default view ) 00630 myView = aViewer->CreateView(); 00631 // Creates a WNT_Window object, in order to map the V3d_View in the window 00632 Handle_Graphic3d_WNTGraphicDevice theGraphicDevice = Handle_Graphic3d_WNTGraphicDevice::DownCast(exotkAIS_GraphicDevice::Instance()->GetGraphicDevice()); 00633 00634 // Create a WNT_Window 00635 Handle_WNT_Window myWNTWindow; 00636 00637 myWNTWindow = new WNT_Window(theGraphicDevice , anHandle); 00638 if (!myWNTWindow->IsMapped()) 00639 myWNTWindow->Map(); 00640 00641 // link the WNT_Window with the V3d_View 00642 myView->SetWindow(myWNTWindow); 00643 00644 // set the default Antialiasing status 00645 if (myAntialiasingIsOn) 00646 myView->SetAntialiasingOn(); 00647 else 00648 myView->SetAntialiasingOff(); 00649 00650 FitAll(); 00651 00652 return Standard_True; 00653 } 00654 00655 //================================================================================== 00656 // Function name : exotkAF_View::SetViewType 00657 //================================================================================== 00658 // Written by : Stephane Routelous - 2001-11-06 16:10:30 00659 // Description : 00660 // Return type : void 00661 //================================================================================== 00662 // Argument : const enum exotkAF_ViewType aType 00663 void exotkAF_View::SetViewType(const enum exotkAF_ViewType aType) 00664 { 00665 switch (aType) 00666 { 00667 case exotkAF_vtFront: 00668 Front(); 00669 break; 00670 case exotkAF_vtBack: 00671 Back(); 00672 break; 00673 case exotkAF_vtRight: 00674 Right(); 00675 break; 00676 case exotkAF_vtLeft: 00677 Left(); 00678 break; 00679 case exotkAF_vtTop: 00680 Top(); 00681 break; 00682 case exotkAF_vtBottom: 00683 Bottom(); 00684 break; 00685 case exotkAF_vtAxo: 00686 Axo(); 00687 break; 00688 default: 00689 break; 00690 } 00691 } 00692 00693 //================================================================================== 00694 // Function name : exotkAF_View::Back 00695 //================================================================================== 00696 // Written by : Stephane Routelous - 2001-11-06 16:10:32 00697 // Description : 00698 // Return type : void 00699 //================================================================================== 00700 void exotkAF_View::Back() 00701 { 00702 if (!myView.IsNull()) 00703 { 00704 myView->SetProj(V3d_Xneg); 00705 myView->Redraw(); 00706 } 00707 } 00708 00709 //================================================================================== 00710 // Function name : exotkAF_View::Front 00711 //================================================================================== 00712 // Written by : Stephane Routelous - 2001-11-06 16:10:33 00713 // Description : 00714 // Return type : void 00715 //================================================================================== 00716 void exotkAF_View::Front() 00717 { 00718 if (!myView.IsNull()) 00719 { 00720 myView->SetProj(V3d_Xpos); 00721 myView->Redraw(); 00722 } 00723 } 00724 00725 //================================================================================== 00726 // Function name : exotkAF_View::Top 00727 //================================================================================== 00728 // Written by : Stephane Routelous - 2001-11-06 16:10:35 00729 // Description : 00730 // Return type : void 00731 //================================================================================== 00732 void exotkAF_View::Top() 00733 { 00734 if (!myView.IsNull()) 00735 { 00736 myView->SetProj(V3d_Zpos); 00737 myView->Redraw(); 00738 } 00739 } 00740 00741 //================================================================================== 00742 // Function name : exotkAF_View::Bottom 00743 //================================================================================== 00744 // Written by : Stephane Routelous - 2001-11-06 16:10:37 00745 // Description : 00746 // Return type : void 00747 //================================================================================== 00748 void exotkAF_View::Bottom() 00749 { 00750 if (!myView.IsNull()) 00751 { 00752 myView->SetProj(V3d_Zneg); 00753 myView->Redraw(); 00754 } 00755 } 00756 00757 //================================================================================== 00758 // Function name : exotkAF_View::Left 00759 //================================================================================== 00760 // Written by : Stephane Routelous - 2001-11-06 16:10:39 00761 // Description : 00762 // Return type : void 00763 //================================================================================== 00764 void exotkAF_View::Left() 00765 { 00766 if (!myView.IsNull()) 00767 { 00768 myView->SetProj(V3d_Yneg); 00769 myView->Redraw(); 00770 } 00771 } 00772 00773 //================================================================================== 00774 // Function name : exotkAF_View::Right 00775 //================================================================================== 00776 // Written by : Stephane Routelous - 2001-11-06 16:10:41 00777 // Description : 00778 // Return type : void 00779 //================================================================================== 00780 void exotkAF_View::Right() 00781 { 00782 if (!myView.IsNull()) 00783 { 00784 myView->SetProj(V3d_Ypos); 00785 myView->Redraw(); 00786 } 00787 } 00788 00789 //================================================================================== 00790 // Function name : exotkAF_View::Axo 00791 //================================================================================== 00792 // Written by : Stephane Routelous - 2001-11-06 16:10:42 00793 // Description : 00794 // Return type : void 00795 //================================================================================== 00796 void exotkAF_View::Axo() 00797 { 00798 if (!myView.IsNull()) 00799 { 00800 myView->SetProj(V3d_XposYnegZpos); 00801 myView->Redraw(); 00802 } 00803 } 00804 00805 //================================================================================== 00806 // Function name : exotkAF_View::Redraw 00807 //================================================================================== 00808 // Written by : Stephane Routelous - 2001-11-06 16:10:44 00809 // Description : 00810 // Return type : void 00811 //================================================================================== 00812 void exotkAF_View::Redraw() 00813 { 00814 if (!myView.IsNull()) 00815 { 00816 myView->Redraw(); 00817 } 00818 } 00819 00820 //================================================================================== 00821 // Function name : exotkAF_View::FitAll 00822 //================================================================================== 00823 // Written by : Stephane Routelous - 2001-11-06 16:10:46 00824 // Description : 00825 // Return type : void 00826 //================================================================================== 00827 void exotkAF_View::FitAll() 00828 { 00829 if (!myView.IsNull()) 00830 { 00831 myView->FitAll(0.01, Standard_True); 00832 /* if ((myCurrentActionMode == exotkAIS_camDynamicZooming) ||(myCurrentActionMode == exotkAIS_camWindowZooming)) 00833 { 00834 SetNothingMode(); 00835 } 00836 */ myView->Redraw(); 00837 } 00838 } 00839 00840 //================================================================================== 00841 // Function name : exotkAF_View::Reset 00842 //================================================================================== 00843 // Written by : Stephane Routelous - 2001-11-06 16:10:53 00844 // Description : 00845 // Return type : void 00846 //================================================================================== 00847 void exotkAF_View::Reset() 00848 { 00849 if (!myView.IsNull()) 00850 { 00851 myView->Reset(); 00852 myView->Redraw(); 00853 } 00854 } 00855 00856 //================================================================================== 00857 // Function name : exotkAF_View::Pan 00858 //================================================================================== 00859 // Written by : Stephane Routelous - 2001-11-06 16:10:55 00860 // Description : 00861 // Return type : void 00862 //================================================================================== 00863 // Argument : const Standard_Integer dX 00864 // Argument : const Standard_Integer dY 00865 void exotkAF_View::Pan(const Standard_Integer dX, const Standard_Integer dY) 00866 { 00867 if (!myView.IsNull()) 00868 myView->Pan(dX, dY); 00869 } 00870 00871 //================================================================================== 00872 // Function name : exotkAF_View::Rotate 00873 //================================================================================== 00874 // Written by : Stephane Routelous - 2001-11-06 16:11:00 00875 // Description : 00876 // Return type : void 00877 //================================================================================== 00878 // Argument : const Standard_Real Ax 00879 // Argument : const Standard_Real Ay 00880 // Argument : const Standard_Real Az 00881 void exotkAF_View::Rotate(const Standard_Real Ax, const Standard_Real Ay, const Standard_Real Az) 00882 { 00883 if (!myView.IsNull()) 00884 myView->Rotate(Ax, Ay, Az); 00885 } 00886 00887 //================================================================================== 00888 // Function name : exotkAF_View::WindowFitAll 00889 //================================================================================== 00890 // Written by : Stephane Routelous - 2001-11-06 16:11:02 00891 // Description : 00892 // Return type : void 00893 //================================================================================== 00894 // Argument : const Standard_Integer Xmin 00895 // Argument : const Standard_Integer Ymin 00896 // Argument : const Standard_Integer Xmax 00897 // Argument : const Standard_Integer Ymax 00898 void exotkAF_View::WindowFitAll(const Standard_Integer Xmin, const Standard_Integer Ymin, const Standard_Integer Xmax, const Standard_Integer Ymax) 00899 { 00900 if (!myView.IsNull()) 00901 myView->WindowFitAll(Xmin, Ymin, Xmax, Ymax); 00902 } 00903 00904 //================================================================================== 00905 // Function name : exotkAF_View::Size 00906 //================================================================================== 00907 // Written by : Stephane Routelous - 2001-11-06 16:11:03 00908 // Description : 00909 // Return type : Standard_Boolean 00910 //================================================================================== 00911 // Argument : Standard_Integer& aWidth 00912 // Argument : Standard_Integer& aHeight 00913 Standard_Boolean exotkAF_View::Size(Standard_Integer& aWidth, Standard_Integer& aHeight) 00914 { 00915 if (!myView.IsNull()) 00916 { 00917 myView->Window()->Size(aWidth, aHeight); 00918 return Standard_True; 00919 } 00920 else 00921 return Standard_False; 00922 } 00923 00924 00925 00926 //================================================================================== 00927 // Function name : exotkAF_View::BackgroundColor 00928 //================================================================================== 00929 // Written by : Stephane Routelous - 2001-11-06 16:11:06 00930 // Description : 00931 // Return type : Standard_Boolean 00932 //================================================================================== 00933 // Argument : Standard_Real &R 00934 // Argument : Standard_Real &G 00935 // Argument : Standard_Real &B 00936 // Argument : const Standard_Real& aBase 00937 Standard_Boolean exotkAF_View::BackgroundColor(Standard_Real &R, Standard_Real &G, Standard_Real &B, const Standard_Real& aBase) 00938 { 00939 if (myView.IsNull()) 00940 return Standard_False; 00941 if (aBase == 0) 00942 return Standard_False; 00943 00944 Standard_Real newR, newG, newB; 00945 00946 myView->BackgroundColor(Quantity_TOC_RGB, newR, newG, newB); 00947 R = newR * aBase; 00948 G = newG * aBase; 00949 B = newB * aBase; 00950 return Standard_True; 00951 } 00952 00953 //================================================================================== 00954 // Function name : exotkAF_View::BackgroundColor 00955 //================================================================================== 00956 // Written by : Stephane Routelous - 2001-11-06 16:11:08 00957 // Description : 00958 // Return type : Standard_Boolean 00959 //================================================================================== 00960 // Argument : Quantity_Color& aColor 00961 Standard_Boolean exotkAF_View::BackgroundColor(Quantity_Color& aColor) 00962 { 00963 Standard_Real R, G, B; 00964 if (BackgroundColor(R, G, B, 1.0)) 00965 { 00966 aColor = Quantity_Color(R, G, B, Quantity_TOC_RGB); 00967 return Standard_True; 00968 } 00969 else 00970 return Standard_False; 00971 } 00972 00973 00974 //================================================================================== 00975 // Function name : exotkAF_View::SetBackgroundColor 00976 //================================================================================== 00977 // Written by : Stephane Routelous - 2001-11-06 16:11:09 00978 // Description : 00979 // Return type : Standard_Boolean 00980 //================================================================================== 00981 // Argument : const Quantity_Color& aColor 00982 Standard_Boolean exotkAF_View::SetBackgroundColor(const Quantity_Color& aColor) 00983 { 00984 return SetBackgroundColor(aColor.Red(), aColor.Green(), aColor.Blue(), 1.0); 00985 } 00986 00987 //================================================================================== 00988 // Function name : exotkAF_View::SetBackgroundColor 00989 //================================================================================== 00990 // Written by : Stephane Routelous - 2001-11-06 16:11:11 00991 // Description : 00992 // Return type : Standard_Boolean 00993 //================================================================================== 00994 // Argument : const Standard_Real R 00995 // Argument : const Standard_Real G 00996 // Argument : const Standard_Real B 00997 // Argument : const Standard_Real Base/*=1.0*/ 00998 Standard_Boolean exotkAF_View::SetBackgroundColor(const Standard_Real R, const Standard_Real G, const Standard_Real B, const Standard_Real Base/*=1.0*/) 00999 { 01000 if (myView.IsNull()) 01001 return Standard_False; 01002 if (Base == 0) 01003 return Standard_False; 01004 01005 Standard_Real newR, newG, newB; 01006 newR = R / Base; 01007 newG = G / Base; 01008 newB = B / Base; 01009 if (((newR>1) &&(newR < 0)) &&((newG>1) &&(newG < 0)) &&((newB>1) &&(newB < 0))) 01010 return Standard_False; 01011 myView->SetBackgroundColor(Quantity_TOC_RGB, newR, newG, newB); 01012 Redraw(); 01013 return Standard_True; 01014 } 01015 01016 //================================================================================== 01017 // Function name : exotkAF_View::Resize 01018 //================================================================================== 01019 // Written by : Stephane Routelous - 2001-11-06 16:11:14 01020 // Description : 01021 // Return type : void 01022 //================================================================================== 01023 void exotkAF_View::Resize() 01024 { 01025 if (!myView.IsNull()) 01026 myView->MustBeResized(); 01027 } 01028 01029 //================================================================================== 01030 // Function name : exotkAF_View::SetHiddenLine 01031 //================================================================================== 01032 // Written by : Stephane Routelous - 2001-11-06 16:11:15 01033 // Description : 01034 // Return type : void 01035 //================================================================================== 01036 // Argument : const Standard_Boolean On 01037 void exotkAF_View::SetHiddenLine(const Standard_Boolean On) 01038 { 01039 if (!myView.IsNull()) 01040 { 01041 myIsHiddenLine = On; 01042 if (On) 01043 myView->SetDegenerateModeOff(); 01044 else 01045 myView->SetDegenerateModeOn(); 01046 } 01047 } 01048 01049 //================================================================================== 01050 // Function name : exotkAF_View::HiddenLine 01051 //================================================================================== 01052 // Written by : Stephane Routelous - 2001-11-06 16:11:17 01053 // Description : 01054 // Return type : Standard_Boolean 01055 //================================================================================== 01056 Standard_Boolean exotkAF_View::HiddenLine() 01057 { 01058 return myIsHiddenLine; 01059 } 01060 01061 //================================================================================== 01062 // Function name : exotkAF_View::SetAntialiasing 01063 //================================================================================== 01064 // Written by : Stephane Routelous - 2001-11-06 16:11:19 01065 // Description : 01066 // Return type : void 01067 //================================================================================== 01068 // Argument : const Standard_Boolean On 01069 void exotkAF_View::SetAntialiasing(const Standard_Boolean On) 01070 { 01071 if (!myView.IsNull()) 01072 { 01073 myAntialiasingIsOn = On; 01074 if (On) 01075 myView->SetAntialiasingOn(); 01076 else 01077 myView->SetAntialiasingOff(); 01078 myView->Redraw(); 01079 } 01080 } 01081 01082 //================================================================================== 01083 // Function name : exotkAF_View::Antialiasing 01084 //================================================================================== 01085 // Written by : Stephane Routelous - 2001-11-06 16:11:21 01086 // Description : 01087 // Return type : Standard_Boolean 01088 //================================================================================== 01089 Standard_Boolean exotkAF_View::Antialiasing() 01090 { 01091 return myAntialiasingIsOn; 01092 } 01093 01094 01095 //================================================================================== 01096 // Function name : exotkAF_View::IsValid 01097 //================================================================================== 01098 // Written by : Stephane Routelous - 2001-11-06 16:11:23 01099 // Description : 01100 // Return type : Standard_Boolean 01101 //================================================================================== 01102 Standard_Boolean exotkAF_View::IsValid() 01103 { 01104 return (!myView.IsNull()); 01105 } 01106 01107 //================================================================================== 01108 // Function name : exotkAF_View::CurrentMouseButton 01109 //================================================================================== 01110 // Written by : Stephane Routelous - 2001-11-06 16:11:25 01111 // Description : 01112 // Return type : exotkAF_MouseButton 01113 //================================================================================== 01114 exotkAF_MouseButton exotkAF_View::CurrentMouseButton() 01115 { 01116 return myCurrentMouseButton; 01117 } 01118 01119 //================================================================================== 01120 // Function name : exotkAF_View::CurrentMousePosition 01121 //================================================================================== 01122 // Written by : Stephane Routelous - 2001-11-06 16:11:27 01123 // Description : 01124 // Return type : void 01125 //================================================================================== 01126 // Argument : Standard_Integer& aX 01127 // Argument : Standard_Integer& aY 01128 void exotkAF_View::CurrentMousePosition(Standard_Integer& aX, Standard_Integer& aY) 01129 { 01130 aX = myCurrentXMousePosition; 01131 aY = myCurrentYMousePosition; 01132 } 01133 01134 //================================================================================== 01135 // Function name : exotkAF_View::ZoomIn 01136 //================================================================================== 01137 // Written by : Stephane Routelous - 2001-11-06 16:11:29 01138 // Description : 01139 // Return type : void 01140 //================================================================================== 01141 void exotkAF_View::ZoomIn() 01142 { 01143 Standard_Integer theHeight, theWidth; 01144 01145 if (Size(theWidth, theHeight)) 01146 { 01147 Standard_Real theZoomFactor = 0.1; 01148 if (myCtrlPushed) 01149 theZoomFactor = 0.2; 01150 Standard_Integer theNewDX = (Standard_Integer)floor(fabs(theWidth*theZoomFactor) + 0.5); 01151 Standard_Integer theNewDY = (Standard_Integer)floor(fabs(theHeight*theZoomFactor) + 0.5); 01152 WindowFitAll(theNewDX, theNewDY, theWidth - theNewDX, theHeight - theNewDY); 01153 } 01154 } 01155 01156 01157 //================================================================================== 01158 // Function name : exotkAF_View::ZoomOut 01159 //================================================================================== 01160 // Written by : Stephane Routelous - 2001-11-06 16:11:32 01161 // Description : 01162 // Return type : void 01163 //================================================================================== 01164 void exotkAF_View::ZoomOut() 01165 { 01166 Standard_Integer theHeight, theWidth; 01167 01168 if (Size(theWidth, theHeight)) 01169 { 01170 Standard_Real theZoomFactor = 0.1; 01171 if (myCtrlPushed) 01172 theZoomFactor = 0.2; 01173 Standard_Integer theNewDX = (Standard_Integer)floor(fabs(theWidth*theZoomFactor) + 0.5); 01174 Standard_Integer theNewDY = (Standard_Integer)floor(fabs(theHeight*theZoomFactor) + 0.5); 01175 WindowFitAll(-theNewDX, - theNewDY, theWidth + theNewDX, theHeight + theNewDY); 01176 } 01177 } 01178 01179 //================================================================================== 01180 // Function name : exotkAF_View::PopupMenu 01181 //================================================================================== 01182 // Written by : Stephane Routelous - 2001-11-06 16:11:34 01183 // Description : 01184 // Return type : Standard_Boolean 01185 //================================================================================== 01186 // Argument : Handle_exotkTree_Menu& aMenu 01187 Standard_Boolean exotkAF_View::PopupMenu(Handle_exotkTree_Menu& aMenu) 01188 { 01189 Standard_Boolean theSuccess = Standard_False; 01190 if (IsPopup()) 01191 { 01192 if (myDocument->DisplayManager()->InteractiveContext()->NbCurrents() > 0) 01193 { 01194 Handle_exotkAIS_InteractiveObjectPopup theMenu = new exotkAIS_InteractiveObjectPopup(); 01195 if ( theMenu->Create(myDocument->DisplayManager())) 01196 { 01197 aMenu = theMenu; 01198 theSuccess = Standard_True; 01199 } 01200 } 01201 else 01202 { 01203 Handle_exotkAF_ViewPopup theMenu = new exotkAF_ViewPopup(); 01204 if (theMenu->Create(this)) 01205 { 01206 aMenu = theMenu; 01207 theSuccess = Standard_True; 01208 } 01209 } 01210 } 01211 return theSuccess; 01212 }
1.2.12 written by Dimitri van Heesch,
© 1997-2001