for( SUIT_Selector* selector = aSelectors.first(); selector; selector = aSelectors.next() )
{
qDebug( selector->type() );
- if( selector->type()!=client )
+ if( selector->type() != client && selector->isEnabled() )
{
- mgr->selected( cur_sel, selector->type() );
+ //mgr->selected( cur_sel, selector->type() );
+ selector->selected( cur_sel );
SUIT_DataOwnerPtrList::const_iterator aLIt = cur_sel.begin(), aLLast = cur_sel.end();
for( ; aLIt!=aLLast; aLIt++ )
sel.append( *aLIt ); //check entry and don't append if such entry is in list already
#include <qdragobject.h>
#include <qapplication.h>
#include <qpopupmenu.h>
+#include <qfontmetrics.h>
using namespace std;
{
int para=paragraphs()-1;
int col=paragraphLength(para);
- insertAt(s,para,col);
+
+ // Limit length of the string because exception may occur if string too long (NPAL16033)
+ // Exception occurs if one of paragraphs of the input string "s" is too long. Now long
+ // paragraph is limited with threshold numbers of characters and finished by " ..." string.
+ // Note that first paragraph of the string is checked only because it is enough for bug fixing.
+ // If it will be insufficient for other cases then more complicated check should be implemented.
+ // At present it is not done because of possible performance problem.
+
+ static int threshold = 50000;
+ long strLength = s.length();
+ if ( col + strLength <= threshold || s.find( '\n' ) < threshold )
+ insertAt(s,para,col);
+ else
+ {
+ if ( col >= threshold )
+ {
+ if ( text( para ).right( 5 ) != QString( " ...\n" ) )
+ insertAt(" ...\n",para,col);
+ }
+ else
+ {
+ long n = threshold - col;
+ s.truncate( n );
+ if ( n >= 5 )
+ {
+ s.at( n - 5 ) = QChar( ' ' );
+ s.at( n - 4 ) = QChar( '.' );
+ s.at( n - 3 ) = QChar( '.' );
+ s.at( n - 2 ) = QChar( '.' );
+ s.at( n - 1 ) = QChar( '\n' );
+ }
+ else
+ s = " ...\n";
+ insertAt(s,para,col);
+ }
+ }
+
int n = paragraphs()-1;
setCursorPosition( n, paragraphLength(n));
}
_currentPrompt = READY_PROMPT;
_buf.truncate(0);
_isInHistory = false;
- setText( "\n" + _currentPrompt);
- setText( command + "\n" );
- handleReturn();
+ setText( "\n" + _currentPrompt);
+ // PAL15963 (Problem with option -u (--execute) of runSalome).
+ // Let events creating a study end before script execution starts
+ setText( command /*+ "\n"*/ );
+ //handleReturn();
+ qApp->postEvent( this, new QKeyEvent(QEvent::KeyPress,Key_Return,13,Qt::NoButton ));
}
void PythonConsole_PyEditor::execAndWait( const QString& command )
else if ( ctrlPressed ) {
moveCursor( QTextEdit::MoveUp, false );
}
- else {
- QString histLine = _currentPrompt;
- if ( ! _isInHistory ) {
- _isInHistory = true;
- _currentCommand = text( endLine ).remove( 0, PROMPT_SIZE );
- _currentCommand.truncate( _currentCommand.length() - 1 );
- }
- QString previousCommand = myInterp->getPrevious();
- if ( previousCommand.compare( BEGIN_HISTORY_PY ) != 0 )
- {
- removeParagraph( endLine );
- histLine.append( previousCommand );
- append( histLine );
- }
- moveCursor( QTextEdit::MoveEnd, false );
+ else {
+ QString histLine = _currentPrompt;
+ if ( ! _isInHistory ) {
+ _isInHistory = true;
+ _currentCommand = text( endLine ).remove( 0, PROMPT_SIZE );
+ _currentCommand.truncate( _currentCommand.length() - 1 );
+ }
+ QString previousCommand = myInterp->getPrevious();
+ if ( previousCommand.compare( BEGIN_HISTORY_PY ) != 0 )
+ {
+ removeParagraph( endLine );
+ histLine.append( previousCommand );
+ append( histLine );
+ }
+ moveCursor( QTextEdit::MoveEnd, false );
+ scrollViewAfterHistoryUsing( previousCommand ); // NPAL16035
}
break;
}
}
}
moveCursor( QTextEdit::MoveEnd, false );
+ scrollViewAfterHistoryUsing( nextCommand ); // NPAL16035
}
break;
}
return popup;
}
+
+/*!
+ Scrolls view after use of history (Up/Down keys)to the left position if length
+ of command less than visible width of the view
+*/
+void PythonConsole_PyEditor::scrollViewAfterHistoryUsing( const QString& command )
+{
+ if ( !command.isEmpty() )
+ {
+ if ( command == QString( BEGIN_HISTORY_PY ) )
+ {
+ ensureCursorVisible();
+ return;
+ }
+
+ QFontMetrics aFM( currentFont() );
+ int aCommandLength = aFM.width( command ) + aFM.width( READY_PROMPT ) + 5;
+ int aVisibleWidth = visibleWidth();
+ QScrollBar* aBar = horizontalScrollBar();
+ if ( aBar )
+ {
+ if ( aCommandLength <= aVisibleWidth )
+ aBar->setValue( aBar->minValue() );
+ else if ( aVisibleWidth > 0 )
+ {
+ double aRatio = aCommandLength / contentsWidth();
+ double aPos = ( aBar->maxValue() - aBar->minValue() ) * aRatio;
+ aBar->setValue( (int)aPos );
+ ensureCursorVisible();
+ }
+ }
+ }
+}
virtual void keyPressEvent (QKeyEvent* event);
virtual void mousePressEvent (QMouseEvent* event);
virtual void customEvent (QCustomEvent* event);
-
+
public slots:
void handleReturn();
void onPyInterpChanged( PyInterp_base* );
virtual QPopupMenu* createPopupMenu( const QPoint& );
-
+
+private:
+
+ void scrollViewAfterHistoryUsing( const QString& command );
+
private:
QString _buf;
QString _currentCommand;
Default constructor
*/
SUIT_Application::SUIT_Application()
-: QObject( 0 ),
-myStudy( 0 ),
-myDesktop( 0 ),
-myStatusLabel( 0 )
-{
+ : QObject( 0 ),
+ myStudy( 0 ),
+ myDesktop( 0 ),
+ myStatusLabel( 0 ),
+ myIsInitiallyRegistered( false )
+{
}
/*!
//! Invokes application-specific "Select Directory" dialog and returns the selected directory name.
virtual QString getDirectory( const QString& initial, const QString& caption, QWidget* parent ) = 0;
+ //! Perform required actions on the application, just registed in the session
+ virtual void Registered() { myIsInitiallyRegistered = true; };
+
signals:
void applicationClosed( SUIT_Application* );
void activated( SUIT_Application* );
protected slots:
virtual void onDesktopActivated();
+protected:
+ bool myIsInitiallyRegistered; //<! false before the first application registration in the session
+
private:
SUIT_Study* myStudy;
SUIT_Desktop* myDesktop;
/*!
Slot, called on activation of some application's desktop
*/
-void SUIT_Session::onApplicationActivated( SUIT_Application* app )
+void SUIT_Session::onApplicationActivated( SUIT_Application* app )
{
myActiveApp = app;
+ if (app)
+ app->Registered();
}
/*!
{
return false;
}
-
-/*!
- * \brief Stores the study state
-*/
-int SUIT_Study::storeState()
-{
- return -1;
-}
/*!
- * \brief Restores the study state
-*/
+ * \brief Restores the study state.
+ */
void SUIT_Study::restoreState(int savePoint)
{
+ // Redefined in SalomeApp_Study.
+ // Called from SALOME_Session_i::restoreVisualState(CORBA::Long theSavePoint)
}
bool suspend( SUIT_Operation* );
bool resume( SUIT_Operation* );
- virtual int storeState();
virtual void restoreState(int savePoint);
signals:
LightApp_Application::start();
SalomeApp_EventFilter::Init();
+}
- static bool isFirst = true;
- if ( isFirst ) {
- isFirst = false;
+/*!Just registered in the session*/
+void SalomeApp_Application::Registered()
+{
+ if (!myIsInitiallyRegistered)
+ {
+ myIsInitiallyRegistered = true;
+ // execute python scripts
QString hdffile;
QStringList pyfiles;
SUIT_ViewManager* newViewManager(const QString&);
void updateSavePointDataObjects( SalomeApp_Study* );
+ virtual void Registered();
+
public slots:
virtual bool onOpenDoc( const QString& );
virtual void onLoadDoc();
return "Interface Applicative";
}
+/*!
+ * \brief Restores the study state
+ */
+void SalomeApp_Study::restoreState(int savePoint)
+{
+ SalomeApp_VisualState((SalomeApp_Application*)application()).restoreState(savePoint);
+}
+
+
/*!
Slot: called on change of a root of a data model. Redefined from CAM_Study
*/
void setNameOfSavePoint(int savePoint, const QString& nameOfSavePoint);
virtual std::string getVisualComponentName();
+ virtual void restoreState(int savePoint);
+
protected:
virtual void saveModuleData ( QString theModuleName, QStringList theListOfFiles );
virtual void openModuleData ( QString theModuleName, QStringList& theListOfFiles );
#include <vtkCell.h>
#include <vtkPlane.h>
#include <vtkMath.h>
+#include <vtkCellArray.h>
+#include <vtkTriangle.h>
+#include <vtkOrderedTriangulator.h>
#ifdef _DEBUG_
static int DEBUG_TRIA_EXECUTE = 0;
*/
VTKViewer_OrderedTriangulator
::VTKViewer_OrderedTriangulator():
- myCell(vtkGenericCell::New())
-{}
+ myCell(vtkGenericCell::New()),
+ myBoundaryTris(vtkCellArray::New()),
+ myTriangle(vtkTriangle::New()),
+ myTriangulator(vtkOrderedTriangulator::New())
+{
+ myBoundaryTris->Allocate(100);
+ myTriangulator->PreSortedOff();
+ //myTriangulator->UseTemplatesOn();
+}
/*!
Destructor
::~VTKViewer_OrderedTriangulator()
{
myCell->Delete();
+ myBoundaryTris->Delete();
+ myTriangle->Delete();
+ myTriangulator->Delete();
}
vtkPoints*
::InitPoints()
{
myInput->GetCell(myCellId,myCell);
+
+ int numPts = myCell->GetNumberOfPoints();
+ if ( numPts > 0 )
+ {
+ myTriangulator->InitTriangulation(0.0,1.0, 0.0,1.0, 0.0,1.0, numPts);
+
+ vtkFloatingPointType x[3], p[3];
+ vtkIdType ptId;
+ vtkFloatingPointType *bounds = myCell->GetBounds();
+
+ // Inject cell points into triangulation
+ for (int i=0; i<numPts; i++)
+ {
+ myCell->Points->GetPoint(i, x);
+ for (int j=0; j<3; j++)
+ p[j] = (x[j] - bounds[2*j]) / (bounds[2*j+1] - bounds[2*j]);
+ ptId = myCell->PointIds->GetId(i);
+ // myTriangulator->InsertPoint(ptId, x, x, 0);
+ myTriangulator->InsertPoint(ptId, x, p, 0);
+ }//for all points
+
+
+// if ( myCell->IsPrimaryCell() ) //use templates if topology is fixed
+// {
+// int numEdges=myCell->GetNumberOfEdges();
+// myTriangulator->TemplateTriangulate(myCell->GetCellType(),
+// numPts,numEdges);
+// }
+// else //use ordered triangulator
+ {
+ myTriangulator->Triangulate();
+ }
+ }
return myInput->GetPoints();
}
VTKViewer_OrderedTriangulator
::GetNumFaces()
{
- return myCell->GetNumberOfFaces();
+ myBoundaryTris->Reset();
+ myTriangulator->AddTriangles(myBoundaryTris);
+ return myBoundaryTris->GetNumberOfCells();
+ //return myCell->GetNumberOfFaces();
}
vtkCell*
VTKViewer_OrderedTriangulator
::GetFace(vtkIdType theFaceId)
{
- return myCell->GetFace(theFaceId);
+ int numCells = myBoundaryTris->GetNumberOfCells();
+ if ( theFaceId < 0 || theFaceId >=numCells ) {return NULL;}
+
+ vtkIdType *cells = myBoundaryTris->GetPointer();
+
+ // Each triangle has three points plus number of points
+ vtkIdType *cptr = cells + 4*theFaceId;
+ for (int i=0; i<3; i++)
+ {
+ myTriangle->PointIds->SetId(i,cptr[i+1]);
+ myTriangle->Points->SetPoint(i,myCell->Points->GetPoint(cptr[i+1]));
+ }
+
+ return myTriangle;
+ //return myCell->GetFace(theFaceId);
}
void
class vtkPoints;
class vtkIdList;
class vtkCell;
+class vtkCellArray;
+class vtkTriangle;
+class vtkOrderedTriangulator;
class VTKVIEWER_EXPORT VTKViewer_Triangulator
{
~VTKViewer_OrderedTriangulator();
protected:
- vtkGenericCell *myCell;
+ vtkGenericCell *myCell;
+ vtkCellArray *myBoundaryTris;
+ vtkTriangle *myTriangle;
+ vtkOrderedTriangulator *myTriangulator;
virtual
vtkPoints*