TopoDS_Face FindByPoint( const gp_Pnt2d&, QString& theType ) const;
-protected:
TopoDS_Shape GetShape() const;
+
+protected:
void SetShape( const TopoDS_Shape& );
bool LocalPartition( const TopoDS_Shape&, const QString& theNewType );
#include <ElSLib.hxx>
#include <Geom_Curve.hxx>
#include <gp_Pln.hxx>
+#include <Quantity_Color.hxx>
#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Face.hxx>
return QString( (QChar*)theStr.ToExtString(), theStr.Length() );
}
+Quantity_Color HYDROData_Tool::toOccColor( const QColor& theColor )
+{
+ double r = theColor.red() / 255.0;
+ double g = theColor.green() / 255.0;
+ double b = theColor.blue() / 255.0;
+
+ return Quantity_Color( r, g, b, Quantity_TOC_RGB );
+}
+
std::ostream& operator<<( std::ostream& theStream, const QString& theText )
{
theStream << theText.toStdString();
return theStream;
}
-
class TopoDS_Shape;
class TopoDS_Wire;
class TopTools_SequenceOfShape;
+class Quantity_Color;
class HYDRODATA_EXPORT HYDROData_Tool {
static TCollection_ExtendedString toExtString( const QString& );
static QString toQString( const TCollection_ExtendedString& );
+
+ static Quantity_Color toOccColor( const QColor& );
};
inline bool ValuesEquals( const double& theFirst, const double& theSecond )
HYDROGUI_ExportSinusXOp.h
HYDROGUI_ExportSinusXDlg.h
HYDROGUI_InputPanel.h
+ HYDROGUI_LandCoverMapPrs.h
HYDROGUI_LocalCSDlg.h
HYDROGUI_LocalCSOp.h
HYDROGUI_MergePolylinesDlg.h
HYDROGUI_ExportSinusXOp.cxx
HYDROGUI_ExportSinusXDlg.cxx
HYDROGUI_InputPanel.cxx
+ HYDROGUI_LandCoverMapPrs.cxx
HYDROGUI_LocalCSDlg.cxx
HYDROGUI_LocalCSOp.cxx
HYDROGUI_MergePolylinesDlg.cxx
--- /dev/null
+// Copyright (C) 2014-2015 EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include <HYDROGUI_LandCoverMapPrs.h>
+#include <HYDROData_Iterator.h>
+#include <HYDROData_Tool.h>
+#include <AIS_DisplayMode.hxx>
+#include <Prs3d.hxx>
+#include <Select3D_SensitiveBox.hxx>
+#include <StdPrs_ShadedShape.hxx>
+#include <StdPrs_WFDeflectionShape.hxx>
+#include <StdSelect.hxx>
+#include <StdSelect_BRepOwner.hxx>
+#include <StdSelect_BRepSelectionTool.hxx>
+#include <TopoDS_Face.hxx>
+#include <QColor>
+#include <QString>
+
+Handle(HYDROData_LandCoverMap) HYDROGUI_LandCoverMapPrs::GetLandCoverMap() const
+{
+ return myLCMap;
+}
+
+void HYDROGUI_LandCoverMapPrs::SetLandCoverMap( const Handle(HYDROData_LandCoverMap)& theMap )
+{
+ myLCMap = theMap;
+}
+
+Handle(Aspect_ColorScale) HYDROGUI_LandCoverMapPrs::GetColorScale() const
+{
+ return myColorScale;
+}
+
+void HYDROGUI_LandCoverMapPrs::SetColorScale( const Handle(Aspect_ColorScale)& theColorScale )
+{
+ myColorScale = theColorScale;
+}
+
+Handle(HYDROData_StricklerTable) HYDROGUI_LandCoverMapPrs::GetTable() const
+{
+ return myTable;
+}
+
+void HYDROGUI_LandCoverMapPrs::SetTable( const Handle(HYDROData_StricklerTable)& theTable )
+{
+ myTable = theTable;
+}
+
+Quantity_Color HYDROGUI_LandCoverMapPrs::GetColor( const QString& theStricklerType ) const
+{
+ Quantity_Color aResult;
+
+ if( !myColorScale.IsNull() && !myTable.IsNull() )
+ {
+ double aCoeff = myTable->Get( theStricklerType, 0.0 );
+ Standard_Boolean isOK = myColorScale->FindColor( aCoeff, aResult );
+ if( isOK )
+ return aResult;
+ else
+ return Quantity_Color();
+ }
+
+ if( !myTable.IsNull() && myTable->HasType( theStricklerType ) )
+ {
+ QColor aColor = myTable->GetColor( theStricklerType );
+ return HYDROData_Tool::toOccColor( aColor );
+ }
+
+ HYDROData_Iterator anIt( HYDROData_Document::Document( myLCMap->Label() ), KIND_STRICKLER_TABLE );
+ for( ; anIt.More(); anIt.Next() )
+ {
+ Handle(HYDROData_StricklerTable) aTable = Handle(HYDROData_StricklerTable)::DownCast( anIt.Current() );
+ if( aTable->HasType( theStricklerType ) )
+ {
+ QColor aColor = myTable->GetColor( theStricklerType );
+ return HYDROData_Tool::toOccColor( aColor );
+ }
+ }
+
+ return Quantity_Color();
+}
+
+void HYDROGUI_LandCoverMapPrs::Compute( const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
+ const Handle(Prs3d_Presentation)& thePresentation,
+ const Standard_Integer theMode )
+{
+ if( myLCMap.IsNull() )
+ return;
+
+ switch( theMode )
+ {
+ case AIS_WireFrame:
+ case AIS_Shaded:
+ {
+ bool isShaded = theMode==AIS_Shaded;
+ HYDROData_LandCoverMap::Iterator anIt( myLCMap );
+ for( ; anIt.More(); anIt.Next() )
+ {
+ TopoDS_Face aFace = anIt.Face();
+ QString aStricklerType = anIt.StricklerType();
+ Quantity_Color aColor = GetColor( aStricklerType );
+ SetColor( aColor );
+
+ if( isShaded )
+ StdPrs_ShadedShape::Add( thePresentation, aFace, myDrawer );
+ else
+ StdPrs_WFDeflectionShape::Add( thePresentation, aFace, myDrawer );
+ }
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+void HYDROGUI_LandCoverMapPrs::ComputeSelection( const Handle(SelectMgr_Selection)& theSelection,
+ const Standard_Integer theMode )
+{
+ if( myLCMap.IsNull() )
+ return;
+
+ if( theMode==0 )
+ {
+ theSelection->Clear();
+ Bnd_Box B = BoundingBox();
+ Handle(StdSelect_BRepOwner) anOwner = new StdSelect_BRepOwner( myLCMap->GetShape(), this );
+ Handle(Select3D_SensitiveBox) aSensitiveBox = new Select3D_SensitiveBox( anOwner, B );
+ theSelection->Add( aSensitiveBox );
+ }
+ else
+ {
+ Standard_Real aDeflection = Prs3d::GetDeflection( myLCMap->GetShape(), myDrawer );
+ HYDROData_LandCoverMap::Iterator anIt( myLCMap );
+ for( ; anIt.More(); anIt.Next() )
+ {
+ StdSelect_BRepSelectionTool::Load( theSelection,
+ this,
+ anIt.Face(),
+ TopAbs_FACE,
+ aDeflection,
+ myDrawer->HLRAngle(),
+ myDrawer->IsAutoTriangulation());
+ }
+ StdSelect::SetDrawerForBRepOwner( theSelection, myDrawer );
+ }
+}
--- /dev/null
+// Copyright (C) 2014-2015 EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef HYDROGUI_LANDCOVERMAP_PRS_H
+#define HYDROGUI_LANDCOVERMAP_PRS_H
+
+#include <HYDROData_LandCoverMap.h>
+#include <HYDROData_StricklerTable.h>
+#include <AIS_Shape.hxx>
+#include <Aspect_ColorScale.hxx>
+
+class HYDROGUI_LandCoverMapPrs : public AIS_Shape
+{
+public:
+ Handle(HYDROData_LandCoverMap) GetLandCoverMap() const;
+ void SetLandCoverMap( const Handle(HYDROData_LandCoverMap)& );
+
+ Handle(Aspect_ColorScale) GetColorScale() const;
+ void SetColorScale( const Handle(Aspect_ColorScale)& );
+
+ Handle(HYDROData_StricklerTable) GetTable() const;
+ void SetTable( const Handle(HYDROData_StricklerTable)& );
+
+ virtual void Compute( const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
+ const Handle(Prs3d_Presentation)& thePresentation,
+ const Standard_Integer theMode );
+
+ virtual void ComputeSelection( const Handle(SelectMgr_Selection)& theSelection,
+ const Standard_Integer theMode );
+
+ Quantity_Color GetColor( const QString& theStricklerType ) const;
+
+private:
+ Handle(HYDROData_LandCoverMap) myLCMap;
+ Handle(Aspect_ColorScale) myColorScale;
+ Handle(HYDROData_StricklerTable) myTable;
+};
+
+#endif
#include <TestViewer.h>
+#include <HYDROData_Tool.h>
#include <random.h>
#include <OCCViewer_ViewManager.h>
#ifdef WIN32
void TestViewer::show( const TopoDS_Shape& theShape, int theMode, bool isFitAll, const QColor& theColor )
{
- double r = theColor.red() / 255.0;
- double g = theColor.green() / 255.0;
- double b = theColor.blue() / 255.0;
-
Handle(AIS_Shape) aShape = new AIS_Shape( theShape );
aShape->SetMaterial( Graphic3d_NOM_PLASTIC );
- aShape->SetColor( Quantity_Color( r, g, b, Quantity_TOC_RGB ) );
+ aShape->SetColor( HYDROData_Tool::toOccColor( theColor ) );
context()->Display( aShape, theMode, 0, Standard_False );
if( isFitAll )