/////////////////////////////////////////////////////////////////////////////// // Copyright (C) 2002-2025, Open Design Alliance (the "Alliance"). // All rights reserved. // // This software and its documentation and related materials are owned by // the Alliance. The software may only be incorporated into application // programs owned by members of the Alliance, subject to a signed // Membership Agreement and Supplemental Software License Agreement with the // Alliance. The structure and organization of this software are the valuable // trade secrets of the Alliance and its suppliers. The software is also // protected by copyright law and international treaty provisions. Application // programs incorporating this software must include the following statement // with their copyright notices: // // This application incorporates Open Design Alliance software pursuant to a license // agreement with Open Design Alliance. // Open Design Alliance Copyright (C) 2002-2025 by Open Design Alliance. // All rights reserved. // // By use of this software, its documentation or related materials, you // acknowledge and accept the above terms. /////////////////////////////////////////////////////////////////////////////// #ifndef _DbBlockPropertiesTable_h_Included_ #define _DbBlockPropertiesTable_h_Included_ #include "DbBlock1PtParameter.h" #include "DbBlockGrip.h" #include "DbParameterInterface.h" /** \details Corresponding C++ library: TD_Db */ class OdDbBPTAuditError { public: /** \details Defines the audit error types for a block properties table. */ enum BPTAuditErrorType { /** Empty. */ empty, /** No matching row. */ noMatchingRow, /** Invalid cell. */ invalidCell, /** No in value set. */ notInValueSet, /** Non-constant attribute definition. */ nonConstAttDef, /** Invalid unmatched value. */ invalidUnmatchedValue, /** Duplicate rows. */ duplicateRows, /** Expression external reference. */ exprExternRef, /** Cell evaluation error. */ cellEvalError }; /** \details Gets the error type. \returns One of the enumerated items from the BPTAuditErrorType enumerated type. */ BPTAuditErrorType errorType() const { return m_Type; } /** \details Gets the index of a cell. \param row [out] Receives the row of the cell. \param col [out] Receives the column of the cell. */ void getCellIndex(int& row, int& col)const { row = m_nRow; col = m_nCol; } /** \details Gets the column index. \returns The column index as an integer value. */ int getColumnIndex()const { return m_nCol; } /** \details Gets the row indices. \returns The array of row indices. */ OdIntArray getRowIndex() const { return m_Rows; } /** \details Gets the unmatched value index. \returns The unmatched value index. */ int getUnmatchedValueIndex()const { return m_nRow; } /** \details Constructor */ OdDbBPTAuditError(BPTAuditErrorType t = empty, int r = -1, int c = -1, OdIntArray indices = OdIntArray()) : m_Type(t), m_nRow(r), m_nCol(c), m_Rows(indices) {} private: BPTAuditErrorType m_Type = empty; int m_nRow = -1; int m_nCol = -1; OdIntArray m_Rows; }; /** \details Corresponding C++ library: TD_Db */ class DYNBLOCKS_EXPORT OdDbBlockPropertiesTable : public OdDbBlock1PtParameter { public: //DOM-IGNORE-BEGIN ODDB_EVAL_DECLARE_MEMBERS(OdDbBlockPropertiesTable); //DOM-IGNORE-END /** \details Creates a new instance of an OdDbBlockPropertiesTable object with default parameters. */ OdDbBlockPropertiesTable(); /** \details Returns the number of columns in the table. \returns The number of columns in the table. */ int numberOfColumns() const; /** \details Returns the number of rows in the table. \returns The number of rows in the table. */ int numberOfRows() const; /** \details Returns the value of the specified cell. \param column [in] Column index. \param row [in] Row index. \param rb [out] Receives a copy of the cell value. \returns Returns eOk if the indices are valid, or eInvalidIndex otherwise. */ OdResult getCellValue(int column, int row, OdDbEvalVariant& rb) const; /** \details Sets the value of the specified cell. \param column [in] Column index. \param row [in] Row index. \param rb [out] The cell value to set. \returns Returns eOk if the indices are valid, or eInvalidInput otherwise. */ OdResult setCellValue(int column, int row, const OdDbEvalVariant& rb); /** \details Returns the value of the specified cell as an OdString value. \param column [in] Column index. \param row [in] Row index. \param s [out] Receives a copy of the cell value as an OdString value. \returns Returns eOk if the indices are valid, or eInvalidIndex otherwise. */ OdResult getCellValueString(int column, int row, OdString &s) const; /** \details Checks whether the specified column is constant. \param column [in] Column index. \returns The true value if the specified column is constant, or false otherwise. \remarks Throws the eInvalidIndex exception if the column index is not valid. */ bool constant(int column) const; /** \details Specifies whether the column is constant. \param column [in] Column index. \param val [in] Specify true to set that the column is constant, or false otherwise. \returns Returns eOk if the column is set to constant successfully, or eInvalidIndex otherwise. */ OdResult setConstant(int column, bool val); /** \details Checks whether the specified column is editable. \param column [in] Column index. \returns The true value if the specified column is editable, or false otherwise. \remarks Throws the eInvalidIndex exception if the column index is not valid. */ bool editable(int column) const; /** \details Specifies whether the column is editable. \param column [in] Column index. \param val [in] Specify true to set that the column is editable, or false otherwise. \returns Returns eOk if the index is valid, or eInvalidIndex otherwise. */ OdResult setEditable(int column, bool val); /** \details Checks whether the specified column is removable. \param column [in] Column index. \returns The true value if the specified column is removable, or false otherwise. \remarks Throws the eInvalidIndex exception if the column index is not valid. */ bool removable(int column) const; /** \details Specifies whether the column is removable. \param column [in] Column index. \param val [in] Specify true to mark the column as removable, or false otherwise. \returns Returns eOk if the index is valid, or eInvalidIndex otherwise. */ OdResult setRemovable(int column, bool val); /** \details Checks whether the specified column is angular. \param column [in] Column index. \returns The true value if the specified column is angular, or false otherwise. \remarks Throws the eInvalidIndex exception if the column index is not valid. */ bool isAngular(int column) const; /** \details Checks whether the specified column is an attribute. \param column [in] Column index. \returns The true value if the specified column is an attribute, or false otherwise. \remarks Throws the eInvalidIndex exception if the column index is not valid. */ bool isAttribute(int) const; /** \details Gets the ID of the custom properties. \param column [in] Column index. \returns The ID of the custom properties. \remarks The ID of the custom properties is optional. The default value is NULL. Throws the eInvalidIndex exception if the column index is not valid. */ OdDbObjectId customProperties(int column) const; /** \details Sets the ID of the custom properties. \param column [in] Column index. \param id [in] ID of the custom properties. \remarks Throws the eInvalidIndex exception if the column index is not valid. */ void setCustomProperties(int column, const OdDbObjectId& id); /** \details Gets the default value of the specified column. \param column [in] Column index. \returns Pointer to the default value of the specified column as an OdDbEvalVariant object. \remarks Throws the eInvalidIndex exception if the column index is not valid. */ OdDbEvalVariant defaultValue(int column) const; /** \details Sets the default value of the specified column. \param column [in] Column index. \param rb [in] Pointer to the default value of the specified column. \remarks Throws the eInvalidIndex exception if the column index is not valid. */ void setDefaultValue(int column, const OdDbEvalVariant& rb); /** \details Gets the format of the specified column. \param column [in] Column index. \returns Format of the specified column as an OdString object. \remarks Throws the eInvalidIndex exception if the column index is not valid. */ OdString format(int column) const; /** \details Sets the format of the specified column. \param column [in] Column index. \param f [in] Format of the specified column. \remarks Throws the eInvalidIndex exception if the column index is not valid. */ void setFormat(int column, const OdString& f); /** \details Checks whether the values of the parameters must match some rows. \returns The true value if the values of the parameters must match some rows, or false otherwise. */ bool mustMatch() const; /** \details Specifies whether the values of the parameters must match some rows. \param b [in] Specify true to set that the values of the parameters must match some rows, or false otherwise. */ void setMustMatch(bool b); /** \details Sets the unmatched value of the specified column. \param column [in] Column index. \param rb [in] Unmatched value of the specified column. \remarks Throws the eInvalidIndex exception if the column index is not valid. */ void setUnmatchedValue(int column, const OdDbEvalVariant& rb); /** \details Gets the unmatched value of the specified column. \param column [in] Column index. \returns Unmatched value of the specified column as an OdDbEvalVariant object. \remarks Throws the eInvalidIndex exception if the column index is not valid. */ OdDbEvalVariant unmatchedValue(int column) const; /** \details Gets the name of the column. \param column [in] Column index. \returns The name of the column. \remarks Throws the eInvalidIndex exception if the column index is not valid. Returns OdString::kEmpty if the object specified with the column is NULL or if the object does not belong to any of these types: * OdDbBlockUserParameter * OdDbBlockParameter * OdDbAttributeDefinition * OdDbAttributeDefinitionPtr */ OdString getColumnName(int column) const; /** \details Gets the table description. \returns The table description as an OdString value. \remarks The returned value is used as the corresponding UI property description. */ OdString tableDescription() const; /** \details Sets the table description. \param s [in] The table description. \remarks The parameter value is used as the corresponding UI property description. */ void setTableDescription(const OdString& s); /** \details Gets the name of the table. \returns The name of the table as an OdString value. \remarks The returned value is used as the corresponding UI property name. */ OdString tableName() const; /** \details Gets the name of the table. \param s [in] The name of the table. \remarks The parameter value is used as the corresponding UI property name. */ void setTableName(const OdString& s); /** \details Gets the ID of the specified row. \param index [in] Row index. \returns The ID of the specified row as an integer value. \remarks Returns -1 if the index is not valid. Rows may be reordered, but each row has a unique (within the table) ID that does not change. */ int idOfRow(int index) const; /** \details Gets the index of the specified row ID. \param id [in] Row ID. \returns The index of the specified row ID. \remarks Returns -1 if the index is not valid. Rows may be reordered, but each row has a unique (within the table) ID that does not change. */ int indexOfRow(int id) const; /** \details Returns the index of the column corresponding to the given parameter interface */ int indexOfColumn(const OdDbParameterInterface*) const; /** \details Inserts a column after the specified index. \param param [in] Parameter id for the column. \param connection [in] Parameter connection string for the column. \param index [in] Insertion index (may be equal to the number of columns) \remarks Returns eInvalidIndex if the specified index is not valid. Returns eInvalidInput if the parameter or connection is invalid, or such a column already exists */ OdResult insertColumn(const OdDbObjectId& param, const OdString& connection, int index); /** \details Inserts a row after the specified index. \param index [in] Index of the row where to insert (may be equal to the number of rows). \remarks Throws the eInvalidIndex exception if the specified index is not valid. */ void insertRow(int index); /** \details Removes the column at the specified index. \param column [in] Index of the column to remove. \remarks Throws the eInvalidIndex exception if the specified index is not valid. Throws eInvalidInput if the column is not removable. */ void removeColumn(int column); /** \details Removes the row at the specified index. \param row [in] Index of row. \remarks Throws the eInvalidIndex exception if the specified index is not valid. */ void removeRow(int row); /** \details Appends the column. \param param [in] ID of the column. \param connection [in] Connection for the column. \remarks Returns eInvalidInput if the parameter or connection is invalid, or such a column already exists */ OdResult appendColumn(const OdDbObjectId& param, const OdString& connection); /** \details Appends the row. */ void appendRow(); /** \details Moves the column from the original position to a new position. \param from [in] Index from which to move the column. \param to [in] Index to which to move the column. \remarks Throws the eInvalidIndex exception if the from or to index is not valid. If the from and to indices are equal, exits the function. */ void moveColumn(int from, int to); /** \details Moves the row from the original position to a new position. \param from [in] Index from which to move the row. \param to [in] Index to which to move the row. \remarks Throws the eInvalidIndex exception if the from or to indices are not valid. If the from and to indices are equal, exits the function. */ void moveRow(int from, int to); /** \details Gets the node ID of a block properties table. \param gr [in] Eval graph. \returns The block properties table node ID. \remarks The block properties table node ID is stored in the eval graph xdata, and reactors keep it updated. */ static OdDbEvalNodeId bptNodeId(const OdDbEvalGraph* gr); void addedToGraph(OdDbEvalGraph* ) override; void erased(const OdDbObject* pObject, bool erasing) override; OdResult subErase(bool erasing) override; void modified(const OdDbObject* pObj) override; /** \details Looks for a row that matches the default parameter values. */ int getDefaultActiveRow() const; /** \details Changes the default values of the parameters used in the table. \param row [in] Row index. \remarks Throws the eNotImplemented exception. */ void setDefaultActiveRow(int row); /** \details Checks whether the column values are unique. \param col [in] Column index. \returns The true value if the column values are unique, or false otherwise. \remarks Throws the eInvalidIndex exception if the column index is not valid. */ bool columnValuesAreUnique(int col)const; /** \details Returns is the table is currently is in invalid state */ bool disabledInDrawingEditor() const; /** \details Checks whether the parameters are only runtime. \returns The true value if the parameters are only runtime, or false otherwise. */ bool runtimeParametersOnly()const; /** \details Specifies whether the parameters are only runtime parameters. \param b [in] Specify true to set the parameters for only runtime, or false otherwise. */ void setRuntimeParametersOnly(bool b); /** \details Gets the column information into an array. \remarks Refer to the OdDbBPTAuditError::BPTAuditErrorType enumerated type for the available error types. */ void tableAudit(OdArray&); /** \details Sorts the rows. \param column [in] Column index. \param ascending [in] Specify true to sort by ascending, or false to sort by descending. \remarks Throws the eInvalidIndex exception if the from or to indcies are not valid. */ void sortRows(int column, bool ascending); /** \details Gets the parameter interface for the given column. \param column [in] Column index. \param runtime [in] If the interface should access runtime (updated) properties. \param mode [in] Parameter open mode. \param block [in] Dynamic block reference (optional). */ OdDbParameterInterfacePtr parameterInterface(int column, bool runtime = false, OdDb::OpenMode mode = OdDb::kForRead, const OdDbBlockReference* block = nullptr) const; /** \details Gets the parameter id for the given column. \param column [in] Column index. */ OdDbObjectId getColumnParam(int column) const; /** \details * Returns an index of the column with the least sorting key (if all the column don't have sorting keys then it returns -1) */ int getFirstKeyColumn() const; /** \details Returns an index of column with a next sorting key (minimal key larger than that of this column), or an index of the nearest following column w/o a sorting key if this colun has no sorting key */ int getNextKeyColumn(int column) const; /** \details * Returns the sorting key of the column, or -1 if it is not set */ int getKeyValue(int column) const; void setKeyValue(int column, unsigned int key); void unsetKeyValue(int column); }; /** \details This template class is a specialization of the OdSmartPtr class for OdDbBlockPropertiesTable objects. */ typedef OdSmartPtr OdDbBlockPropertiesTablePtr; /** \details Grip point for the OdDbBlockPropertiesTable Corresponding C++ library: TD_Db */ class DYNBLOCKS_EXPORT OdDbBlockPropertiesTableGrip : public OdDbBlockGrip { public: //DOM-IGNORE-BEGIN ODDB_DECLARE_MEMBERS(OdDbBlockPropertiesTableGrip); //DOM-IGNORE-END /** \details Creates a new instance of an OdDbBlockPropertiesTableGrip object with default parameters. */ OdDbBlockPropertiesTableGrip(); /** \details Returns true if the grip should be desplayed */ bool showGrip() const; }; /** \details This template class is a specialization of the OdSmartPtr class for OdDbBlockPropertiesTableGrip objects. */ typedef OdSmartPtr OdDbBlockPropertiesTableGripPtr; #endif //_DbBlockPropertiesTable_h_Included_