// Created on: 1997-01-29
// Created by: Robert COUBLANC
// Copyright (c) 1997-1999 Matra Datavision
-// Copyright (c) 1999-2012 OPEN CASCADE SAS
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
-// The content of this file is subject to the Open CASCADE Technology Public
-// License Version 6.5 (the "License"). You may not use the content of this file
-// except in compliance with the License. Please obtain a copy of the License
-// at http://www.opencascade.org and read it completely before using this file.
+// This file is part of Open CASCADE Technology software library.
//
-// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
//
-// The Original Code and all software distributed under the License is
-// distributed on an "AS IS" basis, without warranty of any kind, and the
-// Initial Developer hereby disclaims all such warranties, including without
-// limitation, any warranties of merchantability, fitness for a particular
-// purpose or non-infringement. Please see the License for the specific terms
-// and conditions governing the rights and limitations under the License.
-
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
#define UKI60826 //GG_161199 Use the requested selection color instead of default
#define BUC60814 //GG_300101 Idem UKI60826
-#define IMP150501 //GG_150501 CADPAK_V2 Add Drag() method
-
-#define IMP160701 //ZSV Add InitDetected(),MoreDetected(),NextDetected(),
-// DetectedCurrentShape(),DetectedCurrentObject()
-// methods
-
-#define IMP191001 //GG Avoid to raise when switching with the
-// SetAutomaticHilight() method.
-// Thanks to IFO of SAMTECH company for this improvment.
-
#define OCC138 //VTN Avoding infinit loop in AddOrRemoveCurrentObject method.
#define OCC9657
#include <AIS_GlobalStatus.hxx>
#include <AIS_Shape.hxx>
+#include <Aspect_Grid.hxx>
+
#include <V3d_Light.hxx>
#include <V3d_PositionalLight.hxx>
#include <V3d_SpotLight.hxx>
#include <SelectMgr_Selection.hxx>
#include <SelectBasics_SensitiveEntity.hxx>
-#ifdef IMP150501
-#include <Visual3d_TransientManager.hxx>
#include <Prs3d_Presentation.hxx>
-#endif
#ifdef OCC9657
#include <AIS_MapOfInteractive.hxx>
}
#endif
*/
+
//=======================================================================
//function : MoveTo
-//purpose :
+//purpose :
//=======================================================================
-
-AIS_StatusOfDetection AIS_InteractiveContext::MoveTo(const Standard_Integer XPix,
- const Standard_Integer YPix,
- const Handle(V3d_View)& aView)
+AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer theXPix,
+ const Standard_Integer theYPix,
+ const Handle(V3d_View)& theView,
+ const Standard_Boolean theToRedrawOnUpdate)
{
- if(HasOpenedContext()&& aView->Viewer()!=myCollectorVwr){
+ if (HasOpenedContext())
+ {
myWasLastMain = Standard_True;
- return myLocalContexts(myCurLocalIndex)->MoveTo(XPix,YPix,aView);
+ return myLocalContexts (myCurLocalIndex)->MoveTo (theXPix, theYPix, theView, theToRedrawOnUpdate);
}
-#ifdef IMP160701
- //Nullify class members storing information about detected AIS objects.
myAISCurDetected = 0;
myAISDetectedSeq.Clear();
-#endif
- // OCC11904 - local variables made non-static - it looks and works better like this
- Handle (PrsMgr_PresentationManager3d) pmgr ;
- Handle (StdSelect_ViewerSelector3d) selector;
- Standard_Boolean ismain = Standard_True,UpdVwr = Standard_False;
-
- // Preliminaires
- if(aView->Viewer()== myMainVwr) {
- pmgr = myMainPM;
- selector=myMainSel;
- myLastPicked = myLastinMain;
- myWasLastMain = Standard_True;
- }
- else if (aView->Viewer()== myCollectorVwr){
- pmgr = myCollectorPM;
- selector=myCollectorSel;
- myLastPicked = myLastinColl;
- ismain = Standard_False;
- myWasLastMain = Standard_False;
- }
- else
+ if (theView->Viewer() != myMainVwr)
+ {
return AIS_SOD_Error;
-
- AIS_StatusOfDetection TheStat(AIS_SOD_Nothing);
-
-
+ }
+
+ // preliminaires
+ myLastPicked = myLastinMain;
+ myWasLastMain = Standard_True;
+ AIS_StatusOfDetection aStatus = AIS_SOD_Nothing;
+ Standard_Boolean toUpdateViewer = Standard_False;
+
// allonzy
- selector->Pick(XPix, YPix, aView);
-
-#ifdef IMP160701
- //filling of myAISDetectedSeq sequence storing information about detected AIS objects
- // (the objects must be AIS_Shapes).
- Handle(SelectMgr_EntityOwner) anEntityOwner;
- const Standard_Integer NbDetected = selector->NbPicked();
- for(Standard_Integer i_detect = 1;i_detect<=NbDetected;i_detect++)
+ myMainSel->Pick (theXPix, theYPix, theView);
+
+ // filling of myAISDetectedSeq sequence storing information about detected AIS objects
+ // (the objects must be AIS_Shapes)
+ const Standard_Integer aDetectedNb = myMainSel->NbPicked();
+ for (Standard_Integer aDetIter = 1; aDetIter <= aDetectedNb; ++aDetIter)
{
- anEntityOwner = selector->Picked(i_detect);
- if(!anEntityOwner.IsNull())
- if(myFilters->IsOk(anEntityOwner))
- {
- Handle(AIS_InteractiveObject) anObj =
- Handle(AIS_InteractiveObject)::DownCast(anEntityOwner->Selectable());
- if(!Handle(AIS_Shape)::DownCast(anObj).IsNull())
- myAISDetectedSeq.Append(anObj);
- }
+ Handle(SelectMgr_EntityOwner) anOwner = myMainSel->Picked (aDetIter);
+ if (anOwner.IsNull()
+ || !myFilters->IsOk (anOwner))
+ {
+ continue;
+ }
+
+ Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
+ if (!Handle(AIS_Shape)::DownCast (anObj).IsNull())
+ {
+ myAISDetectedSeq.Append (anObj);
+ }
}
-#endif
- selector->Init();
- if ( selector->More() )
+ myMainSel->Init();
+ if (myMainSel->More())
{
- if ( HasOpenedContext() )
- if ( !myFilters->IsOk( selector->OnePicked() ) )
- return AIS_SOD_AllBad;
- else
- if ( !myLocalContexts( myCurLocalIndex )->Filter()->IsOk( selector->OnePicked() ) )
- return AIS_SOD_AllBad;
-
-
- // Does nothing if previously detected object is equal to the current one
- if ( selector->OnePicked()->Selectable() == myLastPicked )
- return AIS_SOD_OnlyOneDetected;
+ // does nothing if previously detected object is equal to the current one
+ if (myMainSel->OnePicked()->Selectable() == myLastPicked)
+ {
+ return myLastPicked->State() == 1
+ ? AIS_SOD_Selected
+ : AIS_SOD_OnlyOneDetected;
+ }
// Previously detected object is unhilighted if it is not selected or hilighted
// with selection color if it is selected. Such highlighting with selection color
// is needed only if myToHilightSelected flag is true. In this case previously detected
// object has been already highlighted with myHilightColor during previous MoveTo()
// method call. As result it is necessary to rehighligt it with mySelectionColor.
- if ( !myLastPicked.IsNull() )
+ if (!myLastPicked.IsNull())
{
- Standard_Integer HiMod =
- myLastPicked->HasHilightMode() ? myLastPicked->HilightMode() : 0;
- if ( myLastPicked->State() != 1 )
+ const Standard_Integer aHiMod = myLastPicked->HasHilightMode() ? myLastPicked->HilightMode() : 0;
+ if (myLastPicked->State() != 1)
{
- pmgr->Unhighlight( myLastPicked, HiMod );
- UpdVwr = Standard_True;
+ myMainPM->Unhighlight (myLastPicked, aHiMod);
+ toUpdateViewer = Standard_True;
}
- else if ( myToHilightSelected )
+ else if (myToHilightSelected)
{
- pmgr->Color( myLastPicked, mySelectionColor, HiMod );
- UpdVwr = Standard_True;
+ myMainPM->Color (myLastPicked, mySelectionColor, aHiMod);
+ toUpdateViewer = Standard_True;
}
}
-
- // Initialize myLastPicked field with currently detected object
- Handle(SelectMgr_SelectableObject) SO = selector->OnePicked()->Selectable();
- myLastPicked = *((Handle(AIS_InteractiveObject)*)&SO);
-
- if ( ismain )
- myLastinMain = myLastPicked;
- else
- myLastinColl = myLastPicked;
-#ifdef IMP191001
- // Highlight detected object if it is not selected or myToHilightSelected flag is true
- if ( !myLastPicked.IsNull() &&
- ( myLastPicked->State()!= 1 || myToHilightSelected ) )
-#else
- if ( myLastPicked->State()!= 1 )
-#endif
+
+ // initialize myLastPicked field with currently detected object
+ myLastPicked = Handle(AIS_InteractiveObject)::DownCast (myMainSel->OnePicked()->Selectable());
+ myLastinMain = myLastPicked;
+
+ // highlight detected object if it is not selected or myToHilightSelected flag is true
+ if (!myLastPicked.IsNull())
{
- Standard_Integer HiMod =
- myLastPicked->HasHilightMode() ? myLastPicked->HilightMode() : 0;
- pmgr->Color( myLastPicked, myHilightColor, HiMod );
- UpdVwr = Standard_True;
+ if (myLastPicked->State() != 1 || myToHilightSelected)
+ {
+ const Standard_Integer aHiMod = myLastPicked->HasHilightMode() ? myLastPicked->HilightMode() : 0;
+ myMainPM->Color (myLastPicked, myHilightColor, aHiMod);
+ toUpdateViewer = Standard_True;
+ }
+
+ aStatus = myLastPicked->State() == 1
+ ? AIS_SOD_Selected
+ : AIS_SOD_OnlyOneDetected;
}
-
- if ( myLastPicked->State()==1 )
- TheStat = AIS_SOD_Selected;
}
else
{
- // Previously detected object is unhilighted if it is not selected or hilighted
- // with selection color if it is selected.
- TheStat = AIS_SOD_Nothing;
- if ( !myLastPicked.IsNull() )
+ // previously detected object is unhilighted if it is not selected or hilighted
+ // with selection color if it is selected
+ aStatus = AIS_SOD_Nothing;
+ if (!myLastPicked.IsNull())
{
- Standard_Integer HiMod =
- myLastPicked->HasHilightMode() ? myLastPicked->HilightMode() : 0;
- if ( myLastPicked->State() != 1 )
+ Standard_Integer aHiMod = myLastPicked->HasHilightMode() ? myLastPicked->HilightMode() : 0;
+ if (myLastPicked->State() != 1)
{
- pmgr->Unhighlight( myLastPicked, HiMod );
- UpdVwr = Standard_True;
+ myMainPM->Unhighlight (myLastPicked, aHiMod);
+ toUpdateViewer = Standard_True;
}
- else if ( myToHilightSelected )
+ else if (myToHilightSelected)
{
- pmgr->Color( myLastPicked, mySelectionColor, HiMod );
- UpdVwr = Standard_True;
+ myMainPM->Color (myLastPicked, mySelectionColor, aHiMod);
+ toUpdateViewer = Standard_True;
}
}
-
- if ( ismain )
- myLastinMain.Nullify();
+
+ myLastinMain.Nullify();
+ myLastPicked.Nullify();
+ }
+
+ if (toUpdateViewer)
+ {
+ if (theToRedrawOnUpdate)
+ {
+ theView->Viewer()->Update();
+ }
else
- myLastinColl.Nullify();
+ {
+ theView->Viewer()->Invalidate();
+ }
}
-
- if(UpdVwr) aView->Viewer()->Update();
- myLastPicked.Nullify();
-
- mylastmoveview = aView;
- return TheStat;
+
+ mylastmoveview = theView;
+ return aStatus;
}
//=======================================================================
if(aView->Viewer()== myMainVwr) {
selector= myMainSel;
myWasLastMain = Standard_True;}
-
- else if (aView->Viewer()==myCollectorVwr){
- selector= myCollectorSel;
- myWasLastMain = Standard_False;}
-
-
+
selector->Pick(XPMin,YPMin,XPMax,YPMax,aView);
AIS_Selection::SetCurrentSelection(myCurrentName.ToCString());
if(aView->Viewer()== myMainVwr) {
selector= myMainSel;
myWasLastMain = Standard_True;}
-
- else if (aView->Viewer()==myCollectorVwr){
- selector= myCollectorSel;
- myWasLastMain = Standard_False;}
-
-
+
selector->Pick(aPolyline,aView);
AIS_Selection::SetCurrentSelection(myCurrentName.ToCString());
if(myWasLastMain)
return myLocalContexts(myCurLocalIndex)->Select(updateviewer);
else
- // picking was done in the collector, special processing is required...
{
myLocalContexts(myCurLocalIndex)->SetSelected(myLastPicked,updateviewer);
return AIS_SOP_OneSelected;
if(updateviewer)
UpdateCurrentViewer();}
}
- else if (!myWasLastMain && !myLastinColl.IsNull()){
- if(myLastinColl->State()!=1){
- SetCurrentObject(myLastinColl,Standard_False);
- if(updateviewer)
- UpdateCollector();}
- }
else{
AIS_Selection::SetCurrentSelection(myCurrentName.ToCString());
Handle(AIS_Selection) S = AIS_Selection::CurrentSelection();
AIS_Selection::Select();
if(updateviewer){
if(myWasLastMain)
- UpdateCurrentViewer();
- else
- UpdateCollector();
+ UpdateCurrentViewer();
}
}
Standard_Integer NS = NbCurrents();
}
if(myWasLastMain && !myLastinMain.IsNull())
AddOrRemoveCurrentObject(myLastinMain,updateviewer);
- else if (!myWasLastMain && !myLastinColl.IsNull())
- AddOrRemoveCurrentObject(myLastinColl,updateviewer);
-
-
+
Standard_Integer NS = NbCurrents();
if(NS==0) return AIS_SOP_NothingSelected;
if(NS==1) return AIS_SOP_OneSelected;
if(aView->Viewer()== myMainVwr) {
selector= myMainSel;
myWasLastMain = Standard_True;}
-
- else if (aView->Viewer()==myCollectorVwr){
- selector= myCollectorSel;
- myWasLastMain = Standard_False;}
else
return AIS_SOP_NothingSelected;
selector= myMainSel;
myWasLastMain = Standard_True;
}
- else if ( aView->Viewer() == myCollectorVwr ) {
- selector= myCollectorSel;
- myWasLastMain = Standard_False;
- }
else
return AIS_SOP_NothingSelected;
//=======================================================================
//function : HilightNextDetected
-//purpose :
+//purpose :
//=======================================================================
-Standard_Integer AIS_InteractiveContext::HilightNextDetected(const Handle(V3d_View)& V)
+Standard_Integer AIS_InteractiveContext::HilightNextDetected (const Handle(V3d_View)& theView,
+ const Standard_Boolean theToRedrawImmediate)
{
- if(!HasOpenedContext())
- return 0;
- return myLocalContexts(myCurLocalIndex)->HilightNextDetected(V);
+ return HasOpenedContext()
+ ? myLocalContexts (myCurLocalIndex)->HilightNextDetected (theView, theToRedrawImmediate)
+ : 0;
}
//=======================================================================
//function : HilightNextDetected
-//purpose :
+//purpose :
//=======================================================================
-Standard_Integer AIS_InteractiveContext::HilightPreviousDetected(const Handle(V3d_View)& V)
+Standard_Integer AIS_InteractiveContext::HilightPreviousDetected (const Handle(V3d_View)& theView,
+ const Standard_Boolean theToRedrawImmediate)
{
- if(!HasOpenedContext())
- return 0;
- return myLocalContexts(myCurLocalIndex)->HilightPreviousDetected(V);
+ return HasOpenedContext()
+ ? myLocalContexts (myCurLocalIndex)->HilightPreviousDetected (theView, theToRedrawImmediate)
+ : 0;
}
-#ifdef IMP150501
-void AIS_InteractiveContext::Drag(
- const Handle(V3d_View)& aView,
- const Handle(AIS_InteractiveObject)& anObject,
- const Handle(Geom_Transformation)& aTrsf,
- const Standard_Boolean postConcatenate,
- const Standard_Boolean update,
- const Standard_Boolean zBuffer) {
-
- if( anObject.IsNull() || aView.IsNull() ) return;
-
- if( update ) {
- anObject->SetTransformation(aTrsf,postConcatenate,Standard_True);
- aView->Update();
- } else if( Visual3d_TransientManager::BeginDraw(aView->View(),
- zBuffer,Standard_False) ) {
- Handle(Prs3d_Presentation) P = anObject->Presentation();
- if( !P.IsNull() ) {
- if( postConcatenate ) P->Multiply(aTrsf);
- else P->Transform(aTrsf);
- Visual3d_TransientManager::DrawStructure(P);
- }
- Visual3d_TransientManager::EndDraw(Standard_True);
- }
-}
-#endif
-
-#ifdef IMP160701
//=======================================================================
//function : InitDetected
//purpose :
else
return aBad;
}
-#endif